Skip to content

Commit

Permalink
feat: support ESLint 8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed Aug 29, 2021
1 parent 05481ae commit ad56d91
Show file tree
Hide file tree
Showing 4 changed files with 676 additions and 295 deletions.
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
"eslint": ">=0.8.0"
},
"devDependencies": {
"@types/eslint": "^7.2.0",
"@types/eslint": "^7.28.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/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",
"eslint-plugin-prettier": "^3.4.1",
"jest": "^26.1.0",
"prettier": "2.0.5",
"typescript": "^3.9.5",
Expand Down
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 ad56d91

Please sign in to comment.