Skip to content

Commit

Permalink
feat: support ESLint 8.x
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires ESLint@^7.0.0 || ^8.0.0
  • Loading branch information
MichaelDeBoey committed Oct 10, 2021
1 parent f0c1e44 commit b79ac1d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 41 deletions.
18 changes: 2 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,7 @@ node_js:
before_install:
- npm config set depth 0
before_script: >
node_version=$(node -v);
if [ ${node_version:3:1} = "." ]; then
echo "Node 10+"
if [ ${ESLINT} = "6" ]; then
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}" [email protected]
else
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}"
fi
else
echo "Node 8+"
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}" [email protected] [email protected] [email protected]
fi
npm install --legacy-peer-deps --no-save "eslint@${ESLINT}"
notifications:
email: false
script:
Expand All @@ -30,16 +19,13 @@ script:
- npm run build
env:
jobs:
- ESLINT=8
- ESLINT=7
- ESLINT=6
jobs:
fast_finish: true
include:
- node_js: 'lts/*'
env: LINT=true
exclude:
- node_js: 8
env: ESLINT=7
after_success:
- export NODE_ENV=production
- npm run build
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"@babel/preset-env": "^7.15.8",
"@babel/register": "^7.15.3",
"@hkdobrev/run-if-changed": "^0.3.1",
"@typescript-eslint/parser": "^4.33.0",
"@typescript-eslint/parser": "^5.0.0-0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^6.0.0",
"chai": "^4.3.4",
"cross-env": "^7.0.3",
"eslint": "7.32.0",
"eslint": "^8.0.0",
"eslint-config-canonical": "^28.0.0",
"gitdown": "^3.1.4",
"glob": "^7.2.0",
Expand Down Expand Up @@ -65,7 +65,7 @@
"main": "./dist/index.js",
"name": "eslint-plugin-jsdoc",
"peerDependencies": {
"eslint": "^6.0.0 || ^7.0.0"
"eslint": "^7.0.0 || ^8.0.0"
},
"repository": {
"type": "git",
Expand Down
14 changes: 5 additions & 9 deletions src/rules/checkExamples.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Todo: When peerDeps bump to ESLint 7, see about replacing `CLIEngine`
// with non-deprecated `ESLint` class:
// https://github.com/eslint/eslint/blob/master/docs/user-guide/migrating-to-7.0.0.md#-the-cliengine-class-has-been-deprecated
import {
CLIEngine,
ESLint,
} from 'eslint';
import iterateJsdoc from '../iterateJsdoc';

Expand Down Expand Up @@ -172,16 +169,16 @@ export default iterateJsdoc(({
if (matchingFileNameMap.has(fileNameMapKey)) {
cliFile = matchingFileNameMap.get(fileNameMapKey);
} else {
const cli = new CLIEngine(cliConfig);
const cli = new ESLint(cliConfig);
let config;
if (filename || checkEslintrc) {
config = cli.getConfigForFile(file);
config = cli.calculateConfigForFile(file);
}

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

const {results: [{messages}]} =
cliFile.executeOnText(src);
const {results: [{messages}]} = cliFile.lintText(src);

if (!('line' in tag)) {
tag.line = tag.source[0].number;
Expand Down
14 changes: 1 addition & 13 deletions test/rules/assertions/requireJsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
* @see https://github.com/eslint/eslint/blob/master/tests/lib/rules/require-jsdoc.js
*/

import {
CLIEngine,
} from 'eslint';

export default {
invalid: [
{
Expand Down Expand Up @@ -3016,15 +3012,7 @@ function quux (foo) {
},
],
options: [{
contexts: [
// Only fixed to support `:has()` with TS later in ESLint 7, but
// for our testing of ESLint 6, we use `>` which is equivalent in
// this case; after having peerDeps. to ESLint 7+, we can remove
// this check and use of `CLIEngine`
CLIEngine.version.startsWith('6') ?
'ClassProperty > Decorator[expression.callee.name="Input"]' :
'ClassProperty:has(Decorator[expression.callee.name="Input"])',
],
contexts: ['ClassProperty > Decorator[expression.callee.name="Input"]'],
}],
output: `
export class MyComponentComponent {
Expand Down

0 comments on commit b79ac1d

Please sign in to comment.