forked from umbraco/Umbraco.CMS.Backoffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
94 lines (90 loc) · 2.98 KB
/
eslint.config.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import js from '@eslint/js';
import globals from 'globals';
import importPlugin from 'eslint-plugin-import';
import localRules from 'eslint-plugin-local-rules';
import wcPlugin from 'eslint-plugin-wc';
import litPlugin from 'eslint-plugin-lit';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import tseslint from 'typescript-eslint';
import jsdoc from 'eslint-plugin-jsdoc';
export default [
// Recommended config applied to all files
js.configs.recommended,
...tseslint.configs.recommended,
wcPlugin.configs['flat/recommended'],
litPlugin.configs['flat/recommended'],
jsdoc.configs['flat/recommended'], // We use the non typescript version to allow types to be defined in the jsdoc comments. This will allow js docs as an alternative to typescript types.
localRules.configs.all,
eslintPluginPrettierRecommended,
// Global ignores
{
ignores: [
'**/eslint.config.js',
'**/rollup.config.js',
'**/vite.config.ts',
'src/external',
'src/packages/core/icon-registry/icons',
'src/packages/core/icon-registry/icons.ts',
'src/**/*.test.ts',
],
},
// Global config
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
globals: {
...globals.browser,
},
},
plugins: {
import: importPlugin,
'local-rules': localRules,
},
rules: {
semi: ['warn', 'always'],
'prettier/prettier': ['warn', { endOfLine: 'auto' }],
'no-unused-vars': 'off', //Let '@typescript-eslint/no-unused-vars' catch the errors to allow unused function parameters (ex: in interfaces)
'no-var': 'error',
...importPlugin.configs.recommended.rules,
'import/namespace': 'off',
'import/no-unresolved': 'off',
'import/order': ['warn', { groups: ['builtin', 'parent', 'sibling', 'index', 'external'] }],
'import/no-self-import': 'error',
'import/no-cycle': ['error', { maxDepth: 6, allowUnsafeDynamicCyclicDependency: true }],
'import/no-named-as-default': 'off', // Does not work with eslint 9
'import/no-named-as-default-member': 'off', // Does not work with eslint 9
'local-rules/prefer-static-styles-last': 'warn',
'local-rules/enforce-umbraco-external-imports': [
'error',
{
exceptions: ['@umbraco-cms', '@open-wc/testing', '@storybook', 'msw', '.', 'vite'],
},
],
'local-rules/exported-string-constant-naming': [
'error',
{
excludedFileNames: ['umbraco-package', 'input-tiny-mce.defaults'], // TODO: what to do about the tiny mce defaults?
},
],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'warn',
},
},
// Pattern-specific overrides
{
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
languageOptions: {
globals: {
...globals.node,
},
},
},
];