Skip to content

Commit b79ac1d

Browse files
committed
feat: support ESLint 8.x
BREAKING CHANGE: Requires ESLint@^7.0.0 || ^8.0.0
1 parent f0c1e44 commit b79ac1d

File tree

4 files changed

+11
-41
lines changed

4 files changed

+11
-41
lines changed

.travis.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,7 @@ node_js:
1010
before_install:
1111
- npm config set depth 0
1212
before_script: >
13-
node_version=$(node -v);
14-
if [ ${node_version:3:1} = "." ]; then
15-
echo "Node 10+"
16-
if [ ${ESLINT} = "6" ]; then
17-
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}" [email protected]
18-
else
19-
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}"
20-
fi
21-
else
22-
echo "Node 8+"
23-
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}" [email protected] [email protected] [email protected]
24-
fi
13+
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}"
2514
notifications:
2615
email: false
2716
script:
@@ -30,16 +19,13 @@ script:
3019
- npm run build
3120
env:
3221
jobs:
22+
- ESLINT=8
3323
- ESLINT=7
34-
- ESLINT=6
3524
jobs:
3625
fast_finish: true
3726
include:
3827
- node_js: 'lts/*'
3928
env: LINT=true
40-
exclude:
41-
- node_js: 8
42-
env: ESLINT=7
4329
after_success:
4430
- export NODE_ENV=production
4531
- npm run build

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"@babel/preset-env": "^7.15.8",
2727
"@babel/register": "^7.15.3",
2828
"@hkdobrev/run-if-changed": "^0.3.1",
29-
"@typescript-eslint/parser": "^4.33.0",
29+
"@typescript-eslint/parser": "^5.0.0-0",
3030
"babel-plugin-add-module-exports": "^1.0.4",
3131
"babel-plugin-istanbul": "^6.0.0",
3232
"chai": "^4.3.4",
3333
"cross-env": "^7.0.3",
34-
"eslint": "7.32.0",
34+
"eslint": "^8.0.0",
3535
"eslint-config-canonical": "^28.0.0",
3636
"gitdown": "^3.1.4",
3737
"glob": "^7.2.0",
@@ -65,7 +65,7 @@
6565
"main": "./dist/index.js",
6666
"name": "eslint-plugin-jsdoc",
6767
"peerDependencies": {
68-
"eslint": "^6.0.0 || ^7.0.0"
68+
"eslint": "^7.0.0 || ^8.0.0"
6969
},
7070
"repository": {
7171
"type": "git",

src/rules/checkExamples.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// Todo: When peerDeps bump to ESLint 7, see about replacing `CLIEngine`
2-
// with non-deprecated `ESLint` class:
3-
// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated
41
import {
5-
CLIEngine,
2+
ESLint,
63
} from 'eslint';
74
import iterateJsdoc from '../iterateJsdoc';
85

@@ -172,16 +169,16 @@ export default iterateJsdoc(({
172169
if (matchingFileNameMap.has(fileNameMapKey)) {
173170
cliFile = matchingFileNameMap.get(fileNameMapKey);
174171
} else {
175-
const cli = new CLIEngine(cliConfig);
172+
const cli = new ESLint(cliConfig);
176173
let config;
177174
if (filename || checkEslintrc) {
178-
config = cli.getConfigForFile(file);
175+
config = cli.calculateConfigForFile(file);
179176
}
180177

181178
// We need a new instance to ensure that the rules that may only
182179
// be available to `file` (if it has its own `.eslintrc`),
183180
// will be defined.
184-
cliFile = new CLIEngine({
181+
cliFile = new ESLint({
185182
allowInlineConfig,
186183
baseConfig: {
187184
...baseConfig,
@@ -196,8 +193,7 @@ export default iterateJsdoc(({
196193
matchingFileNameMap.set(fileNameMapKey, cliFile);
197194
}
198195

199-
const {results: [{messages}]} =
200-
cliFile.executeOnText(src);
196+
const {results: [{messages}]} = cliFile.lintText(src);
201197

202198
if (!('line' in tag)) {
203199
tag.line = tag.source[0].number;

test/rules/assertions/requireJsdoc.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
* @see https://github.com/eslint/eslint/blob/master/tests/lib/rules/require-jsdoc.js
33
*/
44

5-
import {
6-
CLIEngine,
7-
} from 'eslint';
8-
95
export default {
106
invalid: [
117
{
@@ -3016,15 +3012,7 @@ function quux (foo) {
30163012
},
30173013
],
30183014
options: [{
3019-
contexts: [
3020-
// Only fixed to support `:has()` with TS later in ESLint 7, but
3021-
// for our testing of ESLint 6, we use `>` which is equivalent in
3022-
// this case; after having peerDeps. to ESLint 7+, we can remove
3023-
// this check and use of `CLIEngine`
3024-
CLIEngine.version.startsWith('6') ?
3025-
'ClassProperty > Decorator[expression.callee.name="Input"]' :
3026-
'ClassProperty:has(Decorator[expression.callee.name="Input"])',
3027-
],
3015+
contexts: ['ClassProperty > Decorator[expression.callee.name="Input"]'],
30283016
}],
30293017
output: `
30303018
export class MyComponentComponent {

0 commit comments

Comments
 (0)