-
Notifications
You must be signed in to change notification settings - Fork 376
/
Copy patheslint.config.js
114 lines (109 loc) · 3.5 KB
/
eslint.config.js
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
// eslint-disable-next-line n/no-extraneous-import
import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import globals from "globals";
import eslintPluginUnicorn from "eslint-plugin-unicorn";
import eslintNodePlugin from "eslint-plugin-n";
import pluginPromise from "eslint-plugin-promise";
import pluginJest from "eslint-plugin-jest";
export default [
{
ignores: ["**/dist/*.js", "eslint.config.mjs"],
},
js.configs.recommended,
eslintPluginUnicorn.configs["flat/recommended"],
eslintNodePlugin.configs["flat/recommended-script"],
pluginPromise.configs["flat/recommended"],
eslintConfigPrettier,
{
languageOptions: {
globals: {
...globals.builtin,
...globals["shared-node-browser"],
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
sourceType: "module",
},
rules: {
strict: ["error", "global"],
"no-empty": ["error", { allowEmptyCatch: true }],
// "no-multi-assign": "off",
"func-names": ["error", "as-needed"],
"operator-linebreak": [
"error",
"after",
{ overrides: { "?": "before", ":": "before" } },
],
"capitalized-comments": "off",
"prefer-rest-params": ["error"],
"prefer-spread": ["error"],
"prefer-object-spread": ["error"],
"prefer-destructuring": [
"error",
{
array: false,
object: true,
},
],
"prefer-arrow-callback": ["error", { allowNamedFunctions: true }],
"no-redeclare": ["error", { builtinGlobals: false }],
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
// node
// https://github.com/eslint-community/eslint-plugin-n/
"n/no-unpublished-require": "off", // doesn't play nice with monorepo
"n/no-extraneous-require": ["error", { allowModules: ["@xmpp/test"] }],
"n/no-extraneous-import": ["error", { allowModules: ["@xmpp/test"] }],
"n/hashbang": "off",
// promise
// https://github.com/xjamundx/eslint-plugin-promise
"promise/prefer-await-to-then": "off",
"promise/prefer-await-to-callbacks": "off",
// unicorn
// https://github.com/sindresorhus/eslint-plugin-unicorn
"unicorn/filename-case": "off",
"unicorn/catch-error-name": ["error", { name: "err" }],
"unicorn/prevent-abbreviations": "off",
"unicorn/no-useless-undefined": "off",
"unicorn/no-null": "off",
"unicorn/prefer-event-target": "off",
// "unicorn/prefer-top-level-await": "off",
"unicorn/prefer-node-protocol": "off",
"unicorn/prefer-export-from": "off",
},
},
{
files: ["**/*.cjs"],
languageOptions: {
sourceType: "commonjs",
},
},
{
files: ["**/*.spec.js", "**/*.test.js", "**/test.js", "**/test/**.js"],
plugins: { jest: pluginJest },
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
rules: {
...pluginJest.configs["flat/style"].rules,
...pluginJest.configs["flat/recommended"].rules,
"jest/no-done-callback": "off",
"jest/prefer-to-be": "off",
"jest/no-conditional-expect": "off",
// https://github.com/jest-community/eslint-plugin-jest/pull/1688
"jest/valid-expect": "off",
// "jest/valid-expect": [
// "error",
// {
// alwaysAwait: true,
// // For jest-extended expect().pass
// minArgs: "off",
// },
// ],
"promise/no-callback-in-promise": "off",
},
},
];