diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index 8337d1da57..6fc77ea08d 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -62,16 +62,12 @@ jobs: matrix: node-version: ${{ fromJson(needs.matrix.outputs.latest) }} eslint: + - 8 - 7 - # - 6 - # - 5 package: - eslint-config-airbnb react-hooks: - - '' - # - 3 # TODO: re-enable these once the react config uses eslint 8 - # - 2.3 - # - 1.7 + - 4 defaults: run: @@ -131,16 +127,12 @@ jobs: fail-fast: false matrix: eslint: + - 8 - 7 - # - 6 - # - 5 package: - eslint-config-airbnb react-hooks: - - '' - # - 3 # TODO: re-enable these once the react config uses eslint 8 - # - 2.3 - # - 1.7 + - 4 defaults: run: diff --git a/packages/eslint-config-airbnb/test/test-react-order.js b/packages/eslint-config-airbnb/test/test-react-order.js index dca8b73e8a..0ab4f937f7 100644 --- a/packages/eslint-config-airbnb/test/test-react-order.js +++ b/packages/eslint-config-airbnb/test/test-react-order.js @@ -4,25 +4,25 @@ import eslintrc from '..'; import reactRules from '../rules/react'; import reactA11yRules from '../rules/react-a11y'; +const rules = { + // It is okay to import devDependencies in tests. + 'import/no-extraneous-dependencies': [2, { devDependencies: true }], + // this doesn't matter for tests + 'lines-between-class-members': 0, + // otherwise we need some junk in our fixture code + 'react/no-unused-class-component-methods': 0, +}; const cli = new (CLIEngine || ESLint)({ useEslintrc: false, baseConfig: eslintrc, - - rules: { - // It is okay to import devDependencies in tests. - 'import/no-extraneous-dependencies': [2, { devDependencies: true }], - // this doesn't matter for tests - 'lines-between-class-members': 0, - // otherwise we need some junk in our fixture code - 'react/no-unused-class-component-methods': 0, - }, + ...(CLIEngine ? { rules } : { overrideConfig: { rules } }), }); -function lint(text) { +async function lint(text) { // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles // @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext - const linter = CLIEngine ? cli.executeOnText(text) : cli.lintText(text); - return linter.results[0]; + const linter = CLIEngine ? cli.executeOnText(text) : await cli.lintText(text); + return (CLIEngine ? linter.results : linter)[0]; } function wrapComponent(body) { @@ -42,9 +42,8 @@ test('validate react methods order', (t) => { t.deepEqual(reactA11yRules.plugins, ['jsx-a11y', 'react']); }); - t.test('passes a good component', (t) => { - t.plan(3); - const result = lint(wrapComponent(` + t.test('passes a good component', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} handleSubmit() {} onButtonAClick() {} @@ -61,9 +60,8 @@ test('validate react methods order', (t) => { t.notOk(result.errorCount, 'no errors'); }); - t.test('order: when random method is first', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when random method is first', async (t) => { + const result = await lint(wrapComponent(` someMethod() {} componentDidMount() {} setFoo() {} @@ -77,9 +75,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when random method after lifecycle methods', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when random method after lifecycle methods', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} someMethod() {} setFoo() {} @@ -93,9 +90,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when handler method with `handle` prefix after method with `on` prefix', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when handler method with `handle` prefix after method with `on` prefix', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} onButtonAClick() {} handleSubmit() {} @@ -108,9 +104,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when lifecycle methods after event handler methods', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when lifecycle methods after event handler methods', async (t) => { + const result = await lint(wrapComponent(` handleSubmit() {} componentDidMount() {} setFoo() {} @@ -122,9 +117,8 @@ test('validate react methods order', (t) => { t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort'); }); - t.test('order: when event handler methods after getters and setters', (t) => { - t.plan(2); - const result = lint(wrapComponent(` + t.test('order: when event handler methods after getters and setters', async (t) => { + const result = await lint(wrapComponent(` componentDidMount() {} setFoo() {} getFoo() {}