|
1
|
import prettier from "eslint-plugin-prettier" |
|
2
|
import markdown from "eslint-plugin-markdown" |
|
3
|
import medusaContentConfigs from "../../content-lint-medusa.mjs" |
|
4
|
import titledMarkdownProcessor from "../../content-lint-processor.mjs" |
|
5
|
import globals from "globals" |
|
6
|
import babelParser from "@babel/eslint-parser" |
|
7
|
import typescriptEslintEslintPlugin from "@typescript-eslint/eslint-plugin" |
|
8
|
import tsParser from "@typescript-eslint/parser" |
|
9
|
import path from "node:path" |
|
10
|
import { fileURLToPath } from "node:url" |
|
11
|
import js from "@eslint/js" |
|
12
|
import { FlatCompat } from "@eslint/eslintrc" |
|
13
|
|
|
14
|
const __filename = fileURLToPath(import.meta.url) |
|
15
|
const __dirname = path.dirname(__filename) |
|
16
|
const compat = new FlatCompat({ |
|
17
|
baseDirectory: __dirname, |
|
18
|
recommendedConfig: js.configs.recommended, |
|
19
|
allConfig: js.configs.all, |
|
20
|
}) |
|
21
|
|
|
22
|
export default [ |
|
23
|
{ |
|
24
|
ignores: ["**/references/**/*"], |
|
25
|
}, |
|
26
|
{ |
|
27
|
plugins: { |
|
28
|
prettier, |
|
29
|
markdown, |
|
30
|
}, |
|
31
|
|
|
32
|
languageOptions: { |
|
33
|
globals: { |
|
34
|
...globals.node, |
|
35
|
}, |
|
36
|
|
|
37
|
parser: babelParser, |
|
38
|
ecmaVersion: 13, |
|
39
|
sourceType: "module", |
|
40
|
|
|
41
|
parserOptions: { |
|
42
|
requireConfigFile: false, |
|
43
|
|
|
44
|
ecmaFeatures: { |
|
45
|
experimentalDecorators: true, |
|
46
|
modules: true, |
|
47
|
}, |
|
48
|
}, |
|
49
|
}, |
|
50
|
|
|
51
|
settings: { |
|
52
|
react: { |
|
53
|
version: "detect", |
|
54
|
}, |
|
55
|
}, |
|
56
|
|
|
57
|
rules: { |
|
58
|
"no-undef": "off", |
|
59
|
"no-unused-expressions": "off", |
|
60
|
"no-unused-vars": "off", |
|
61
|
"no-unused-labels": "off", |
|
62
|
"no-console": "off", |
|
63
|
curly: ["error", "all"], |
|
64
|
"new-cap": "off", |
|
65
|
"require-jsdoc": "off", |
|
66
|
camelcase: "off", |
|
67
|
"no-invalid-this": "off", |
|
68
|
|
|
69
|
"max-len": [ |
|
70
|
"warn", |
|
71
|
{ |
|
72
|
code: 64, |
|
73
|
}, |
|
74
|
], |
|
75
|
|
|
76
|
semi: ["error", "never"], |
|
77
|
|
|
78
|
quotes: [ |
|
79
|
"error", |
|
80
|
"double", |
|
81
|
{ |
|
82
|
allowTemplateLiterals: true, |
|
83
|
}, |
|
84
|
], |
|
85
|
|
|
86
|
"comma-dangle": [ |
|
87
|
"error", |
|
88
|
{ |
|
89
|
arrays: "always-multiline", |
|
90
|
objects: "always-multiline", |
|
91
|
imports: "always-multiline", |
|
92
|
exports: "always-multiline", |
|
93
|
functions: "never", |
|
94
|
}, |
|
95
|
], |
|
96
|
|
|
97
|
"object-curly-spacing": ["error", "always"], |
|
98
|
"arrow-parens": ["error", "always"], |
|
99
|
"linebreak-style": 0, |
|
100
|
|
|
101
|
"no-confusing-arrow": [ |
|
102
|
"error", |
|
103
|
{ |
|
104
|
allowParens: false, |
|
105
|
}, |
|
106
|
], |
|
107
|
|
|
108
|
"space-before-function-paren": [ |
|
109
|
"error", |
|
110
|
{ |
|
111
|
anonymous: "always", |
|
112
|
named: "never", |
|
113
|
asyncArrow: "always", |
|
114
|
}, |
|
115
|
], |
|
116
|
|
|
117
|
"space-infix-ops": "off", |
|
118
|
"eol-last": ["error", "always"], |
|
119
|
"react/prop-types": "off", |
|
120
|
"react/jsx-no-undef": "off", |
|
121
|
}, |
|
122
|
}, |
|
123
|
{ |
|
124
|
files: ["**/*.md", "**/*.mdx"], |
|
125
|
processor: titledMarkdownProcessor, |
|
126
|
}, |
|
127
|
{ |
|
128
|
files: [ |
|
129
|
"**/*.md/**/*.js", |
|
130
|
"**/*.mdx/**/*.js", |
|
131
|
"**/*.md/**/*.jsx", |
|
132
|
"**/*.mdx/**/*.jsx", |
|
133
|
], |
|
134
|
}, |
|
135
|
...compat.extends("plugin:@typescript-eslint/recommended").map((config) => ({ |
|
136
|
...config, |
|
137
|
files: [ |
|
138
|
"**/*.md/**/*.ts", |
|
139
|
"**/*.mdx/**/*.ts", |
|
140
|
"**/*.md/**/*.tsx", |
|
141
|
"**/*.mdx/**/*.tsx", |
|
142
|
], |
|
143
|
})), |
|
144
|
{ |
|
145
|
files: [ |
|
146
|
"**/*.md/**/*.ts", |
|
147
|
"**/*.mdx/**/*.ts", |
|
148
|
"**/*.md/**/*.tsx", |
|
149
|
"**/*.mdx/**/*.tsx", |
|
150
|
], |
|
151
|
|
|
152
|
plugins: { |
|
153
|
"@typescript-eslint": typescriptEslintEslintPlugin, |
|
154
|
}, |
|
155
|
|
|
156
|
languageOptions: { |
|
157
|
parser: tsParser, |
|
158
|
}, |
|
159
|
|
|
160
|
rules: { |
|
161
|
"@typescript-eslint/no-unused-vars": "off", |
|
162
|
"@typescript-eslint/no-empty-function": "off", |
|
163
|
"@typescript-eslint/no-explicit-any": "off", |
|
164
|
"@typescript-eslint/no-non-null-assertion": "off", |
|
165
|
"@typescript-eslint/no-var-requires": "off", |
|
166
|
"prefer-rest-params": "off", |
|
167
|
"@typescript-eslint/ban-ts-comment": "off", |
|
168
|
"@typescript-eslint/no-non-null-asserted-optional-chain": "off", |
|
169
|
"@typescript-eslint/ban-types": "off", |
|
170
|
}, |
|
171
|
}, |
|
172
|
...medusaContentConfigs, |
|
173
|
] |