Skip to content

Commit 1b689f1

Browse files
committed
update the configuration
1 parent 99233d5 commit 1b689f1

File tree

1 file changed

+30
-34
lines changed

1 file changed

+30
-34
lines changed

eslint.config.mjs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
18-
1917
import eslint from '@eslint/js';
20-
import importPlugin from "eslint-plugin-import";
2118
import eslintPluginImport from 'eslint-plugin-import';
22-
import noticePlugin from "eslint-plugin-notice";
19+
import jestPlugin from 'eslint-plugin-jest';
20+
import noticePlugin from 'eslint-plugin-notice';
2321
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
24-
import unicornPlugin from "eslint-plugin-unicorn";
22+
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
2523
import tseslint from 'typescript-eslint';
2624

27-
28-
export default [
25+
export default tseslint.config(
2926
{
30-
...eslintPluginImport.flatConfigs.recommended,
31-
// ...unicornPlugin.configs.recommended, // is not working for now with ESLint v9
32-
...eslintPluginPrettierRecommended, // 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.
33-
3427
plugins: {
3528
notice: noticePlugin,
36-
unicorn: unicornPlugin,
37-
import: importPlugin
29+
'@typescript-eslint': tseslint.plugin,
30+
jest: jestPlugin,
3831
},
32+
extends: [
33+
// eslint.configs.recommended,
34+
eslintPluginImport.flatConfigs.recommended,
35+
eslintPluginUnicorn.configs['flat/recommended'],
36+
eslintPluginPrettierRecommended, // 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.
37+
],
3938
languageOptions: {
39+
parser: tseslint.parser,
4040
parserOptions: {
4141
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
4242
sourceType: 'module', // Allows for the use of imports
4343
},
4444
},
4545
rules: {
46-
'notice/notice': ['error', {templateFile: 'config/license-header.js', onNonMatchingHeader: 'replace'}],
47-
'no-console': ['error', {allow: ['warn', 'error']}],
46+
'notice/notice': ['error', { templateFile: 'config/license-header.js', onNonMatchingHeader: 'replace' }],
47+
'no-console': ['error', { allow: ['warn', 'error'] }],
4848
'unicorn/filename-case': [
4949
'error',
5050
{
@@ -56,7 +56,7 @@ export default [
5656
},
5757
},
5858
],
59-
'import/newline-after-import': ['error', {count: 1}],
59+
'import/newline-after-import': ['error', { count: 1 }],
6060
'import/first': 'error',
6161
'import/order': [
6262
'error',
@@ -77,28 +77,19 @@ export default [
7777
'unicorn/no-null': 'off', // We don't know the impact on mxGraph code
7878
'unicorn/no-useless-undefined': 'off', // The "undefined" value is useful where we use it and change some mxGraph code
7979
},
80-
ignores: [
81-
'.github/',
82-
'.idea/',
83-
'/build/',
84-
'/config/',
85-
'/dist/',
86-
'node_modules/',
87-
'scripts/utils/dist/',
88-
'test/performance/data/',
89-
],
80+
ignores: ['.github/', '.idea/', '/build/', '/config/', '/dist/', 'node_modules/', 'scripts/utils/dist/', 'test/performance/data/'],
81+
},
82+
{
83+
// disable type-aware linting on JS files
84+
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
85+
...tseslint.configs.disableTypeChecked,
9086
},
9187

9288
// typescript
93-
{ ...eslint.configs.recommended, files: ['**/*.ts', '**/*.tsx'] },
94-
...tseslint.configs.recommended.map(conf => ({ ...conf, files: ['**/*.ts', '**/*.tsx'] })),
9589
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
9690
{
97-
...tseslint.configs.stylistic,
98-
...eslintPluginImport.flatConfigs.typescript,
99-
...eslintPluginPrettierRecommended, // 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.
100-
101-
files: ['*.ts'],
91+
files: ['**/*.ts', '**/*.cts', '**/*.mts'],
92+
extends: [...tseslint.configs.recommended, ...tseslint.configs.stylistic, eslintPluginImport.flatConfigs.typescript],
10293
settings: {
10394
'import/resolver': {
10495
typescript: {
@@ -155,4 +146,9 @@ export default [
155146
// '@typescript-eslint/unbound-method': 'error',
156147
},
157148
},
158-
];
149+
{
150+
// enable jest rules on test files
151+
files: ['test/**'],
152+
...jestPlugin.configs['flat/recommended'],
153+
},
154+
);

0 commit comments

Comments
 (0)