Skip to content

Commit

Permalink
feat: support ESLint 8.x
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Requires Node@^12.22.0 || ^14.17.0 || >=16.0.0
  • Loading branch information
MichaelDeBoey committed Aug 29, 2021
1 parent 05481ae commit 61027e9
Show file tree
Hide file tree
Showing 5 changed files with 1,572 additions and 1,983 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10
- image: circleci/node:12

jobs:
test:
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@
"eslint": ">=0.8.0"
},
"devDependencies": {
"@types/eslint": "^7.2.0",
"@types/jest": "^26.0.0",
"@types/node": "^14.0.13",
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"eslint": "^7.3.1",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-import-resolver-typescript": "^2.0.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-jest": "^23.17.1",
"@types/eslint": "^7.28.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.5",
"@typescript-eslint/eslint-plugin": "^5.0.0-0",
"@typescript-eslint/parser": "^5.0.0-0",
"eslint": "^8.0.0-0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-jest-formatting": "file:.",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.1.0",
"prettier": "2.0.5",
"typescript": "^3.9.5",
"ts-jest": "^26.1.1"
"eslint-plugin-prettier": "^3.4.1",
"jest": "^27.1.0",
"prettier": "2.3.2",
"typescript": "^4.4.2",
"ts-jest": "^27.0.5"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"license": "MIT"
}
4 changes: 3 additions & 1 deletion src/ast-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ export const getPaddingLineSequences = (

if (nextNode.loc.start.line - prevToken.loc.end.line >= 2) {
do {
const token = sourceCode.getTokenAfter(prevToken, { includeComments });
const token = sourceCode.getTokenAfter(prevToken, {
includeComments,
}) as AST.Token;

if (token.loc.start.line - prevToken.loc.end.line >= 2) {
pairs.push([prevToken, token]);
Expand Down
57 changes: 28 additions & 29 deletions src/rules/padding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,35 +143,34 @@ const paddingAlwaysTester = (
message: 'Expected blank line before this statement.',
fix(fixer: Rule.RuleFixer): Rule.Fix {
let prevToken = astUtils.getActualLastToken(sourceCode, prevNode);
const nextToken =
sourceCode.getFirstTokenBetween(prevToken, nextNode, {
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*/
filter(token: AST.Token): boolean {
if (astUtils.areTokensOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}

return true;
},
}) || nextNode;
const nextToken = (sourceCode.getFirstTokenBetween(prevToken, nextNode, {
includeComments: true,
/**
* Skip the trailing comments of the previous node.
* This inserts a blank line after the last trailing comment.
*
* For example:
*
* foo(); // trailing comment.
* // comment.
* bar();
*
* Get fixed to:
*
* foo(); // trailing comment.
*
* // comment.
* bar();
*/
filter(token: AST.Token): boolean {
if (astUtils.areTokensOnSameLine(prevToken, token)) {
prevToken = token;
return false;
}

return true;
},
}) || nextNode) as AST.Token;

const insertText = astUtils.areTokensOnSameLine(prevToken, nextToken)
? '\n\n'
Expand Down
Loading

0 comments on commit 61027e9

Please sign in to comment.