-
Notifications
You must be signed in to change notification settings - Fork 180
/
eslint.config.mjs
112 lines (106 loc) · 2.2 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
import globals from 'globals'
import js from '@eslint/js'
import prettierConfig from 'eslint-config-prettier'
import { fileURLToPath } from 'url'
import { dirname } from 'path'
/**
* TODO:
* - Check speed (inspect ignored files, that we're not processing junk)
* - Fix lint-staged
*/
/**
* Feed in import.meta.url in your .mjs module to get the equivalent of __dirname
* @param {string} importMetaUrl
*/
export const getESMDirname = (importMetaUrl) => {
return dirname(fileURLToPath(importMetaUrl))
}
/**
* Configs that should only apply to repo root (shouldn't be inherited in subdirectories)
* @type {Array<import('eslint').Linter.FlatConfig>}
*/
const rootConfigs = [
{
ignores: [
'packages/**/*',
'.circleci',
'.devcontainer',
'.github',
'.husky',
'.vscode',
'.yarn',
'docker',
'node_modules',
'test-queries',
'setup'
]
},
{
files: ['*.{js,mjs,cjs}', '.*.{js,mjs,cjs}', 'utils/*.{js,mjs,cjs}'],
languageOptions: {
sourceType: 'commonjs',
globals: {
...globals.node
}
}
},
{
files: ['*.mjs', '.*.mjs', 'utils/*.mjs'],
languageOptions: {
sourceType: 'module'
}
}
]
/**
* Base configs that should be inherited in all packages as well
* @type {Array<import('eslint').Linter.FlatConfig>}
*/
export const baseConfigs = [
{
ignores: [
'**/node_modules/**',
'**/dist/**',
'**/dist-*/**',
'**/public/**',
'**/events.json',
'**/generated/**/*',
'**/.nuxt/**',
'**/.output/**'
]
},
{
files: ['**/*.mjs'],
languageOptions: {
sourceType: 'module'
}
},
{
files: ['**/*.cjs'],
languageOptions: {
sourceType: 'commonjs'
}
},
{
files: ['**/*.{js,mjs,cjs}', '**/.*.{js,mjs,cjs}'],
...js.configs.recommended
},
prettierConfig,
{
rules: {
camelcase: [
1,
{
properties: 'always'
}
],
'no-var': 'error',
'no-alert': 'error',
eqeqeq: 'error',
'prefer-const': 'warn',
'object-shorthand': 'warn'
}
}
]
const configs = [...baseConfigs, ...rootConfigs]
export { globals, prettierConfig }
export default configs