Skip to content
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 v9, eslint-config-eslint v10 #604

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ export default [
files: ["tools/**"],
rules: {
"no-console": "off",
"n/no-process-exit": "off",
"n/no-unsupported-features/es-syntax": ["error", {
version: ">=16.0.0",
ignores: ["modules"]
}]
Comment on lines -27 to -30
Copy link
Member Author

@mdjermanovic mdjermanovic Apr 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This override is apparently no longer needed with the latest version of eslint-plugin-n.

"n/no-process-exit": "off"
}
}
];
5 changes: 1 addition & 4 deletions espree.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */

/**
* @fileoverview Main Espree file that converts Acorn into Esprima output.
*
Expand Down Expand Up @@ -57,7 +55,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

/* eslint-enable jsdoc/no-multi-asterisks -- needed to preserve original formatting of licences */

import * as acorn from "acorn";
import jsx from "acorn-jsx";
Expand Down Expand Up @@ -160,7 +157,7 @@ export const Syntax = (function() {
}

for (key in VisitorKeys) {
if (Object.hasOwnProperty.call(VisitorKeys, key)) {
if (Object.hasOwn(VisitorKeys, key)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was reported by prefer-object-has-own.

types[key] = key;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const SUPPORTED_VERSIONS = [
* @returns {number} The latest ECMAScript version.
*/
export function getLatestEcmaVersion() {
return SUPPORTED_VERSIONS[SUPPORTED_VERSIONS.length - 1];
return SUPPORTED_VERSIONS.at(-1);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was reported by unicorn/prefer-at.

}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/token-translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Token = {
*/
function convertTemplatePart(tokens, code) {
const firstToken = tokens[0],
lastTemplateToken = tokens[tokens.length - 1];
lastTemplateToken = tokens.at(-1);

const token = {
type: Token.Template,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"@rollup/plugin-node-resolve": "^11.2.0",
"c8": "^7.11.0",
"chai": "^4.3.6",
"eslint": "^8.44.0",
"eslint-config-eslint": "^9.0.0",
"eslint": "^9.1.1",
"eslint-config-eslint": "^10.0.0",
"eslint-release": "^3.2.0",
"esprima-fb": "^8001.2001.0-dev-harmony-fb",
"globals": "^13.20.0",
"globals": "^15.1.0",
"lint-staged": "^13.2.0",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
Expand All @@ -70,7 +70,7 @@
"build:debug": "npm run build -- -m",
"build:docs": "node tools/sync-docs.js",
"build:update-version": "node tools/update-version.js",
"lint": "eslint . --report-unused-disable-directives",
"lint": "eslint .",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--report-unused-disable-directives CLI flag is no longer needed because it is set to "error" in the config.

"lint:fix": "npm run lint -- --fix",
"prepublishOnly": "npm run build:update-version && npm run build",
"pretest": "npm run build",
Expand Down
2 changes: 1 addition & 1 deletion tools/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ code.forEach((source, index) => {
sourceCode = source.trim();

// add an extra semicolon if there's not already one at the end - helps normalize empty lines at end of input
if (sourceCode[sourceCode.length - 1] !== ";") {
if (sourceCode.at(-1) !== ";") {
sourceCode += ";";
}

Expand Down
3 changes: 1 addition & 2 deletions tools/update-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ const testFiles = getTestFilenames(FIXTURES_DIR),
libraryFiles.forEach(filename => {
const testResultFilename = `${path.resolve(__dirname, "..", LIBRARIES_DIR, filename)}.result.json`,
code = shelljs.cat(path.resolve(LIBRARIES_DIR, filename));
let result = tester.getExpectedResult(code, {
const result = tester.getExpectedResult(code, {
loc: true,
range: true,
tokens: true
});

JSON.stringify(result).to(testResultFilename);
result = null;
});
Comment on lines -73 to 80
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was reported by no-useless-assignment.


// update all tests in ecma-features
Expand Down