Skip to content

Commit 371537f

Browse files
committed
[Tests] re-enable tests disabled for the eslint 8 upgrade
1 parent c05ffb2 commit 371537f

File tree

2 files changed

+28
-42
lines changed

2 files changed

+28
-42
lines changed

.github/workflows/node.yml

+4-12
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,12 @@ jobs:
6262
matrix:
6363
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
6464
eslint:
65+
- 8
6566
- 7
66-
# - 6
67-
# - 5
6867
package:
6968
- eslint-config-airbnb
7069
react-hooks:
71-
- ''
72-
# - 3 # TODO: re-enable these once the react config uses eslint 8
73-
# - 2.3
74-
# - 1.7
70+
- 4
7571

7672
defaults:
7773
run:
@@ -131,16 +127,12 @@ jobs:
131127
fail-fast: false
132128
matrix:
133129
eslint:
130+
- 8
134131
- 7
135-
# - 6
136-
# - 5
137132
package:
138133
- eslint-config-airbnb
139134
react-hooks:
140-
- ''
141-
# - 3 # TODO: re-enable these once the react config uses eslint 8
142-
# - 2.3
143-
# - 1.7
135+
- 4
144136

145137
defaults:
146138
run:

packages/eslint-config-airbnb/test/test-react-order.js

+24-30
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import eslintrc from '..';
44
import reactRules from '../rules/react';
55
import reactA11yRules from '../rules/react-a11y';
66

7+
const rules = {
8+
// It is okay to import devDependencies in tests.
9+
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
10+
// this doesn't matter for tests
11+
'lines-between-class-members': 0,
12+
// otherwise we need some junk in our fixture code
13+
'react/no-unused-class-component-methods': 0,
14+
};
715
const cli = new (CLIEngine || ESLint)({
816
useEslintrc: false,
917
baseConfig: eslintrc,
10-
11-
rules: {
12-
// It is okay to import devDependencies in tests.
13-
'import/no-extraneous-dependencies': [2, { devDependencies: true }],
14-
// this doesn't matter for tests
15-
'lines-between-class-members': 0,
16-
// otherwise we need some junk in our fixture code
17-
'react/no-unused-class-component-methods': 0,
18-
},
18+
...(CLIEngine ? { rules } : { overrideConfig: { rules } }),
1919
});
2020

21-
function lint(text) {
21+
async function lint(text) {
2222
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeonfiles
2323
// @see https://eslint.org/docs/developer-guide/nodejs-api.html#executeontext
24-
const linter = CLIEngine ? cli.executeOnText(text) : cli.lintText(text);
25-
return linter.results[0];
24+
const linter = CLIEngine ? cli.executeOnText(text) : await cli.lintText(text);
25+
return (CLIEngine ? linter.results : linter)[0];
2626
}
2727

2828
function wrapComponent(body) {
@@ -42,9 +42,8 @@ test('validate react methods order', (t) => {
4242
t.deepEqual(reactA11yRules.plugins, ['jsx-a11y', 'react']);
4343
});
4444

45-
t.test('passes a good component', (t) => {
46-
t.plan(3);
47-
const result = lint(wrapComponent(`
45+
t.test('passes a good component', async (t) => {
46+
const result = await lint(wrapComponent(`
4847
componentDidMount() {}
4948
handleSubmit() {}
5049
onButtonAClick() {}
@@ -61,9 +60,8 @@ test('validate react methods order', (t) => {
6160
t.notOk(result.errorCount, 'no errors');
6261
});
6362

64-
t.test('order: when random method is first', (t) => {
65-
t.plan(2);
66-
const result = lint(wrapComponent(`
63+
t.test('order: when random method is first', async (t) => {
64+
const result = await lint(wrapComponent(`
6765
someMethod() {}
6866
componentDidMount() {}
6967
setFoo() {}
@@ -77,9 +75,8 @@ test('validate react methods order', (t) => {
7775
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
7876
});
7977

80-
t.test('order: when random method after lifecycle methods', (t) => {
81-
t.plan(2);
82-
const result = lint(wrapComponent(`
78+
t.test('order: when random method after lifecycle methods', async (t) => {
79+
const result = await lint(wrapComponent(`
8380
componentDidMount() {}
8481
someMethod() {}
8582
setFoo() {}
@@ -93,9 +90,8 @@ test('validate react methods order', (t) => {
9390
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
9491
});
9592

96-
t.test('order: when handler method with `handle` prefix after method with `on` prefix', (t) => {
97-
t.plan(2);
98-
const result = lint(wrapComponent(`
93+
t.test('order: when handler method with `handle` prefix after method with `on` prefix', async (t) => {
94+
const result = await lint(wrapComponent(`
9995
componentDidMount() {}
10096
onButtonAClick() {}
10197
handleSubmit() {}
@@ -108,9 +104,8 @@ test('validate react methods order', (t) => {
108104
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
109105
});
110106

111-
t.test('order: when lifecycle methods after event handler methods', (t) => {
112-
t.plan(2);
113-
const result = lint(wrapComponent(`
107+
t.test('order: when lifecycle methods after event handler methods', async (t) => {
108+
const result = await lint(wrapComponent(`
114109
handleSubmit() {}
115110
componentDidMount() {}
116111
setFoo() {}
@@ -122,9 +117,8 @@ test('validate react methods order', (t) => {
122117
t.deepEqual(result.messages.map((msg) => msg.ruleId), ['react/sort-comp'], 'fails due to sort');
123118
});
124119

125-
t.test('order: when event handler methods after getters and setters', (t) => {
126-
t.plan(2);
127-
const result = lint(wrapComponent(`
120+
t.test('order: when event handler methods after getters and setters', async (t) => {
121+
const result = await lint(wrapComponent(`
128122
componentDidMount() {}
129123
setFoo() {}
130124
getFoo() {}

0 commit comments

Comments
 (0)