-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
Copy patheslint.config.mjs
74 lines (66 loc) · 1.5 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
// @ts-check
/** @import { Linter } from "eslint" */
import eslintJs from "@eslint/js";
import eslintPluginJsdoc from "eslint-plugin-jsdoc";
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
import globals from "globals";
/**
* Globs for ESM files.
* @satisfies {Array<string>}
*/
const globsEsm = ["**/**.mjs"];
/**
* Globs for CJS files.
* @satisfies {Array<string>}
*/
const globsCjs = ["**/**.cjs", "**/**.js"];
/**
* Globs for all JavaScript files.
* @satisfies {Array<string>}
*/
const globsJs = [...globsEsm, ...globsCjs];
/**
* ESLint configuration.
* @satisfies {Array<Linter.Config>}
*/
const eslintConfig = [
{
files: globsJs,
...eslintJs.configs.recommended,
},
{
files: globsJs,
...eslintPluginJsdoc.configs["flat/recommended-typescript-flavor-error"],
},
{
files: globsJs,
rules: {
"arrow-body-style": "error",
"object-shorthand": "error",
strict: "error",
// Sometimes it’s better for TypeScript to infer the return type.
"jsdoc/require-returns-type": "off",
},
},
{
files: globsEsm,
languageOptions: {
globals: globals.nodeBuiltin,
},
plugins: {
"simple-import-sort": eslintPluginSimpleImportSort,
},
rules: {
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
},
{
files: globsCjs,
languageOptions: {
sourceType: "commonjs",
globals: globals.node,
},
},
];
export default eslintConfig;