Skip to content

Commit d3e47a4

Browse files
committed
migrate overrides
1 parent a67ac1f commit d3e47a4

File tree

2 files changed

+148
-144
lines changed

2 files changed

+148
-144
lines changed

eslint.config.cjs

Lines changed: 0 additions & 144 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/*
2+
Copyright 2021 Bonitasoft S.A.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import noticePlugin from "eslint-plugin-notice";
18+
import importPlugin from "eslint-plugin-import";
19+
import unicornPlugin from "eslint-plugin-unicorn";
20+
21+
import eslintPluginImport from 'eslint-plugin-import';
22+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
23+
import eslint from '@eslint/js';
24+
import tseslint from 'typescript-eslint';
25+
26+
27+
export default [
28+
{
29+
...eslintPluginImport.configs.recommended, // import/recommended is not working for now with ESLint v9
30+
...unicornPlugin.configs.recommended,
31+
...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.
32+
33+
root: true,
34+
plugins: {
35+
notice: noticePlugin,
36+
unicorn: unicornPlugin,
37+
import: importPlugin
38+
},
39+
languageOptions: {
40+
parserOptions: {
41+
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
42+
sourceType: 'module', // Allows for the use of imports
43+
},
44+
},
45+
rules: {
46+
'notice/notice': ['error', {templateFile: 'config/license-header.js', onNonMatchingHeader: 'replace'}],
47+
'no-console': ['error', {allow: ['warn', 'error']}],
48+
'unicorn/filename-case': [
49+
'error',
50+
{
51+
cases: {
52+
camelCase: true,
53+
kebabCase: true,
54+
pascalCase: true,
55+
snakeCase: true,
56+
},
57+
},
58+
],
59+
'import/newline-after-import': ['error', {count: 1}],
60+
'import/first': 'error',
61+
'import/order': [
62+
'error',
63+
{
64+
groups: ['type', 'builtin', 'external', 'parent', 'sibling', 'index', 'internal'],
65+
'newlines-between': 'always',
66+
alphabetize: {
67+
order: 'asc',
68+
orderImportKind: 'asc',
69+
caseInsensitive: true,
70+
},
71+
},
72+
],
73+
'unicorn/prefer-keyboard-event-key': 'off', // 'key' doesn't exist in the used ES version
74+
'unicorn/prefer-module': 'off', // We don't want to change a working configuration
75+
'unicorn/prefer-string-replace-all': 'off', // String#replaceAll() doesn't exist in the used ES version
76+
'unicorn/no-new-array': 'off', // In contradiction with unicorn/new-for-builtins: Use `new Array()` instead of `Array()`
77+
'unicorn/no-null': 'off', // We don't know the impact on mxGraph code
78+
'unicorn/no-useless-undefined': 'off', // The "undefined" value is useful where we use it and change some mxGraph code
79+
},
80+
},
81+
82+
// typescript
83+
{ ...eslint.configs.recommended, files: ['**/*.ts', '**/*.tsx'] },
84+
tseslint.configs.recommended.map(conf => ({ ...conf, files: ['**/*.ts', '**/*.tsx'] })),
85+
/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
86+
{
87+
...tseslint.configs.stylistic,
88+
...eslintPluginImport.configs.typescript, // import/typescript is not working for now with ESLint v9
89+
...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.
90+
91+
files: ['*.ts'],
92+
settings: {
93+
'import/resolver': {
94+
typescript: {
95+
alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
96+
project: '**/tsconfig.json',
97+
},
98+
},
99+
},
100+
languageOptions: {
101+
parserOptions: {
102+
// This setting is required if you want to use rules which require type information
103+
// https://typescript-eslint.io/packages/parser/#project
104+
project: ['./tsconfig.json', './tsconfig.test.json', './tsconfig.utils.json'],
105+
},
106+
},
107+
rules: {
108+
'@typescript-eslint/explicit-function-return-type': [
109+
'error',
110+
{
111+
allowExpressions: true,
112+
allowTypedFunctionExpressions: true,
113+
},
114+
],
115+
'@typescript-eslint/explicit-member-accessibility': [
116+
'error',
117+
{
118+
accessibility: 'no-public',
119+
},
120+
],
121+
'@typescript-eslint/consistent-type-exports': [
122+
'error',
123+
{
124+
fixMixedExportsWithInlineTypeSpecifier: true,
125+
},
126+
],
127+
'@typescript-eslint/consistent-type-imports': ['error'],
128+
// We choose to disable it and choose later if we want to enable it. See https://github.com/process-analytics/bpmn-visualization-js/pull/2821.
129+
'@typescript-eslint/consistent-type-definitions': 'off',
130+
'@typescript-eslint/dot-notation': 'error',
131+
132+
'require-await': 'off', // disable the base eslint rule as it can report incorrect errors when '@typescript-eslint/require-await' is enabled (see official documentation)
133+
'@typescript-eslint/require-await': 'error',
134+
'@typescript-eslint/no-floating-promises': 'error',
135+
'@typescript-eslint/no-misused-promises': 'error',
136+
137+
'@typescript-eslint/restrict-plus-operands': 'error',
138+
139+
// The following lines are commented, because they show errors on files other than the demo:
140+
// '@typescript-eslint/no-base-to-string': 'error',
141+
// '@typescript-eslint/no-unsafe-assignment': 'error',
142+
// '@typescript-eslint/no-unsafe-argument': 'error',
143+
// '@typescript-eslint/no-unsafe-member-access': 'error',
144+
// '@typescript-eslint/restrict-template-expressions': 'error',
145+
// '@typescript-eslint/unbound-method': 'error',
146+
},
147+
},
148+
];

0 commit comments

Comments
 (0)