@asd14/eslint-config 10.3.0 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +24 -177
  3. package/dist/types/eslint.config.d.ts +172 -0
  4. package/dist/types/src/configs/dev-files.d.ts +14 -0
  5. package/dist/types/src/configs/node-jest.d.ts +17 -0
  6. package/dist/types/src/configs/node.d.ts +248 -0
  7. package/dist/types/src/configs/react-jest.d.ts +20 -0
  8. package/dist/types/src/configs/react.d.ts +1519 -0
  9. package/dist/types/src/configs/ts-node.d.ts +290 -0
  10. package/dist/types/src/index.d.ts +6 -0
  11. package/dist/types/src/rules/base.d.ts +16 -0
  12. package/dist/types/src/rules/import-dev.d.ts +9 -0
  13. package/dist/types/src/rules/import.d.ts +44 -0
  14. package/dist/types/src/rules/jsdoc.d.ts +40 -0
  15. package/dist/types/src/rules/nx-dev.d.ts +13 -0
  16. package/dist/types/src/rules/nx.d.ts +45 -0
  17. package/dist/types/src/rules/react.d.ts +120 -0
  18. package/dist/types/src/rules/rtl.d.ts +13 -0
  19. package/dist/types/src/rules/typescript.d.ts +53 -0
  20. package/dist/types/src/rules/unicorn.d.ts +42 -0
  21. package/dist/types/src/utils/find-up-sync.d.ts +34 -0
  22. package/dist/types/tsconfig.tsbuildinfo +1 -0
  23. package/package.json +51 -67
  24. package/src/configs/dev-files.js +17 -0
  25. package/src/configs/node-jest.js +29 -0
  26. package/src/configs/node.js +68 -0
  27. package/src/configs/react-jest.js +16 -0
  28. package/src/configs/react.js +89 -0
  29. package/src/configs/ts-node.js +23 -0
  30. package/src/index.js +6 -0
  31. package/src/rules/base.js +24 -0
  32. package/src/rules/import-dev.js +31 -0
  33. package/src/rules/import.js +55 -0
  34. package/src/rules/jsdoc.js +49 -0
  35. package/src/rules/nx-dev.js +23 -0
  36. package/src/rules/nx.js +81 -0
  37. package/{rules → src/rules}/react.js +41 -27
  38. package/src/rules/rtl.js +6 -0
  39. package/src/rules/typescript.js +88 -0
  40. package/{rules → src/rules}/unicorn.js +19 -41
  41. package/src/utils/find-up-sync.js +56 -0
  42. package/rules/best-practices.js +0 -11
  43. package/rules/comments.js +0 -46
  44. package/rules/errors.js +0 -112
  45. package/rules/es6.js +0 -48
  46. package/rules/html.js +0 -59
  47. package/rules/import-ts.js +0 -41
  48. package/rules/import.js +0 -101
  49. package/rules/jsdoc-ts.js +0 -8
  50. package/rules/jsdoc.js +0 -103
  51. package/rules/json.js +0 -9
  52. package/rules/node.js +0 -56
  53. package/rules/prettier.js +0 -16
  54. package/rules/promise.js +0 -68
  55. package/rules/style.js +0 -252
  56. package/rules/variables.js +0 -70
  57. package/targets/node-esm.js +0 -25
  58. package/targets/node-ts.js +0 -36
  59. package/targets/node.js +0 -36
  60. package/targets/react-ts.js +0 -94
  61. package/targets/react.js +0 -90
@@ -0,0 +1,89 @@
1
+ import prettierConfig from "eslint-plugin-prettier/recommended"
2
+ import globals from "globals"
3
+
4
+ import baseConfig from "../rules/base.js"
5
+ import jsdocConfig from "../rules/jsdoc.js"
6
+ import unicornConfig from "../rules/unicorn.js"
7
+ import importConfig from "../rules/import.js"
8
+ import tsConfig from "../rules/typescript.js"
9
+ import nxConfig from "../rules/nx.js"
10
+ import reactHooksConfig from "../rules/react.js"
11
+
12
+ /** @type {import("eslint").Linter.RulesRecord} */
13
+ const reactSpecificRules = {
14
+ "no-console": "off",
15
+ "unicorn/prevent-abbreviations": [
16
+ "error",
17
+ {
18
+ replacements: {
19
+ i: false,
20
+ params: false,
21
+ lib: false,
22
+ args: {
23
+ params: true,
24
+ },
25
+ props: false,
26
+ opts: {
27
+ props: true,
28
+ },
29
+ options: {
30
+ props: true,
31
+ },
32
+ fn: false,
33
+ acc: false,
34
+ },
35
+ },
36
+ ],
37
+ }
38
+
39
+ /** @satisfies {import("eslint").Linter.Config} */
40
+ export const reactConfig = /** @type {const} */ ({
41
+ name: "ASD14 config for React source files",
42
+ ignores: ["node_modules", "dist", "coverage", "build"],
43
+ languageOptions: {
44
+ ...tsConfig.languageOptions,
45
+ ecmaVersion: "latest",
46
+ sourceType: "module",
47
+ parserOptions: {
48
+ projectService: true,
49
+ ecmaVersion: "latest",
50
+ ecmaFeatures: {
51
+ jsx: true,
52
+ },
53
+ },
54
+ globals: {
55
+ ...globals.serviceworker,
56
+ ...globals.browser,
57
+ },
58
+ },
59
+ plugins: {
60
+ ...importConfig.plugins,
61
+ ...jsdocConfig.plugins,
62
+ ...nxConfig.plugins,
63
+ ...reactHooksConfig.plugins,
64
+ ...tsConfig.plugins,
65
+ ...unicornConfig.plugins,
66
+ ...prettierConfig.plugins,
67
+ },
68
+ rules: {
69
+ ...baseConfig.rules,
70
+ ...importConfig.rules,
71
+ ...jsdocConfig.rules,
72
+ ...nxConfig.rules,
73
+ ...reactHooksConfig.rules,
74
+ ...reactSpecificRules,
75
+ ...tsConfig.rules,
76
+ ...unicornConfig.rules,
77
+ ...prettierConfig.rules,
78
+ },
79
+ settings: {
80
+ ...importConfig.settings,
81
+ ...reactHooksConfig.settings,
82
+
83
+ /*
84
+ * A list of regex strings that, if matched by a path, will not report
85
+ * the matching module if no exports are found.
86
+ */
87
+ "import/ignore": [".(sass|scss|less|css)$"],
88
+ },
89
+ })
@@ -0,0 +1,23 @@
1
+ import { nodeConfig } from "./node.js"
2
+ import tsConfig from "../rules/typescript.js"
3
+
4
+ /** @satisfies {import("eslint").Linter.Config} */
5
+ export const tsNodeConfig = /** @type {const} */ ({
6
+ name: "ASD14 config for Typescript + Node.js source files",
7
+ ignores: ["node_modules", "dist", "coverage", "build"],
8
+ languageOptions: {
9
+ ...nodeConfig.languageOptions,
10
+ ...tsConfig.languageOptions,
11
+ },
12
+ plugins: {
13
+ ...tsConfig.plugins,
14
+ ...nodeConfig.plugins,
15
+ },
16
+ rules: {
17
+ ...tsConfig.rules,
18
+ ...nodeConfig.rules,
19
+ },
20
+ settings: {
21
+ ...nodeConfig.settings,
22
+ },
23
+ })
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./configs/node.js"
2
+ export * from "./configs/ts-node.js"
3
+ export * from "./configs/node-jest.js"
4
+ export * from "./configs/react.js"
5
+ export * from "./configs/react-jest.js"
6
+ export * from "./configs/dev-files.js"
@@ -0,0 +1,24 @@
1
+ /** @satisfies {import("eslint").Linter.Config} */
2
+ export default /** @type {const} */ ({
3
+ rules: {
4
+ // Allow default named exports, ie. `export { asd as default } from "lorem.js"`,
5
+ // to avoid conflicts with "unicorn/prefer-export-from"
6
+ "no-restricted-exports": [
7
+ "error",
8
+ {
9
+ restrictDefaultExports: {
10
+ named: false,
11
+ namedFrom: false,
12
+ },
13
+ },
14
+ ],
15
+ "no-underscore-dangle": [
16
+ "error",
17
+ {
18
+ allow: ["_dirname", "_testResult"],
19
+ allowInArrayDestructuring: true,
20
+ allowInObjectDestructuring: true,
21
+ },
22
+ ],
23
+ },
24
+ })
@@ -0,0 +1,31 @@
1
+ import path from "node:path"
2
+ import { findUpSync } from "../utils/find-up-sync.js"
3
+
4
+ const MONOREPO_ROOT = path.dirname(findUpSync("nx.json"))
5
+
6
+ /** @satisfies {import("eslint").Linter.Config} */
7
+ export default /** @type {const} */ ({
8
+ files: [
9
+ "type-tests/**/*.{js,jsx,ts,tsx}",
10
+ "*.tt.{js,jsx,ts,tsx}",
11
+ "tests/**/*.{js,jsx,ts,tsx}",
12
+ "*.test.{js,jsx,ts,tsx}",
13
+ "stories/**/*.{js,jsx,ts,tsx}",
14
+ "*.stories.{js,jsx,ts,tsx}",
15
+ "eslint.config.js",
16
+ "jest.setup.js",
17
+ "jest.config.js",
18
+ ],
19
+ rules: {
20
+ /*
21
+ * Point to the monorepo root folder since ~all~ most devDependencies
22
+ * used in test, story and config files reside in the root package.json.
23
+ */
24
+ "import/no-extraneous-dependencies": [
25
+ "error",
26
+ {
27
+ packageDir: ["./", MONOREPO_ROOT],
28
+ },
29
+ ],
30
+ },
31
+ })
@@ -0,0 +1,55 @@
1
+ import importPlugin from "eslint-plugin-import"
2
+
3
+ const importConfig = importPlugin.flatConfigs.recommended
4
+ const importTSConfig = importPlugin.flatConfigs.typescript
5
+
6
+ /** @satisfies {import("eslint").Linter.Config} */
7
+ export default /** @type {const} */ ({
8
+ plugins: importConfig.plugins,
9
+ rules: {
10
+ ...importConfig.rules,
11
+ ...importTSConfig.rules,
12
+ "import/no-extraneous-dependencies": ["error", { includeTypes: true }],
13
+ "import/no-cycle": ["error", { maxDepth: Infinity }],
14
+ "import/no-self-import": "error",
15
+ "import/no-absolute-path": "error",
16
+ "import/default": "error",
17
+ "import/export": "error",
18
+ "import/prefer-default-export": "off",
19
+ "import/namespace": ["error", { allowComputed: true }],
20
+ "import/no-duplicates": "error",
21
+ "import/no-named-as-default": "error",
22
+ "import/no-named-as-default-member": "error",
23
+ "import/unambiguous": "off",
24
+ "import/exports-last": "error",
25
+ "import/named": "off",
26
+ "import/no-unresolved": "off",
27
+ "import/extensions": ["error", "always", { ignorePackages: true }],
28
+ "import/order": [
29
+ "error",
30
+ {
31
+ groups: [
32
+ "builtin",
33
+ "external",
34
+ "internal",
35
+ ["index", "sibling", "parent"],
36
+ "object",
37
+ "unknown",
38
+ ],
39
+ pathGroups: [
40
+ {
41
+ pattern: "@self-ui/*",
42
+ group: "external",
43
+ position: "after",
44
+ },
45
+ ],
46
+ pathGroupsExcludedImportTypes: ["builtin"],
47
+ alphabetize: {
48
+ order: "asc",
49
+ caseInsensitive: true,
50
+ },
51
+ },
52
+ ],
53
+ },
54
+ settings: importTSConfig.settings,
55
+ })
@@ -0,0 +1,49 @@
1
+ import jsdoc from "eslint-plugin-jsdoc"
2
+
3
+ /** @satisfies {import('eslint').Linter.Config} */
4
+ export default /** @type {const} */ ({
5
+ plugins: {
6
+ jsdoc,
7
+ },
8
+ rules: {
9
+ "jsdoc/sort-tags": [
10
+ "error",
11
+ {
12
+ reportIntraTagGroupSpacing: false,
13
+ reportTagGroupSpacing: false,
14
+ },
15
+ ],
16
+ "jsdoc/tag-lines": [
17
+ "error",
18
+ "always",
19
+ {
20
+ startLines: 1,
21
+ endLines: 0,
22
+ applyToEndTag: false,
23
+ tags: {
24
+ returns: {
25
+ lines: "always",
26
+ },
27
+ property: {
28
+ lines: "any",
29
+ },
30
+ param: {
31
+ lines: "any",
32
+ },
33
+ example: {
34
+ lines: "always",
35
+ },
36
+ },
37
+ },
38
+ ],
39
+ "jsdoc/check-indentation": "error",
40
+ "jsdoc/check-alignment": "error",
41
+ "jsdoc/no-bad-blocks": "error",
42
+ "jsdoc/require-asterisk-prefix": ["error", "always"],
43
+
44
+ "jsdoc/require-description": "off",
45
+ "jsdoc/require-property-description": "off",
46
+ "jsdoc/require-param-description": "off",
47
+ "jsdoc/require-returns-description": "off",
48
+ },
49
+ })
@@ -0,0 +1,23 @@
1
+ /** @satisfies {import("eslint").Linter.Config} */
2
+ export default /** @type {const} */ ({
3
+ /*
4
+ * Configuration files dont need any visibility restrictions since
5
+ * they are only for development and build purposes and are not
6
+ * emited in the final bundle/public artifacts.
7
+ */
8
+ files: ["jest.setup.{ts,js}", "jest.config.{ts,js}", "eslint.config.js"],
9
+ rules: {
10
+ "@nx/enforce-module-boundaries": [
11
+ "error",
12
+ {
13
+ allow: [],
14
+ depConstraints: [
15
+ {
16
+ sourceTag: "*",
17
+ onlyDependOnLibsWithTags: ["type:lib"],
18
+ },
19
+ ],
20
+ },
21
+ ],
22
+ },
23
+ })
@@ -0,0 +1,81 @@
1
+ import nxPlugin from "@nx/eslint-plugin"
2
+
3
+ const RULES = {
4
+ // Visibility and publishing rules
5
+ publicCanOnlyImportPublic: {
6
+ sourceTag: "npm:public",
7
+ onlyDependOnLibsWithTags: ["npm:public"],
8
+ },
9
+ privateCanImportAny: {
10
+ sourceTag: "npm:private",
11
+ onlyDependOnLibsWithTags: ["npm:public", "npm:private"],
12
+ },
13
+ // Package type rules
14
+ libsCanOnlyImportLibs: {
15
+ sourceTag: "type:lib",
16
+ onlyDependOnLibsWithTags: ["type:lib"],
17
+ },
18
+ hooksCanOnlyImportLibsAndHooks: {
19
+ sourceTag: "type:hook",
20
+ onlyDependOnLibsWithTags: ["type:lib", "type:hook"],
21
+ },
22
+ uiCanImportAny: {
23
+ sourceTag: "type:ui",
24
+ onlyDependOnLibsWithTags: ["type:ui", "type:lib", "type:hook"],
25
+ },
26
+ appsCanImportAny: {
27
+ sourceTag: "type:app",
28
+ onlyDependOnLibsWithTags: ["type:ui", "type:lib", "type:hook"],
29
+ },
30
+ // Runtime rules
31
+ apiCanOnlyImportApiOrNode: {
32
+ sourceTag: "runtime:api",
33
+ onlyDependOnLibsWithTags: ["runtime:api", "runtime:node"],
34
+ },
35
+ reactCanOnlyImportReactOrNode: {
36
+ sourceTag: "runtime:react",
37
+ onlyDependOnLibsWithTags: ["runtime:react", "runtime:node"],
38
+ },
39
+ nodeCanImportNode: {
40
+ sourceTag: "runtime:node",
41
+ onlyDependOnLibsWithTags: ["runtime:node"],
42
+ },
43
+ // Domain rules
44
+ domainCanOnlyImportSelf: {
45
+ sourceTag: "domain:*",
46
+ onlyDependOnLibsWithTags: ["domain:${tag}"],
47
+ },
48
+ // Prevent imports from test files in non-test files
49
+ noTestImportsInProd: {
50
+ sourceTag: "!test",
51
+ bannedExternalImports: ["**/*.spec.*", "**/*.test.*", "**/test-utils/**"],
52
+ },
53
+ }
54
+
55
+ /** @satisfies {import("eslint").Linter.Config} */
56
+ export default /** @type {const} */ ({
57
+ plugins: {
58
+ "@nx": nxPlugin,
59
+ },
60
+ rules: {
61
+ "@nx/enforce-module-boundaries": [
62
+ "error",
63
+ {
64
+ allow: [],
65
+ depConstraints: [
66
+ RULES.publicCanOnlyImportPublic,
67
+ RULES.privateCanImportAny,
68
+ RULES.libsCanOnlyImportLibs,
69
+ RULES.hooksCanOnlyImportLibsAndHooks,
70
+ RULES.uiCanImportAny,
71
+ RULES.appsCanImportAny,
72
+ RULES.apiCanOnlyImportApiOrNode,
73
+ RULES.reactCanOnlyImportReactOrNode,
74
+ RULES.nodeCanImportNode,
75
+ RULES.domainCanOnlyImportSelf,
76
+ RULES.noTestImportsInProd,
77
+ ],
78
+ },
79
+ ],
80
+ },
81
+ })
@@ -1,31 +1,29 @@
1
- module.exports = {
2
- plugins: ["react", "react-hooks"],
3
-
4
- /*
5
- * Disabled by prettier
6
- * https://github.com/prettier/eslint-config-prettier/blob/master/react.js
7
- *
8
- * "react/jsx-child-element-spacing": "off",
9
- * "react/jsx-closing-bracket-location": "off",
10
- * "react/jsx-closing-tag-location": "off",
11
- * "react/jsx-curly-spacing": "off",
12
- * "react/jsx-equals-spacing": "off",
13
- * "react/jsx-first-prop-new-line": "off",
14
- * "react/jsx-indent": "off",
15
- * "react/jsx-indent-props": "off",
16
- * "react/jsx-max-props-per-line": "off",
17
- * "react/jsx-one-expression-per-line": "off",
18
- * "react/jsx-props-no-multi-spaces": "off",
19
- * "react/jsx-space-before-closing": "off",
20
- * "react/jsx-tag-spacing": "off",
21
- * "react/jsx-wrap-multilines": "off"
22
- */
1
+ import reactPlugin from "eslint-plugin-react"
2
+ import reactHooksPlugin from "eslint-plugin-react-hooks"
3
+ import reactRefresh from "eslint-plugin-react-refresh"
4
+
5
+ const reactRecommendedConfig = /** @type {import("eslint").Linter.Config} */ (
6
+ reactPlugin.configs.flat?.["recommended"]
7
+ )
8
+
9
+ /** @satisfies {import("eslint").Linter.Config} */
10
+ export default /** @type {const} */ ({
11
+ plugins: {
12
+ ...reactRecommendedConfig.plugins,
13
+ "react-hooks": reactHooksPlugin,
14
+ "react-refresh": reactRefresh,
15
+ },
23
16
  rules: {
17
+ ...reactRecommendedConfig.rules,
18
+
19
+ // Validate that your components can safely be updated with Fast Refresh.
20
+ "react-refresh/only-export-components": "error",
21
+
24
22
  // Checks rules of Hooks
25
23
  "react-hooks/rules-of-hooks": "error",
26
24
 
27
25
  // Checks effect dependencies
28
- "react-hooks/exhaustive-deps": "warn",
26
+ "react-hooks/exhaustive-deps": "error",
29
27
 
30
28
  // Prevent missing displayName in a React component definition
31
29
  "react/display-name": "off",
@@ -144,11 +142,19 @@ module.exports = {
144
142
  // Prevent invalid characters from appearing in markup
145
143
  "react/no-unknown-property": "error",
146
144
 
145
+ "react/function-component-definition": [
146
+ "error",
147
+ {
148
+ namedComponents: "arrow-function",
149
+ unnamedComponents: "arrow-function",
150
+ },
151
+ ],
152
+
147
153
  // Prevent missing props validation in a React component definition
148
- "react/prop-types": "error",
154
+ "react/prop-types": "off",
149
155
 
150
156
  // Prevent missing React when using JSX
151
- "react/react-in-jsx-scope": "error",
157
+ "react/react-in-jsx-scope": "off",
152
158
 
153
159
  // Enforce ES5 or ES6 class for returning value in render function
154
160
  "react/require-render-return": "error",
@@ -183,7 +189,7 @@ module.exports = {
183
189
  * Declaring only one component per file improves readability and
184
190
  * reusability of components.
185
191
  */
186
- "react/no-multi-comp": "error",
192
+ "react/no-multi-comp": "off",
187
193
 
188
194
  /*
189
195
  * Updating the state after a component update will trigger a second
@@ -234,6 +240,7 @@ module.exports = {
234
240
  "react/require-default-props": [
235
241
  "error",
236
242
  {
243
+ functions: "defaultArguments",
237
244
  forbidDefaultForRequired: true,
238
245
  },
239
246
  ],
@@ -328,5 +335,12 @@ module.exports = {
328
335
 
329
336
  // Prevent usage of button elements without an explicit type attribute
330
337
  "react/button-has-type": "error",
338
+
339
+ "react/jsx-props-no-spreading": "off",
340
+ },
341
+ settings: {
342
+ react: {
343
+ version: "detect",
344
+ },
331
345
  },
332
- }
346
+ })
@@ -0,0 +1,6 @@
1
+ import rtlPlugin from "eslint-plugin-testing-library"
2
+
3
+ /** @satisfies {import('eslint').Linter.Config} */
4
+ export default /** @type {const} */ ({
5
+ ...rtlPlugin.configs["flat/react"],
6
+ })
@@ -0,0 +1,88 @@
1
+ import tsParser from "@typescript-eslint/parser"
2
+ import tsPlugin from "@typescript-eslint/eslint-plugin"
3
+
4
+ /** @satisfies {import("eslint").Linter.Config} */
5
+ export default /** @type {const} */ ({
6
+ languageOptions: {
7
+ parser: tsParser,
8
+ },
9
+ plugins: {
10
+ "@typescript-eslint": /** @type {any} */ (tsPlugin),
11
+ },
12
+ rules: {
13
+ ...tsPlugin.configs["strict-type-checked"]?.rules,
14
+
15
+ "@typescript-eslint/no-unused-vars": [
16
+ "error",
17
+ {
18
+ args: "all",
19
+ argsIgnorePattern: "^_",
20
+ caughtErrors: "all",
21
+ caughtErrorsIgnorePattern: "^_",
22
+ destructuredArrayIgnorePattern: "^_",
23
+ varsIgnorePattern: "^_",
24
+ ignoreRestSiblings: true,
25
+ },
26
+ ],
27
+
28
+ //
29
+ "@typescript-eslint/require-await": "warn",
30
+
31
+ // Conflicts with TypeScript's own error where accessing a property that
32
+ // doesn't exist on a type must be accessed with index notation.
33
+ "@typescript-eslint/dot-notation": "off",
34
+
35
+ "@typescript-eslint/restrict-template-expressions": [
36
+ "error",
37
+ {
38
+ allowBoolean: true,
39
+ allowNumber: true,
40
+ },
41
+ ],
42
+
43
+ "@typescript-eslint/no-var-requires": "off",
44
+ "@typescript-eslint/no-use-before-define": "error",
45
+
46
+ "@typescript-eslint/naming-convention": [
47
+ "error",
48
+ {
49
+ selector: "default",
50
+ leadingUnderscore: "allow",
51
+ format: ["camelCase", "PascalCase", "UPPER_CASE"],
52
+ },
53
+ {
54
+ selector: "variable",
55
+ types: ["boolean"],
56
+ format: ["camelCase", "PascalCase"],
57
+ prefix: ["is", "has", "can", "does", "should", "will", "did", "was"],
58
+ },
59
+ {
60
+ selector: "variable",
61
+ types: ["boolean", "number", "string", "array"],
62
+ modifiers: ["const", "global"],
63
+ format: ["UPPER_CASE"],
64
+ },
65
+ {
66
+ selector: "typeAlias",
67
+ format: ["PascalCase"],
68
+ },
69
+ {
70
+ selector: "typeParameter",
71
+ format: ["PascalCase"],
72
+ },
73
+ {
74
+ selector: [
75
+ "classProperty",
76
+ "objectLiteralProperty",
77
+ "typeProperty",
78
+ "classMethod",
79
+ "objectLiteralMethod",
80
+ "typeMethod",
81
+ "accessor",
82
+ "enumMember",
83
+ ],
84
+ format: [],
85
+ },
86
+ ],
87
+ },
88
+ })
@@ -1,40 +1,21 @@
1
- module.exports = {
2
- plugins: ["unicorn"],
1
+ import unicornPlugin from "eslint-plugin-unicorn"
3
2
 
4
- extends: "plugin:unicorn/recommended",
5
-
6
- /*
7
- * Disabled by prettier
8
- * https://github.com/prettier/eslint-config-prettier/blob/master/unicorn.js
9
- *
10
- * "unicorn/number-literal-case": "off"
11
- */
3
+ /** @satisfies {import('eslint').Linter.Config} */
4
+ export default /** @type {const} */ ({
5
+ ...unicornPlugin.configs["flat/recommended"],
12
6
  rules: {
13
- // Disable until node 16 is lts
14
- "unicorn/prefer-node-protocol": "off",
7
+ /*
8
+ * Disabled by prettier
9
+ * https://github.com/prettier/eslint-config-prettier/blob/master/unicorn.js
10
+ *
11
+ * "unicorn/number-literal-case": "off"
12
+ */
15
13
 
16
- "unicorn/prevent-abbreviations": [
17
- "error",
18
- {
19
- replacements: {
20
- i: false,
21
- params: false,
22
- lib: false,
23
- args: {
24
- params: true,
25
- },
26
- props: false,
27
- opts: {
28
- props: true,
29
- },
30
- source: {
31
- input: true,
32
- },
33
- fn: false,
34
- acc: false,
35
- },
36
- },
37
- ],
14
+ // Use "node:" protocol when importing Node.js builtin modules
15
+ "unicorn/prefer-node-protocol": "error",
16
+
17
+ // We like functional programming
18
+ "unicorn/no-array-for-each": "off",
38
19
 
39
20
  // Move function definitions to the highest possible scope.
40
21
  // Too noisy when curring functions
@@ -137,19 +118,16 @@ module.exports = {
137
118
  // Enforce throwing TypeError in type checking conditions
138
119
  "unicorn/prefer-type-error": "error",
139
120
 
121
+ // Cannot satisfy "consistent-return" with this rule enabled
122
+ "unicorn/no-useless-undefined": "off",
123
+
140
124
  /*
141
125
  * Enforce the use of new for all builtins, except String, Number and
142
126
  * Boolean
143
127
  */
144
128
  "unicorn/new-for-builtins": "error",
145
129
 
146
- /*
147
- * Disallow unsafe regular expressions. Uses safe-regex to disallow
148
- * potentially catastrophic exponential-time regular expressions.
149
- */
150
- "unicorn/no-unsafe-regex": "error",
151
-
152
130
  // Enforce passing a message value when throwing a built-in error
153
131
  "unicorn/error-message": "error",
154
132
  },
155
- }
133
+ })