-
Notifications
You must be signed in to change notification settings - Fork 331
/
eslint.config.mjs
151 lines (148 loc) · 4.25 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import globals from 'globals';
import pluginJs from '@eslint/js';
import pluginTypeScript from 'typescript-eslint';
import eslintPluginYml from 'eslint-plugin-yml';
import eslintPluginAstro from 'eslint-plugin-astro';
import eslintPluginJsonc from 'eslint-plugin-jsonc';
import eslintPluginHtmlInlineScripts from 'eslint-plugin-html';
import eslintConfigPrettier from 'eslint-config-prettier';
import eslintPluginHtml from '@html-eslint/eslint-plugin';
import eslintPluginHtmlParser from '@html-eslint/parser';
import eslintPluginMdx from 'eslint-plugin-mdx';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { FlatCompat } from '@eslint/eslintrc';
// TODO: Change to import.meta.dirname once Node 18 is no longer supported (Node >= >=20.11.0)
const __dirname = dirname(fileURLToPath(import.meta.url));
const compat = new FlatCompat({
baseDirectory: __dirname
});
/** @type {import('eslint').Linter.Config[]} */
export default [
...[
...compat.extends('jquery'),
{
languageOptions: {
sourceType: 'script',
ecmaVersion: 5,
globals: { ...globals.browser, ...globals.jquery }
},
rules: {
'one-var': ['error', { var: 'consecutive' }],
strict: ['error', 'function'],
'no-nested-ternary': 0,
camelcase: 0,
'no-console': ['error', { allow: ['warn', 'error'] }]
}
}
].map((cfg) => ({
ignores: [
'site/**',
'!site/src/components/demos/**/map.{js,html}',
'**/*.{mjs,cjs}'
],
...cfg
})),
{
ignores: [
'**/redist/**',
'**/build/**',
'**/dist/**',
'**/.astro/**',
'docs/**'
]
},
{
files: ['site/src/components/demos/**/map.js'],
languageOptions: {
parserOptions: {
ecmaFeatures: {
// these files are directly displayed in `Scripts` tab in website so avoid having to include use strict
impliedStrict: true
}
}
}
},
{
files: ['.remarkrc.mjs'],
languageOptions: { globals: { ...globals.node } }
},
pluginJs.configs.recommended,
...pluginTypeScript.config({
files: ['site/**/*.{js,mjs,cjs,ts}'],
ignores: ['site/src/components/demos/**/map.js'],
extends: [
pluginTypeScript.configs.strictTypeChecked,
pluginTypeScript.configs.stylisticTypeChecked
],
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: `${__dirname}/site`
}
}
}),
...eslintPluginAstro.configs.recommended,
{
...eslintPluginMdx.flat,
processor: eslintPluginMdx.createRemarkProcessor({
lintCodeBlocks: true
}),
rules: {
...eslintPluginMdx.flat.rules,
'no-unused-vars': 'off'
}
},
{
...eslintPluginMdx.flatCodeBlocks,
rules: {
...eslintPluginMdx.flatCodeBlocks.rules,
'no-var': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-require-imports': 'off'
}
},
{
// Configuration for `<script>` tag using TypeScript in `.astro` files and code blocks in markdown.
files: ['site/**/*.astro/*.ts', 'site/**/*.{md,mdx}/*.js'],
languageOptions: {
parserOptions: {
project: false
}
},
rules: {
...pluginTypeScript.configs.disableTypeChecked.rules
}
},
...eslintPluginYml.configs['flat/recommended'],
...eslintPluginJsonc.configs['flat/recommended-with-jsonc'],
{
...eslintPluginHtml.configs['flat/recommended'],
files: ['**/*.html'],
plugins: {
eslintPluginHtmlInlineScripts,
'@html-eslint': eslintPluginHtml
},
languageOptions: {
parser: eslintPluginHtmlParser
},
settings: {
'html/indent': '+2',
'html/report-bad-indent': 'error'
},
rules: {
...eslintPluginHtml.configs['flat/recommended'].rules,
'@html-eslint/require-img-alt': 'off',
/* Disable rules that conflict with prettier */
'@html-eslint/require-closing-tags': 'off',
'@html-eslint/no-multiple-empty-lines': 'off',
'@html-eslint/no-extra-spacing-attrs': 'off',
'@html-eslint/element-newline': 'off',
'@html-eslint/indent': 'off',
'@html-eslint/quotes': 'off',
'@html-eslint/no-trailing-spaces': 'off',
'@html-eslint/attrs-newline': 'off'
}
},
eslintConfigPrettier
];