Skip to content

Commit db40daa

Browse files
authored
Merge pull request #203 from matthieu-crouzet/chore/o3r-eslint
chore: set up o3r eslint recommendations
2 parents 62798bb + 82640da commit db40daa

File tree

156 files changed

+54137
-44933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+54137
-44933
lines changed

.github/workflows/vscode-extension-secure-ci.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
fail-fast: false
152152
matrix:
153153
os: [ubuntu-latest]
154-
node-version: [20]
154+
node-version: [24]
155155

156156
steps:
157157
- name: Harden Runner
@@ -171,17 +171,14 @@ jobs:
171171
cache: "npm"
172172
cache-dependency-path: "package-lock.json"
173173

174-
- name: Build lib package
175-
working-directory: lib
176-
run: |
177-
npm ci --fund=false
178-
npm run build
179-
180174
- name: Install dependencies
181175
run: npm ci --fund=false
182176

177+
- name: Build lib package
178+
run: npm run compile-lib
179+
183180
- name: Run linting
184-
run: npm run lint
181+
run: npm run lint -- --quiet
185182

186183
- name: Run type checking
187184
run: npm run compile

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ yarn-error.log
1616
!.vscode/launch.json
1717
!.vscode/tasks.json
1818
!.vscode/extensions.json
19+
!.vscode/settings.json
1920
!.vscode/README.md
2021
*.swp
2122
*.swo

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint"
4+
]
5+
}

.vscode/settings.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"eslint.codeActionsOnSave.mode": "all",
3+
"eslint.format.enable": true,
4+
"eslint.probe": [
5+
"javascript",
6+
"typescript",
7+
"typescriptreact",
8+
"html",
9+
"markdown",
10+
"json",
11+
"yaml"
12+
],
13+
"eslint.rules.customizations": [
14+
{
15+
"fixable": true,
16+
"rule": "@stylistic/*",
17+
"severity": "off"
18+
},
19+
{
20+
"fixable": true,
21+
"rule": "!@stylistic/*",
22+
"severity": "info"
23+
}
24+
],
25+
"eslint.useFlatConfig": true,
26+
"eslint.validate": [
27+
"html",
28+
"javascript",
29+
"typescript",
30+
"json",
31+
"yaml"
32+
]
33+
}

eslint.config.mjs

Lines changed: 133 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,146 @@
1-
import eslint from "@eslint/js";
2-
import tseslint from "typescript-eslint";
3-
import eslintConfigPrettier from "eslint-config-prettier";
1+
import o3rConfig from '@o3r/eslint-config';
2+
import {
3+
defineConfig,
4+
globalIgnores,
5+
} from 'eslint/config';
6+
import globals from 'globals';
7+
import jsonParser from 'jsonc-eslint-parser';
48

5-
export default tseslint.config(
9+
export default defineConfig([
10+
globalIgnores(
11+
['out/', 'test-out/', 'dist/', 'test-dist/', '**/*.d.ts', 'node_modules/', 'lib/'],
12+
'prompt-registry/ignores'
13+
),
14+
...o3rConfig,
615
{
7-
ignores: ["out/", "test-out/", "dist/", "test-dist/", "**/*.d.ts", "node_modules/", "lib/"],
16+
name: 'prompt-registry/report-unused-disable-directives',
17+
linterOptions: {
18+
reportUnusedDisableDirectives: 'error'
19+
}
820
},
9-
eslint.configs.recommended,
10-
eslintConfigPrettier,
1121
{
12-
files: ["src/**/*.ts"],
13-
plugins: {
14-
"@typescript-eslint": tseslint.plugin,
15-
},
22+
name: 'prompt-registry/typescript-type-checking',
23+
files: ['**/*.ts'],
24+
languageOptions: {
25+
parserOptions: {
26+
projectService: true,
27+
tsconfigRootDir: import.meta.dirname
28+
}
29+
}
30+
},
31+
{
32+
name: 'prompt-registry/node-globals',
33+
files: ['src/**/*.ts'],
1634
languageOptions: {
17-
parser: tseslint.parser,
18-
ecmaVersion: 2020,
19-
sourceType: "module",
2035
globals: {
21-
Buffer: "readonly",
22-
NodeJS: "readonly",
23-
console: "readonly",
24-
process: "readonly",
25-
setTimeout: "readonly",
26-
clearTimeout: "readonly",
27-
setInterval: "readonly",
28-
clearInterval: "readonly",
29-
URL: "readonly",
30-
__dirname: "readonly",
31-
__filename: "readonly",
32-
require: "readonly",
33-
module: "readonly",
34-
exports: "readonly",
35-
},
36-
},
36+
...globals.node,
37+
NodeJS: true
38+
}
39+
}
40+
},
41+
{
42+
name: 'prompt-registry/overrides',
43+
files: ['**/*.ts'],
44+
rules: {
45+
'@typescript-eslint/restrict-template-expressions': ['error', {
46+
allow: ['unknown']
47+
}]
48+
}
49+
},
50+
{
51+
// TODO to be discussed and fixed in a future PRs
52+
name: 'prompt-registry/temporary-warn-rules-ts',
53+
files: ['**/*.ts'],
3754
rules: {
38-
"no-unused-vars": "off",
39-
"@typescript-eslint/naming-convention": [
40-
"warn",
41-
{
42-
selector: "import",
43-
format: ["camelCase", "PascalCase"],
44-
},
45-
],
46-
curly: "warn",
47-
eqeqeq: "warn",
48-
"no-throw-literal": "warn",
49-
semi: "off",
50-
},
55+
'@typescript-eslint/explicit-member-accessibility': 'warn',
56+
'@typescript-eslint/member-ordering': 'warn',
57+
'@typescript-eslint/no-unsafe-member-access': 'warn',
58+
'@typescript-eslint/no-unsafe-argument': 'warn',
59+
'@typescript-eslint/no-unsafe-call': 'warn',
60+
'@typescript-eslint/no-unsafe-return': 'warn',
61+
'@typescript-eslint/no-unsafe-assignment': 'warn',
62+
'@typescript-eslint/naming-convention': 'warn',
63+
'@typescript-eslint/require-await': 'warn',
64+
'@typescript-eslint/no-floating-promises': 'warn',
65+
'@typescript-eslint/no-unused-vars': 'warn',
66+
'@typescript-eslint/no-require-imports': 'warn',
67+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
68+
'@typescript-eslint/restrict-template-expressions': 'warn',
69+
'@typescript-eslint/no-shadow': 'warn',
70+
'@typescript-eslint/prefer-promise-reject-errors': 'warn'
71+
}
5172
},
5273
{
53-
files: ["src/ui/webview/**/*.js"],
74+
// TODO to be discussed and fixed in a future PRs
75+
name: 'prompt-registry/temporary-warn-rules',
76+
files: ['**/*.{j,t}s'],
77+
rules: {
78+
'unicorn/filename-case': 'warn',
79+
'unicorn/no-array-sort': 'warn',
80+
'unicorn/no-useless-switch-case': 'warn',
81+
'unicorn/prefer-single-call': 'warn',
82+
'unicorn/prefer-query-selector': 'warn',
83+
'unicorn/prefer-default-parameters': 'warn',
84+
'unicorn/prefer-number-properties': 'warn',
85+
'unicorn/prefer-ternary': 'warn',
86+
'unicorn/text-encoding-identifier-case': 'warn',
87+
'unicorn/explicit-length-check': 'warn',
88+
'unicorn/no-immediate-mutation': 'warn',
89+
'prefer-arrow/prefer-arrow-functions': 'warn',
90+
'jsdoc/check-tag-names': 'warn',
91+
'jsdoc/require-description': 'warn',
92+
'jsdoc/require-param-type': 'warn',
93+
'jsdoc/reject-any-type': 'warn',
94+
'jsdoc/escape-inline-tags': 'warn',
95+
'jsdoc/check-alignment': 'warn',
96+
'jsdoc/require-throws-type': 'warn',
97+
'no-underscore-dangle': 'warn',
98+
'no-console': 'warn',
99+
'no-undef': 'warn',
100+
'no-loop-func': 'warn',
101+
'no-bitwise': 'warn',
102+
'new-cap': 'warn',
103+
'prefer-const': 'warn',
104+
'import/no-cycle': 'warn',
105+
'import/order': 'warn',
106+
'import-newlines/enforce': 'warn',
107+
'@stylistic/max-statements-per-line': 'warn',
108+
'@stylistic/indent-binary-ops': 'warn',
109+
'@stylistic/comma-dangle': 'warn',
110+
'@stylistic/brace-style': 'warn',
111+
'@stylistic/max-len': 'warn',
112+
'@stylistic/semi': 'warn',
113+
'@stylistic/indent': 'warn',
114+
'@eslint-community/eslint-comments/require-description': 'warn'
115+
}
116+
},
117+
{
118+
name: 'prompt-registry/parser/json',
119+
files: ['**/*.json'],
120+
languageOptions: {
121+
parser: jsonParser
122+
}
123+
},
124+
{
125+
name: 'prompt-registry/settings',
126+
settings: {
127+
'import/resolver': {
128+
node: true,
129+
typescript: {
130+
projectService: true
131+
}
132+
}
133+
}
134+
},
135+
{
136+
name: 'prompt-registry/webview-js',
137+
files: ['src/ui/webview/**/*.js'],
54138
languageOptions: {
55139
ecmaVersion: 2020,
56-
sourceType: "module",
140+
sourceType: 'module',
57141
globals: {
58-
document: "readonly",
59-
window: "readonly",
60-
console: "readonly",
61-
acquireVsCodeApi: "readonly",
62-
setTimeout: "readonly",
63-
clearTimeout: "readonly",
64-
MutationObserver: "readonly",
65-
HTMLElement: "readonly",
66-
},
67-
},
68-
rules: {
69-
"no-unused-vars": "off",
70-
curly: "warn",
71-
eqeqeq: "warn",
72-
semi: "off",
73-
},
142+
...globals.browser
143+
}
144+
}
74145
}
75-
);
146+
]);

0 commit comments

Comments
 (0)