|
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'; |
4 | 8 |
|
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, |
6 | 15 | { |
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 | + } |
8 | 20 | }, |
9 | | - eslint.configs.recommended, |
10 | | - eslintConfigPrettier, |
11 | 21 | { |
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'], |
16 | 34 | languageOptions: { |
17 | | - parser: tseslint.parser, |
18 | | - ecmaVersion: 2020, |
19 | | - sourceType: "module", |
20 | 35 | 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'], |
37 | 54 | 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 | + } |
51 | 72 | }, |
52 | 73 | { |
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'], |
54 | 138 | languageOptions: { |
55 | 139 | ecmaVersion: 2020, |
56 | | - sourceType: "module", |
| 140 | + sourceType: 'module', |
57 | 141 | 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 | + } |
74 | 145 | } |
75 | | -); |
| 146 | +]); |
0 commit comments