Skip to content

Commit b84fadd

Browse files
test: add ESLint 8.x tests (#200)
1 parent 1e665e6 commit b84fadd

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

.github/workflows/validate.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
if: ${{ !contains(github.head_ref, 'all-contributors') }}
1717
strategy:
1818
matrix:
19-
eslint: [6.8.0, 6, 7.0.0, 7]
19+
eslint: [6.8.0, 6, 7.0.0, 7, 8.0.0, 8]
2020
node: [12.22.0, 12, 14.17.0, 14, 16.0.0, 16]
2121
runs-on: ubuntu-latest
2222
steps:
@@ -40,11 +40,11 @@ jobs:
4040
run: npm install --no-save --force eslint@${{ matrix.eslint }}
4141

4242
- name: ▶️ Run validate script (without linting)
43-
if: ${{ matrix.eslint != 7 }}
43+
if: ${{ matrix.eslint != 8 }}
4444
run: npm run validate -- build,test:coverage
4545

4646
- name: ▶️ Run validate script (with linting)
47-
if: ${{ matrix.eslint == 7 }}
47+
if: ${{ matrix.eslint == 8 }}
4848
run: npm run validate
4949

5050
- name: ⬆️ Upload coverage report

package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,22 @@
4545
"requireindex": "^1.2.0"
4646
},
4747
"devDependencies": {
48-
"@typescript-eslint/parser": "^4.33.0",
49-
"eslint": "^7.31.0",
50-
"eslint-remote-tester": "^2.0.1",
48+
"@typescript-eslint/parser": "^5.9.1",
49+
"eslint": "^8.7.0",
50+
"eslint-remote-tester": "^2.1.1",
5151
"eslint-remote-tester-repositories": "^0.0.4",
52-
"kcd-scripts": "^11.2.2",
52+
"kcd-scripts": "^12.0.0",
5353
"typescript": "^4.5.3"
5454
},
5555
"peerDependencies": {
56-
"eslint": ">=6.8"
56+
"eslint": "^6.8.0 || ^7.0.0 || ^8.0.0"
5757
},
5858
"eslintConfig": {
5959
"extends": "./node_modules/kcd-scripts/eslint.js",
6060
"rules": {
61-
"babel/quotes": "off",
61+
"consistent-return": "off",
6262
"max-lines-per-function": "off",
63-
"testing-library/no-dom-import": "off",
64-
"consistent-return": "off"
63+
"testing-library/no-dom-import": "off"
6564
}
6665
},
6766
"eslintIgnore": [

src/rules/prefer-to-have-class.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,18 @@ export const create = (context) => ({
116116
classValue.type === "CallExpression" &&
117117
classValue.callee.type === "MemberExpression" &&
118118
classValue.callee.object.name === "expect"
119-
)
119+
) {
120120
return;
121+
}
122+
121123
context.report({
122124
node: matcher,
123125
messageId,
124126
fix(fixer) {
125-
if (checkedProp.name === "classList" && matcher.name !== "toContain")
127+
if (checkedProp.name === "classList" && matcher.name !== "toContain") {
126128
return;
129+
}
130+
127131
return [
128132
fixer.removeRange([classNameProp.range[1], checkedProp.range[1]]),
129133
fixer.replaceText(matcher, "toHaveClass"),
@@ -182,8 +186,9 @@ export const create = (context) => ({
182186
node: matcher,
183187
messageId,
184188
fix(fixer) {
185-
if (className.name === "classList" && matcher.name !== "toContain")
189+
if (className.name === "classList" && matcher.name !== "toContain") {
186190
return;
191+
}
187192

188193
return [
189194
fixer.removeRange([classNameProp.range[1], className.range[1]]),
@@ -215,8 +220,9 @@ export const create = (context) => ({
215220
if (
216221
(matcher.name === "toHaveAttribute" && classNameValue !== "class") ||
217222
(matcher.name === "toHaveProperty" && classNameValue !== "className")
218-
)
223+
) {
219224
return;
225+
}
220226

221227
const { isDTLQuery } = getQueryNodeFrom(
222228
context,
@@ -255,8 +261,10 @@ export const create = (context) => ({
255261
if (
256262
(matcher.name === "toHaveAttribute" && classNameValue !== "class") ||
257263
(matcher.name === "toHaveProperty" && classNameValue !== "className")
258-
)
264+
) {
259265
return;
266+
}
267+
260268
const { isDTLQuery } = getQueryNodeFrom(
261269
context,
262270
node.callee.object.object.arguments[0]
@@ -295,8 +303,9 @@ export const create = (context) => ({
295303
if (
296304
(matcher.name === "toHaveAttribute" && classNameValue !== "class") ||
297305
(matcher.name === "toHaveProperty" && classNameValue !== "className")
298-
)
306+
) {
299307
return;
308+
}
300309

301310
const { isDTLQuery } = getQueryNodeFrom(
302311
context,

0 commit comments

Comments
 (0)