Skip to content

Commit

Permalink
Update: use eslint flat config
Browse files Browse the repository at this point in the history
.eslintrc.js and .eslintignore are deprecated and the new flat config system is preferred. The CLI also doesn't
support --ext flag with the flat config system.

How the new config is generated:
https://eslint.org/docs/latest/use/configure/migration-guide#migrate-your-config-file
Reference for cli flag changes:
https://eslint.org/docs/latest/use/configure/migration-guide#cli-flag-changes
  • Loading branch information
WilsonZiweiWang committed Sep 10, 2024
1 parent 19a0cc1 commit 1c545dc
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 46 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

43 changes: 0 additions & 43 deletions .eslintrc.js

This file was deleted.

75 changes: 75 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import header from "eslint-plugin-header";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
{
ignores: [
"**/out",
"**/poky",
"**/.vscode-test",
"__mocks__/vscode.ts",
"**/jest.config.js",
"**/eslint.config.mjs",
],
},
...compat.extends(
"standard-with-typescript",
"plugin:deprecation/recommended"
),
{
plugins: {
header,
},

languageOptions: {
globals: {
...globals.browser,
},

ecmaVersion: "latest",
sourceType: "module",
},

rules: {
"header/header": [
2,
"block",
[
" --------------------------------------------------------------------------------------------",
{
pattern: " \\* Copyright \\(c\\) .*\\. All rights reserved\\.",
template:
" * Copyright (c) 2023 Savoir-faire Linux. All rights reserved.",
},
" * Licensed under the MIT License. See License.txt in the project root for license information.",
" * ------------------------------------------------------------------------------------------ ",
],
2,
],
},
},
{
files: ["**/*.ts"],

languageOptions: {
globals: {
...globals.node,
},

ecmaVersion: 5,
sourceType: "commonjs",
},
},
];
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@
"clean:client": "rm -fr ./client/node_modules ./client/out client/tsconfig.tsbuildinfo client/.vscode-test",
"clean:lib": "rm -fr ./lib/node_modules",
"clean": "npm run clean:lib && npm run clean:server && npm run clean:client && rm -fr node_modules integration-tests/out integration-tests/project-folder/build* .vscode-test .eslintcache resources coverage ./out *.vsix",
"lint": "eslint . --ext js,ts --cache",
"lint": "eslint . --cache",
"jest": "jest",
"test": "npm run jest && npm run test:integration && npm run test:grammar",
"test:integration": "xvfb-run node ./integration-tests/out/runTest.js",
Expand Down

0 comments on commit 1c545dc

Please sign in to comment.