Skip to content

Commit ce889db

Browse files
committed
Avoid to use conf on cjs and mjs files
1 parent 7de956e commit ce889db

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

eslint.config.mjs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import unicornPlugin from 'eslint-plugin-unicorn';
2323
import tseslint from 'typescript-eslint';
2424

2525
export default tseslint.config(
26-
eslint.configs.recommended,
27-
importPlugin.flatConfigs.recommended,
2826
unicornPlugin.configs['flat/recommended'], // https://github.com/sindresorhus/eslint-plugin-unicorn?tab=readme-ov-file#es-module-recommended-1
2927
prettierRecommendedConfig, // Enables eslint-plugin-prettier, eslint-config-prettier and prettier/prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration.
3028
{
@@ -51,6 +49,25 @@ export default tseslint.config(
5149
},
5250
},
5351
],
52+
'unicorn/prefer-keyboard-event-key': 'off', // 'key' doesn't exist in the used ES version
53+
'unicorn/prefer-module': 'off', // We don't want to change a working configuration
54+
'unicorn/prefer-string-replace-all': 'off', // String#replaceAll() doesn't exist in the used ES version
55+
'unicorn/no-new-array': 'off', // In contradiction with unicorn/new-for-builtins: Use `new Array()` instead of `Array()`
56+
'unicorn/no-null': 'off', // We don't know the impact on mxGraph code
57+
'unicorn/no-useless-undefined': 'off', // The "undefined" value is useful where we use it and change some mxGraph code
58+
'unicorn/prefer-global-this': 'off', // We only target the browser, so it is valid to use the window object. In addition, using 'globalThis' require additional changes in the code/configuration to work.
59+
},
60+
// Actually, the new feature to ignore folders in conf file or in commande line, seems to not work after several tests.
61+
// https://eslint.org/docs/latest/use/configure/ignore
62+
ignores: ['.github/*', '.idea/*', '/build/*', '/config/*', '/dist/*', 'node_modules/*', 'scripts/utils/dist/*', 'test/performance/data/*'],
63+
},
64+
65+
// Don't execute on .cjs and .mjs files. Problem with 'module', 'require', 'console', 'exports', etc.
66+
{
67+
files: ['**/*.js', '**/*.ts', '**/*.cts', '**/*.mts'],
68+
...eslint.configs.recommended,
69+
...importPlugin.flatConfigs.recommended,
70+
rules: {
5471
'import/newline-after-import': ['error', { count: 1 }],
5572
'import/first': 'error',
5673
'import/order': [
@@ -65,15 +82,7 @@ export default tseslint.config(
6582
},
6683
},
6784
],
68-
'unicorn/prefer-keyboard-event-key': 'off', // 'key' doesn't exist in the used ES version
69-
'unicorn/prefer-module': 'off', // We don't want to change a working configuration
70-
'unicorn/prefer-string-replace-all': 'off', // String#replaceAll() doesn't exist in the used ES version
71-
'unicorn/no-new-array': 'off', // In contradiction with unicorn/new-for-builtins: Use `new Array()` instead of `Array()`
72-
'unicorn/no-null': 'off', // We don't know the impact on mxGraph code
73-
'unicorn/no-useless-undefined': 'off', // The "undefined" value is useful where we use it and change some mxGraph code
74-
'unicorn/prefer-global-this': 'off', // We only target the browser, so it is valid to use the window object. In addition, using 'globalThis' require additional changes in the code/configuration to work.
7585
},
76-
ignores: ['.github/', '.idea/', '/build/', '/config/', '/dist/', 'node_modules/', 'scripts/utils/dist/', 'test/performance/data/'],
7786
},
7887

7988
// disable type-aware linting on JS files

0 commit comments

Comments
 (0)