-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: switch to eslint flat config #577
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ dist | |
npm-debug.log | ||
_test.js | ||
.idea | ||
.vscode | ||
.nyc_output | ||
.eslint-release-info.json | ||
yarn.lock | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import eslintConfigESLint from "eslint-config-eslint"; | ||
import nodeRecommendedModule from "eslint-plugin-n/configs/recommended-module.js"; | ||
import nodeRecommendedScript from "eslint-plugin-n/configs/recommended-script.js"; | ||
import globals from "globals"; | ||
|
||
export default [ | ||
{ | ||
ignores: [ | ||
"tests/fixtures/", | ||
"dist/", | ||
"coverage/", | ||
"tools/create-test-example.js" | ||
] | ||
}, | ||
|
||
// eslintConfigESLint[3] is eslint-plugin-n's recommended-script config | ||
...eslintConfigESLint.slice(0, 3), | ||
{ | ||
files: ["**/*.js"], | ||
...nodeRecommendedModule | ||
}, | ||
{ | ||
files: ["**/*.cjs"], | ||
...nodeRecommendedScript | ||
}, | ||
...eslintConfigESLint.slice(4), | ||
|
||
{ | ||
settings: { | ||
jsdoc: { | ||
mode: "typescript" | ||
} | ||
} | ||
}, | ||
{ | ||
files: ["tests/lib/**"], | ||
languageOptions: { | ||
globals: { | ||
...globals.mocha | ||
} | ||
} | ||
}, | ||
{ | ||
files: ["tools/**"], | ||
rules: { | ||
"no-console": "off", | ||
"n/no-process-exit": "off", | ||
"n/no-unsupported-features/es-syntax": ["error", { | ||
version: ">=16.0.0", | ||
ignores: ["modules"] | ||
}] | ||
} | ||
} | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
/* eslint-disable no-param-reassign*/ | ||
/* eslint no-param-reassign: 0 -- stylistic choice */ | ||
|
||
import TokenTranslator from "./token-translator.js"; | ||
import { normalizeOptions } from "./options.js"; | ||
|
||
|
@@ -109,7 +110,7 @@ export default () => Parser => { | |
allowReturnOutsideFunction: options.allowReturnOutsideFunction, | ||
|
||
// Collect tokens | ||
onToken: token => { | ||
onToken(token) { | ||
Comment on lines
-112
to
+113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is because in the new |
||
if (tokenTranslator) { | ||
|
||
// Use `tokens`, `ecmaVersion`, and `jsxAttrValueToken` in the state. | ||
|
@@ -121,7 +122,7 @@ export default () => Parser => { | |
}, | ||
|
||
// Collect comments | ||
onComment: (block, text, start, end, startLoc, endLoc) => { | ||
onComment(block, text, start, end, startLoc, endLoc) { | ||
if (state.comments) { | ||
const comment = convertAcornCommentToEsprimaComment(block, text, start, end, startLoc, endLoc, code); | ||
|
||
|
@@ -314,7 +315,7 @@ export default () => Parser => { | |
* on extra so that when tokens are converted, the next token will be switched | ||
* to JSXText via onToken. | ||
*/ | ||
jsx_readString(quote) { // eslint-disable-line camelcase | ||
jsx_readString(quote) { // eslint-disable-line camelcase -- required by API | ||
const result = super.jsx_readString(quote); | ||
|
||
if (this.type === tokTypes.string) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
* @fileoverview Translates tokens between Acorn format and Esprima format. | ||
* @author Nicholas C. Zakas | ||
*/ | ||
/* eslint no-underscore-dangle: 0 */ | ||
|
||
//------------------------------------------------------------------------------ | ||
// Requirements | ||
|
@@ -180,8 +179,7 @@ TokenTranslator.prototype = { | |
*/ | ||
onToken(token, extra) { | ||
|
||
const that = this, | ||
tt = this._acornTokTypes, | ||
const tt = this._acornTokTypes, | ||
tokens = extra.tokens, | ||
templateTokens = this._tokens; | ||
|
||
|
@@ -191,10 +189,10 @@ TokenTranslator.prototype = { | |
* @returns {void} | ||
* @private | ||
*/ | ||
function translateTemplateTokens() { | ||
tokens.push(convertTemplatePart(that._tokens, that._code)); | ||
that._tokens = []; | ||
} | ||
const translateTemplateTokens = () => { | ||
tokens.push(convertTemplatePart(this._tokens, this._code)); | ||
this._tokens = []; | ||
}; | ||
Comment on lines
-194
to
+195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small refactor to avoid disabling |
||
|
||
if (token.type === tt.eof) { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
/** | ||
* @fileoverview Generate `<test-name>.result.js` from `<test-name>.src.js` in | ||
* `tests/fixtures/ecma-version/<number>/**` directory. | ||
* @author Nicholas C. Zakas | ||
* @author Toru Nagashima | ||
* | ||
* Usage: | ||
* node tools/update-ecma-version-tests.js <number> | ||
* | ||
* @author Nicholas C. Zakas | ||
* @author Toru Nagashima | ||
*/ | ||
Comment on lines
1
to
10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some eslint-plugin-jsdoc rules were reporting errors in the structure, so I moved the usage description under the file overview. |
||
|
||
//------------------------------------------------------------------------------ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a PR to move it to
eslint-config-eslint
.eslint/eslint#17338
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
We'll remove it from here when we release eslint-config-eslint v9.