forked from finos/legend-studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
58 lines (55 loc) · 2.74 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* We need to detect environment for ESLint CLI because there are rules
* which are computationally expensive to perform during development.
* Therefore, for each environments, we will enable/disable these rules according:
* - For `development` mode (when watching for changes and re-compile): DISABLE
* - For `IDE` ESLint process (to keep the IDE snappy): DISABLE
* - For `production` mode (to produce bundled code): ENABLE
* - For `linting` process (to check code quality in CI): ENABLE
*/
const enableFastMode =
process.env.NODE_ENV === undefined || // IDE ESLint process runs without setting a NODE environment
(process.env.NODE_ENV === 'development' &&
process.env.DEVELOPMENT_MODE !== 'advanced');
/**
* NOTE: this config is supposed to be used for both the IDE ESLint process
* and the CI ESLint process. However, since we have many Typescript projects,
* `typescript-eslint` does not seem to handle this well enough as it can end up
* throwing Out-Of-Memory error if we just call `eslint` from the root directory.
* As such, for CI, we will call `eslint` from each package separately as this is
* the only rules that runs the expensive linting rules
*
* See https://github.com/typescript-eslint/typescript-eslint/issues/1192
*/
module.exports = {
root: true, // tell ESLint to stop looking further up in directory tree to resolve for parent configs
parserOptions: {
// `parserOptions.project` is required for generating parser service to run specific rules like
// `prefer-nullish-coalescing`, and `prefer-optional-chain`
project: ['./packages/*/tsconfig.json'],
// Use this experimental flag to improve memory usage while using Typescript project reference
// See https://github.com/typescript-eslint/typescript-eslint/issues/2094
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
},
plugins: ['@finos/legend-studio'],
extends: [
'plugin:@finos/legend-studio/recommended',
!enableFastMode && 'plugin:@finos/legend-studio/computationally-expensive',
'plugin:@finos/legend-studio/scripts-override', // must be called last to turn off rules which are not applicable for scripts
].filter(Boolean),
};