-
Notifications
You must be signed in to change notification settings - Fork 20
/
eslint.config.mjs
137 lines (128 loc) · 3.9 KB
/
eslint.config.mjs
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* eslint-disable n/no-extraneous-import */
// @ts-check
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import eslint from '@eslint/js'
import neslint from 'eslint-plugin-n'
import tseslint from 'typescript-eslint'
import reacteslint from 'eslint-plugin-react'
import hookseslint from 'eslint-plugin-react-hooks'
import reactRefreshEslint from 'eslint-plugin-react-refresh'
export default [
// setup the parser first
{
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
},
{
...neslint.configs['flat/recommended-script'],
ignores: [...(neslint.configs['flat/recommended-script'].ignores ?? []), 'webui/**/*'],
},
{
// extends: commonExtends,
plugins: {
'@typescript-eslint': tseslint.plugin,
},
rules: {
// Default rules to be applied everywhere
'prettier/prettier': 'error',
...eslint.configs.recommended.rules,
'no-console': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_', varsIgnorePattern: '^_(.+)' },
],
'no-extra-semi': 'off',
// 'n/no-unsupported-features/es-syntax': ['error', { ignores: ['modules'] }],
'no-use-before-define': 'off',
'no-warning-comments': ['error', { terms: ['nocommit', '@nocommit', '@no-commit'] }],
// 'jest/no-mocks-import': 'off',
},
},
...tseslint.configs.recommendedTypeChecked,
{
// disable type-aware linting on JS files
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
...tseslint.configs.disableTypeChecked,
},
{
files: ['*.mjs'],
languageOptions: {
sourceType: 'module',
},
},
{
files: ['**/*.tsx', '**/*.ts', '**/*.cts', '**/*.mts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/explicit-module-boundary-types': ['error'],
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/require-await': 'off', // conflicts with 'promise-function-async'
/** Disable some annoyingly strict rules from the 'recommended-requiring-type-checking' pack */
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-argument': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/no-unsafe-call': 0,
'@typescript-eslint/restrict-template-expressions': 0,
'@typescript-eslint/restrict-plus-operands': 0,
'@typescript-eslint/no-redundant-type-constituents': 0,
/** End 'recommended-requiring-type-checking' overrides */
},
},
{
files: ['**/__tests__/**/*', 'test/**/*'],
rules: {
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
},
},
// Add prettier at the end to give it final say on formatting
eslintPluginPrettierRecommended,
{
// But lastly, ensure that we ignore certain paths
ignores: [
'**/dist/*',
'**/build/*',
'/dist',
'**/pkg/*',
'**/docs/*',
'**/generated/*',
'**/node_modules/*',
'**/electron-output/*',
'webui/vite.config.ts',
'pi-image/**/*',
],
},
{
files: ['eslint.config.*'],
rules: {
'n/no-unpublished-import': 'off',
},
},
// The above is mostly copied from https://github.com/bitfocus/companion-module-tools/blob/main/eslint/config.mjs with very little modifications. The below is extra rules that have been added
{
files: ['webui/**/*.tsx', 'webui/**/*.jsx', 'webui/**/*.ts', 'webui/**/*.js'],
plugins: {
'react-hooks': hookseslint,
'react-refresh': reactRefreshEslint,
react: reacteslint,
},
rules: {
...hookseslint.configs.recommended.rules,
'react-refresh/only-export-components': 'warn',
},
},
{
rules: {
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
},
},
]