Skip to content

Commit bd3540a

Browse files
committed
feat: support ESLint 8.x
1 parent 3b7031e commit bd3540a

File tree

6 files changed

+78
-22
lines changed

6 files changed

+78
-22
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/validate.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: validate
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
jobs:
8+
main:
9+
strategy:
10+
matrix:
11+
eslint: [5, 6, 7, 8]
12+
node: [6.14, 6, 8, 10, 12, 14, 16]
13+
exclude:
14+
- eslint: 8
15+
node: 10
16+
- eslint: 8
17+
node: 8
18+
- eslint: 8
19+
node: 6
20+
- eslint: 8
21+
node: 6.14
22+
- eslint: 7
23+
node: 8
24+
- eslint: 7
25+
node: 6
26+
- eslint: 7
27+
node: 6.14
28+
- eslint: 6
29+
node: 6
30+
- eslint: 6
31+
node: 6.14
32+
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: 🛑 Cancel Previous Runs
36+
uses: styfle/[email protected]
37+
38+
- name: ⬇️ Checkout repo
39+
uses: actions/checkout@v2
40+
41+
- name: ⎔ Setup node
42+
uses: actions/setup-node@v2
43+
with:
44+
node-version: ${{ matrix.node }}
45+
46+
- name: 📥 Download deps
47+
uses: bahmutov/npm-install@v1
48+
with:
49+
useLockFile: false
50+
51+
- name: 📥 Install ESLint
52+
run: npm install eslint@${{ matrix.eslint }}
53+
54+
- name: ▶️ Run tests
55+
run: npm run test

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
node_modules/
1+
node_modules
2+
.DS_Store
3+
4+
# these cause more harm than good
5+
# when working with contributors
6+
package-lock.json
7+
yarn.lock

.travis.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
"bugs": {
1111
"url": "https://github.com/standard/eslint-config-standard-jsx/issues"
1212
},
13-
"devDependencies": {
14-
"eslint": "^7.12.1",
15-
"eslint-plugin-react": "^7.21.5",
16-
"tape": "^5.0.1"
17-
},
1813
"homepage": "https://github.com/standard/eslint-config-standard-jsx",
1914
"keywords": [
2015
"JavaScript Standard Style",
@@ -45,8 +40,14 @@
4540
],
4641
"license": "MIT",
4742
"main": "index.js",
43+
"dependencies": {},
44+
"devDependencies": {
45+
"eslint": "^8.0.0",
46+
"eslint-plugin-react": "^7.26.1",
47+
"tape": "^5.0.1"
48+
},
4849
"peerDependencies": {
49-
"eslint": "^7.12.1",
50+
"eslint": "^7.12.1 || ^8.0.0",
5051
"eslint-plugin-react": "^7.21.5"
5152
},
5253
"repository": {

test/validate-config.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
const eslint = require('eslint')
1+
const { ESLint } = require('eslint')
22
const test = require('tape')
33

44
test('load config in eslint to validate all rule syntax is correct', function (t) {
5-
const CLIEngine = eslint.CLIEngine
6-
7-
const cli = new CLIEngine({
5+
const cli = new ESLint({
86
useEslintrc: false,
9-
configFile: 'eslintrc.json'
7+
overrideConfigFile: 'eslintrc.json'
108
})
119

1210
const code = 'var foo = 1\nvar bar = function () {}\nbar(foo)\n'
1311

14-
t.equal(cli.executeOnText(code).errorCount, 0)
12+
t.equal(cli.lintText(code).errorCount, 0)
1513
t.end()
1614
})
1715

1816
test('space before an opening tag\'s closing bracket should not be allowed', t => {
19-
const CLIEngine = eslint.CLIEngine
20-
21-
const cli = new CLIEngine({
17+
const cli = new ESLint({
2218
useEslintrc: false,
23-
configFile: 'eslintrc.json'
19+
overrideConfigFile: 'eslintrc.json'
2420
})
2521

2622
const shouldPass = {
@@ -59,12 +55,12 @@ test('space before an opening tag\'s closing bracket should not be allowed', t =
5955
t.plan(testPlansCount)
6056

6157
for (const testCase in shouldPass) {
62-
const { errorCount } = cli.executeOnText(shouldPass[testCase])
58+
const { errorCount } = cli.lintText(shouldPass[testCase])
6359
t.equal(errorCount, 0)
6460
}
6561

6662
for (const testCase in shouldFail) {
67-
const { errorCount } = cli.executeOnText(shouldFail[testCase])
63+
const { errorCount } = cli.lintText(shouldFail[testCase])
6864
t.true(errorCount > 0)
6965
}
7066
})

0 commit comments

Comments
 (0)