Skip to content

Commit 66b1302

Browse files
author
Oleksandr Dzhychko
committed
build: update to ESLint 9
With the update to v9, ESLint did not support reading configuration in subdirectories. We relied on this feature when running ESLint with pre-commit. Therefore, the configuration was unified at the top-level of the repository. This resulted in a cleanup of linting related build code in the `ts-model-api` and `vue-model-api` directories. The unification makes maintenance easier anyway. The official ESLint hook is not used anymore because of the issue described in eslint/eslint#18465 The local hook works around that issue. It also does not require duplicating versions of NPM packages. But it requires installing NPM dependencies before running pre-commit hooks.
1 parent b33ceba commit 66b1302

File tree

12 files changed

+1785
-2611
lines changed

12 files changed

+1785
-2611
lines changed

.github/workflows/linting.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: 20
14+
- uses: actions/cache@v4
15+
with:
16+
path: node_modules
17+
key: release-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
18+
- name: Install dependencies
19+
run: npm ci
1120
- uses: actions/setup-python@v5
1221
- uses: pre-commit/[email protected]
1322

.pre-commit-config.yaml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@ repos:
3737
hooks:
3838
- id: prettier
3939
files: ^(vue-model-api)|(model-api-gen-gradle-test/vue-integration)|(model-client-js-test/model-client-connection)/
40-
- repo: https://github.com/pre-commit/mirrors-eslint
41-
# IMPORTANT: keep versions of hook and additional dependencies in sync with the versions configured in `vue-model-api/package.json`
42-
rev: v8.56.0
40+
- repo: "local"
4341
hooks:
4442
- id: eslint
45-
additional_dependencies:
46-
47-
48-
- "@typescript-eslint/[email protected]"
49-
- "@typescript-eslint/[email protected]"
50-
files: ^(vue-model-api)|(ts-model-api)/src/
51-
types: [ts]
43+
name: ESLint
44+
language: node
45+
entry: npm
46+
args: [ "run", "lint" ]
47+
types: [ file ]

eslint.config.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import globals from "globals";
2+
import pluginJs from "@eslint/js";
3+
import tseslint from "typescript-eslint";
4+
import eslintConfigPrettier from "eslint-config-prettier";
5+
6+
export default [
7+
{ files: ["**/*.{js,mjs,cjs,ts}"] },
8+
{ ignores: ["**/.gradle", "**/dist/", "**/build/"] },
9+
{
10+
languageOptions: {
11+
ecmaVersion: "latest",
12+
sourceType: "module",
13+
globals: {
14+
...globals.browser,
15+
...globals.node,
16+
...globals.es2021
17+
},
18+
},
19+
},
20+
pluginJs.configs.recommended,
21+
...tseslint.configs.recommended,
22+
eslintConfigPrettier, // > Turns off all rules that are unnecessary or might conflict with Prettier.
23+
{
24+
// The Redocly plugin uses CommonJS syntax for imports and exports as in the Redocly documentation.
25+
files: ["model-server-openapi/**/*"],
26+
rules: {
27+
"@typescript-eslint/no-require-imports": "off"
28+
}
29+
},
30+
{
31+
rules: {
32+
"@typescript-eslint/consistent-type-imports": "error",
33+
"@typescript-eslint/no-import-type-side-effects": "error",
34+
"@typescript-eslint/no-unused-vars": [
35+
"error",
36+
{
37+
vars: "all",
38+
args: "after-used",
39+
varsIgnorePattern: "^_.+",
40+
argsIgnorePattern: "^_.+",
41+
},
42+
],
43+
"@typescript-eslint/ban-ts-comment": [
44+
"error",
45+
{ "ts-ignore": "allow-with-description" },
46+
],
47+
},
48+
},
49+
];

0 commit comments

Comments
 (0)