Skip to content

Commit 0425e5f

Browse files
authored
Merge pull request #209 from matthieu-crouzet/chore/fix-eslint-errors
fix: resolve all ESLint errors and set up lib-specific config
2 parents db40daa + 9e143a8 commit 0425e5f

File tree

190 files changed

+66607
-65223
lines changed

Some content is hidden

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

190 files changed

+66607
-65223
lines changed

eslint.config.mjs

Lines changed: 33 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,61 @@
1-
import o3rConfig from '@o3r/eslint-config';
21
import {
32
defineConfig,
43
globalIgnores,
54
} from 'eslint/config';
65
import globals from 'globals';
76
import jsonParser from 'jsonc-eslint-parser';
7+
import {
8+
createSharedConfig,
9+
temporaryWarnRules,
10+
temporaryWarnRulesTs,
11+
} from './eslint.shared.mjs';
812

913
export default defineConfig([
1014
globalIgnores(
11-
['out/', 'test-out/', 'dist/', 'test-dist/', '**/*.d.ts', 'node_modules/', 'lib/'],
15+
[
16+
'out/',
17+
'test-out/',
18+
'dist/',
19+
'test-dist/',
20+
'**/*.d.ts',
21+
'node_modules/',
22+
'test/**/*.js',
23+
'lib/'
24+
],
1225
'prompt-registry/ignores'
1326
),
14-
...o3rConfig,
15-
{
16-
name: 'prompt-registry/report-unused-disable-directives',
17-
linterOptions: {
18-
reportUnusedDisableDirectives: 'error'
19-
}
20-
},
27+
...createSharedConfig({
28+
name: 'prompt-registry',
29+
tsProjects: ['tsconfig.json', 'tsconfig.test.json'],
30+
tsconfigRootDir: import.meta.dirname,
31+
nodeGlobFiles: ['src/**/*.ts']
32+
}),
2133
{
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'],
34-
languageOptions: {
35-
globals: {
36-
...globals.node,
37-
NodeJS: true
38-
}
39-
}
40-
},
41-
{
42-
name: 'prompt-registry/overrides',
34+
// TODO to be discussed and fixed in a future PRs
35+
name: 'prompt-registry/temporary-warn-rules-ts',
4336
files: ['**/*.ts'],
4437
rules: {
45-
'@typescript-eslint/restrict-template-expressions': ['error', {
46-
allow: ['unknown']
47-
}]
38+
...temporaryWarnRulesTs
4839
}
4940
},
5041
{
51-
// TODO to be discussed and fixed in a future PRs
52-
name: 'prompt-registry/temporary-warn-rules-ts',
53-
files: ['**/*.ts'],
42+
name: 'prompt-registry/test-ts-rules',
43+
files: ['test/**/*.ts'],
5444
rules: {
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'
45+
'@typescript-eslint/no-unsafe-member-access': 'off',
46+
'@typescript-eslint/no-unsafe-argument': 'off',
47+
'@typescript-eslint/no-unsafe-call': 'off',
48+
'@typescript-eslint/no-unsafe-return': 'off',
49+
'@typescript-eslint/no-unsafe-assignment': 'off',
50+
'@typescript-eslint/no-require-imports': 'off'
7151
}
7252
},
7353
{
7454
// TODO to be discussed and fixed in a future PRs
7555
name: 'prompt-registry/temporary-warn-rules',
7656
files: ['**/*.{j,t}s'],
7757
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'
58+
...temporaryWarnRules
11559
}
11660
},
11761
{
@@ -121,17 +65,6 @@ export default defineConfig([
12165
parser: jsonParser
12266
}
12367
},
124-
{
125-
name: 'prompt-registry/settings',
126-
settings: {
127-
'import/resolver': {
128-
node: true,
129-
typescript: {
130-
projectService: true
131-
}
132-
}
133-
}
134-
},
13568
{
13669
name: 'prompt-registry/webview-js',
13770
files: ['src/ui/webview/**/*.js'],

eslint.shared.mjs

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import o3rConfig from '@o3r/eslint-config';
2+
import globals from 'globals';
3+
4+
/**
5+
* Shared ESLint configuration blocks used by both root and lib packages.
6+
* @param {object} options
7+
* @param {string} options.name - Config name prefix (e.g. 'prompt-registry' or 'collection-scripts')
8+
* @param {string[]} options.tsProjects - tsconfig files for type-checked linting
9+
* @param {string} options.tsconfigRootDir - Root directory for tsconfig resolution (use import.meta.dirname)
10+
* @param {string[]} [options.nodeGlobFiles] - File patterns for node globals (default: ['**\/*.ts'])
11+
*/
12+
export function createSharedConfig({ name, tsProjects, tsconfigRootDir, nodeGlobFiles = ['**/*.ts'] }) {
13+
return [
14+
...o3rConfig,
15+
{
16+
name: `${name}/report-unused-disable-directives`,
17+
linterOptions: {
18+
reportUnusedDisableDirectives: 'error'
19+
}
20+
},
21+
{
22+
name: `${name}/typescript-type-checking`,
23+
files: ['**/*.ts'],
24+
languageOptions: {
25+
parserOptions: {
26+
project: tsProjects,
27+
tsconfigRootDir
28+
}
29+
}
30+
},
31+
{
32+
name: `${name}/node-globals`,
33+
files: nodeGlobFiles,
34+
languageOptions: {
35+
globals: {
36+
...globals.node,
37+
NodeJS: true
38+
}
39+
}
40+
},
41+
{
42+
name: `${name}/overrides`,
43+
files: ['**/*.ts'],
44+
rules: {
45+
'@typescript-eslint/restrict-template-expressions': ['error', {
46+
allow: ['unknown']
47+
}]
48+
}
49+
},
50+
{
51+
name: `${name}/settings`,
52+
settings: {
53+
'import/resolver': {
54+
node: true,
55+
typescript: {
56+
project: tsProjects
57+
}
58+
}
59+
}
60+
}
61+
];
62+
}
63+
64+
// TODO to be discussed and fixed in future PRs
65+
export const temporaryWarnRulesTs = {
66+
'@typescript-eslint/no-unsafe-member-access': 'warn',
67+
'@typescript-eslint/no-unsafe-argument': 'warn',
68+
'@typescript-eslint/no-unsafe-call': 'warn',
69+
'@typescript-eslint/no-unsafe-return': 'warn',
70+
'@typescript-eslint/no-unsafe-assignment': 'warn',
71+
'@typescript-eslint/no-require-imports': 'warn',
72+
'@typescript-eslint/no-unused-vars': 'warn',
73+
'@typescript-eslint/restrict-template-expressions': 'warn',
74+
'@typescript-eslint/explicit-member-accessibility': 'warn',
75+
'@typescript-eslint/member-ordering': 'warn',
76+
'@typescript-eslint/naming-convention': 'warn',
77+
'@typescript-eslint/require-await': 'warn',
78+
'@typescript-eslint/no-floating-promises': 'warn',
79+
'@typescript-eslint/no-redundant-type-constituents': 'warn',
80+
'@typescript-eslint/no-shadow': 'warn',
81+
'@typescript-eslint/prefer-promise-reject-errors': 'warn'
82+
};
83+
84+
// TODO to be discussed and fixed in future PRs
85+
export const temporaryWarnRules = {
86+
'jsdoc/check-tag-names': 'warn',
87+
'jsdoc/require-throws-type': 'warn',
88+
'import/order': 'warn',
89+
'unicorn/filename-case': 'warn',
90+
'unicorn/no-array-sort': 'warn',
91+
'unicorn/no-useless-switch-case': 'warn',
92+
'unicorn/prefer-single-call': 'warn',
93+
'unicorn/prefer-query-selector': 'warn',
94+
'unicorn/prefer-default-parameters': 'warn',
95+
'unicorn/prefer-number-properties': 'warn',
96+
'unicorn/prefer-ternary': 'warn',
97+
'unicorn/text-encoding-identifier-case': 'warn',
98+
'unicorn/explicit-length-check': 'warn',
99+
'unicorn/no-immediate-mutation': 'warn',
100+
'prefer-arrow/prefer-arrow-functions': 'warn',
101+
'jsdoc/require-description': 'warn',
102+
'jsdoc/require-param-type': 'warn',
103+
'jsdoc/reject-any-type': 'warn',
104+
'jsdoc/escape-inline-tags': 'warn',
105+
'jsdoc/check-alignment': 'warn',
106+
'no-underscore-dangle': 'warn',
107+
'no-console': 'warn',
108+
'no-undef': 'warn',
109+
'no-loop-func': 'warn',
110+
'no-bitwise': 'warn',
111+
'new-cap': 'warn',
112+
'prefer-const': 'warn',
113+
'import/no-cycle': 'warn',
114+
'import-newlines/enforce': 'warn',
115+
'@stylistic/max-len': 'warn',
116+
'@stylistic/max-statements-per-line': 'warn',
117+
'@stylistic/indent-binary-ops': 'warn',
118+
'@stylistic/comma-dangle': 'warn',
119+
'@stylistic/brace-style': 'warn',
120+
'@stylistic/semi': 'warn',
121+
'@stylistic/indent': 'warn',
122+
'@eslint-community/eslint-comments/require-description': 'warn'
123+
};

lib/eslint.config.mjs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import {
2+
defineConfig,
3+
globalIgnores,
4+
} from 'eslint/config';
5+
import {
6+
createSharedConfig,
7+
temporaryWarnRules,
8+
temporaryWarnRulesTs,
9+
} from '../eslint.shared.mjs';
10+
11+
export default defineConfig([
12+
globalIgnores(
13+
[
14+
'dist/',
15+
'dist-test/',
16+
'**/*.d.ts',
17+
'node_modules/',
18+
'bin/'
19+
],
20+
'collection-scripts/ignores'
21+
),
22+
...createSharedConfig({
23+
name: 'collection-scripts',
24+
tsProjects: ['tsconfig.json', 'tsconfig.test.json'],
25+
tsconfigRootDir: import.meta.dirname
26+
}),
27+
{
28+
// TODO to be discussed and fixed in a future PR
29+
name: 'collection-scripts/temporary-warn-rules-ts',
30+
files: ['**/*.ts'],
31+
rules: temporaryWarnRulesTs
32+
},
33+
{
34+
// TODO to be discussed and fixed in a future PR
35+
name: 'collection-scripts/temporary-warn-rules',
36+
files: ['**/*.{j,t}s'],
37+
rules: temporaryWarnRules
38+
},
39+
{
40+
name: 'collection-scripts/test-ts-rules',
41+
files: ['test/**/*.ts'],
42+
rules: {
43+
'@typescript-eslint/no-unsafe-member-access': 'off',
44+
'@typescript-eslint/no-unsafe-argument': 'off',
45+
'@typescript-eslint/no-unsafe-call': 'off',
46+
'@typescript-eslint/no-unsafe-return': 'off',
47+
'@typescript-eslint/no-unsafe-assignment': 'off',
48+
'@typescript-eslint/no-require-imports': 'off'
49+
}
50+
}
51+
]);

lib/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"watch": "tsc --watch",
2222
"compile-tests": "tsc -p tsconfig.test.json",
2323
"test": "npm run compile-tests && mocha 'dist-test/test/**/*.test.js'",
24-
"lint": "eslint src/**/*.ts test/**/*.ts",
24+
"lint": "eslint src test",
25+
"lint:fix": "eslint src test --fix",
2526
"prepublishOnly": "npm run build"
2627
},
2728
"repository": {

lib/src/bundle-id.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
/**
22
* Bundle ID Generation Utilities
33
* @module bundle-id
4-
*
4+
*
55
* IMPORTANT: This logic MUST stay in sync with the runtime implementation in:
66
* src/utils/bundleNameUtils.ts (generateBuildScriptBundleId function)
7-
*
7+
*
88
* The bundle ID format is: {owner}-{repo}-{collectionId}-v{version}
9-
*
9+
*
1010
* Any changes here should be mirrored in bundleNameUtils.ts and vice versa.
1111
*/
1212

1313
/**
1414
* Generate canonical bundle ID for consistency with runtime.
15-
*
1615
* @param repoSlug - Repository slug (owner/repo or owner-repo)
1716
* @param collectionId - Collection identifier
1817
* @param version - Version string (without 'v' prefix)
1918
* @returns Canonical bundle ID
20-
*
2119
* @example
2220
* generateBundleId('owner/repo', 'my-collection', '1.0.0')
2321
* // Returns: 'owner-repo-my-collection-v1.0.0'

0 commit comments

Comments
 (0)