@curev/eslint-config 0.2.1 → 0.3.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 (103) hide show
  1. package/.eslintignore +1 -0
  2. package/.github/workflows/release.yml +37 -0
  3. package/.vscode/settings.json +36 -0
  4. package/CHANGELOG.md +740 -0
  5. package/README.md +70 -0
  6. package/eslint.config.ts +3 -0
  7. package/fixtures/input/css.css +10 -0
  8. package/fixtures/input/html.html +17 -0
  9. package/fixtures/input/javascript.js +69 -0
  10. package/fixtures/input/jsx.jsx +27 -0
  11. package/fixtures/input/markdown.md +34 -0
  12. package/fixtures/input/svelte.svelte +8 -0
  13. package/fixtures/input/toml.toml +23 -0
  14. package/fixtures/input/tsx.tsx +32 -0
  15. package/fixtures/input/typescript.ts +84 -0
  16. package/fixtures/input/vue-ts.vue +35 -0
  17. package/fixtures/input/vue.vue +27 -0
  18. package/fixtures/output/all/javascript.js +72 -0
  19. package/fixtures/output/all/jsx.jsx +26 -0
  20. package/fixtures/output/all/markdown.md +33 -0
  21. package/fixtures/output/all/svelte.svelte +8 -0
  22. package/fixtures/output/all/toml.toml +23 -0
  23. package/fixtures/output/all/tsx.tsx +32 -0
  24. package/fixtures/output/all/typescript.ts +83 -0
  25. package/fixtures/output/all/vue-ts.vue +35 -0
  26. package/fixtures/output/all/vue.vue +24 -0
  27. package/fixtures/output/js/javascript.js +72 -0
  28. package/fixtures/output/js/markdown.md +33 -0
  29. package/fixtures/output/js/toml.toml +23 -0
  30. package/fixtures/output/no-markdown-with-formatters/javascript.js +72 -0
  31. package/fixtures/output/no-markdown-with-formatters/jsx.jsx +24 -0
  32. package/fixtures/output/no-markdown-with-formatters/markdown.md +33 -0
  33. package/fixtures/output/no-markdown-with-formatters/toml.toml +23 -0
  34. package/fixtures/output/no-markdown-with-formatters/tsx.tsx +23 -0
  35. package/fixtures/output/no-markdown-with-formatters/typescript.ts +83 -0
  36. package/fixtures/output/no-style/javascript.js +72 -0
  37. package/fixtures/output/no-style/jsx.jsx +21 -0
  38. package/fixtures/output/no-style/toml.toml +23 -0
  39. package/fixtures/output/no-style/typescript.ts +80 -0
  40. package/fixtures/output/no-style/vue-ts.vue +35 -0
  41. package/fixtures/output/no-style/vue.vue +24 -0
  42. package/fixtures/output/tab-double-quotes/javascript.js +72 -0
  43. package/fixtures/output/tab-double-quotes/jsx.jsx +26 -0
  44. package/fixtures/output/tab-double-quotes/markdown.md +33 -0
  45. package/fixtures/output/tab-double-quotes/toml.toml +23 -0
  46. package/fixtures/output/tab-double-quotes/tsx.tsx +32 -0
  47. package/fixtures/output/tab-double-quotes/typescript.ts +83 -0
  48. package/fixtures/output/tab-double-quotes/vue-ts.vue +35 -0
  49. package/fixtures/output/tab-double-quotes/vue.vue +24 -0
  50. package/fixtures/output/ts-override/javascript.js +72 -0
  51. package/fixtures/output/ts-override/jsx.jsx +26 -0
  52. package/fixtures/output/ts-override/markdown.md +33 -0
  53. package/fixtures/output/ts-override/toml.toml +23 -0
  54. package/fixtures/output/ts-override/tsx.tsx +32 -0
  55. package/fixtures/output/ts-override/typescript.ts +83 -0
  56. package/fixtures/output/ts-override/vue-ts.vue +35 -0
  57. package/fixtures/output/ts-override/vue.vue +24 -0
  58. package/fixtures/output/with-formatters/css.css +11 -0
  59. package/fixtures/output/with-formatters/html.html +28 -0
  60. package/fixtures/output/with-formatters/javascript.js +72 -0
  61. package/fixtures/output/with-formatters/jsx.jsx +26 -0
  62. package/fixtures/output/with-formatters/markdown.md +34 -0
  63. package/fixtures/output/with-formatters/toml.toml +23 -0
  64. package/fixtures/output/with-formatters/tsx.tsx +32 -0
  65. package/fixtures/output/with-formatters/typescript.ts +83 -0
  66. package/fixtures/output/with-formatters/vue-ts.vue +38 -0
  67. package/fixtures/output/with-formatters/vue.vue +24 -0
  68. package/package.json +130 -12
  69. package/src/configs/comments.ts +19 -0
  70. package/src/configs/formatters.ts +187 -0
  71. package/src/configs/ignores.ts +10 -0
  72. package/src/configs/imports.ts +46 -0
  73. package/src/configs/index.ts +21 -0
  74. package/src/configs/javascript.ts +277 -0
  75. package/src/configs/jsdoc.ts +41 -0
  76. package/src/configs/jsonc.ts +86 -0
  77. package/src/configs/markdown.ts +110 -0
  78. package/src/configs/node.ts +24 -0
  79. package/src/configs/perfectionist.ts +18 -0
  80. package/src/configs/react.ts +111 -0
  81. package/src/configs/sort.ts +223 -0
  82. package/src/configs/stylistic.ts +52 -0
  83. package/src/configs/svelte.ts +107 -0
  84. package/src/configs/test.ts +54 -0
  85. package/src/configs/toml.ts +72 -0
  86. package/src/configs/typescript.ts +171 -0
  87. package/src/configs/unicorn.ts +41 -0
  88. package/src/configs/unocss.ts +43 -0
  89. package/src/configs/vue.ts +170 -0
  90. package/src/configs/yaml.ts +72 -0
  91. package/src/factory.ts +255 -0
  92. package/src/globs.ts +81 -0
  93. package/src/index.ts +9 -0
  94. package/src/plugins.ts +10 -0
  95. package/src/stub.d.ts +3 -0
  96. package/src/types.ts +364 -0
  97. package/src/utils.ts +76 -0
  98. package/src/vender/prettier-types.ts +136 -0
  99. package/test/cli.spec.ts +90 -0
  100. package/test/fixtures.test.ts +127 -0
  101. package/tsconfig.json +17 -0
  102. package/tsup.config.ts +8 -0
  103. package/index.js +0 -5
@@ -0,0 +1,187 @@
1
+ import { GLOB_CSS, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS } from "../globs";
2
+ import type { VendoredPrettierOptions } from "../vender/prettier-types";
3
+ import { ensurePackages, interopDefault, parserPlain } from "../utils";
4
+ import type { FlatConfigItem, OptionsFormatters, StylisticConfig } from "../types";
5
+ import { StylisticConfigDefaults } from "./stylistic";
6
+
7
+ export async function formatters(
8
+ options: OptionsFormatters | true = {},
9
+ stylistic: StylisticConfig = {}
10
+ ): Promise<FlatConfigItem[]> {
11
+ await ensurePackages([
12
+ "eslint-plugin-format"
13
+ ]);
14
+
15
+ if (options === true) {
16
+ options = {
17
+ css: true,
18
+ graphql: true,
19
+ html: true,
20
+ markdown: true
21
+ };
22
+ }
23
+
24
+ const {
25
+ indent,
26
+ quotes,
27
+ semi
28
+ } = {
29
+ ...StylisticConfigDefaults,
30
+ ...stylistic
31
+ };
32
+
33
+ const prettierOptions: VendoredPrettierOptions = Object.assign(
34
+ {
35
+ endOfLine: "auto",
36
+ semi,
37
+ singleQuote: quotes === "single",
38
+ tabWidth: typeof indent === "number" ? indent : 2,
39
+ trailingComma: "all",
40
+ useTabs: indent === "tab"
41
+ } satisfies VendoredPrettierOptions,
42
+ options.prettierOptions || {}
43
+ );
44
+
45
+ const dprintOptions = Object.assign(
46
+ {
47
+ indentWidth: typeof indent === "number" ? indent : 2,
48
+ quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
49
+ useTabs: indent === "tab"
50
+ },
51
+ options.dprintOptions || {}
52
+ );
53
+
54
+ const pluginFormat = await interopDefault(import("eslint-plugin-format"));
55
+
56
+ const configs: FlatConfigItem[] = [
57
+ {
58
+ name: "curev:formatters:setup",
59
+ plugins: {
60
+ format: pluginFormat
61
+ }
62
+ }
63
+ ];
64
+
65
+ if (options.css) {
66
+ configs.push(
67
+ {
68
+ files: [GLOB_CSS, GLOB_POSTCSS],
69
+ languageOptions: {
70
+ parser: parserPlain
71
+ },
72
+ name: "curev:formatter:css",
73
+ rules: {
74
+ "format/prettier": [
75
+ "error",
76
+ {
77
+ ...prettierOptions,
78
+ parser: "css"
79
+ }
80
+ ]
81
+ }
82
+ },
83
+ {
84
+ files: [GLOB_SCSS],
85
+ languageOptions: {
86
+ parser: parserPlain
87
+ },
88
+ name: "curev:formatter:scss",
89
+ rules: {
90
+ "format/prettier": [
91
+ "error",
92
+ {
93
+ ...prettierOptions,
94
+ parser: "scss"
95
+ }
96
+ ]
97
+ }
98
+ },
99
+ {
100
+ files: [GLOB_LESS],
101
+ languageOptions: {
102
+ parser: parserPlain
103
+ },
104
+ name: "curev:formatter:less",
105
+ rules: {
106
+ "format/prettier": [
107
+ "error",
108
+ {
109
+ ...prettierOptions,
110
+ parser: "less"
111
+ }
112
+ ]
113
+ }
114
+ }
115
+ );
116
+ }
117
+
118
+ if (options.html) {
119
+ configs.push({
120
+ files: ["**/*.html"],
121
+ languageOptions: {
122
+ parser: parserPlain
123
+ },
124
+ name: "curev:formatter:html",
125
+ rules: {
126
+ "format/prettier": [
127
+ "error",
128
+ {
129
+ ...prettierOptions,
130
+ parser: "html"
131
+ }
132
+ ]
133
+ }
134
+ });
135
+ }
136
+
137
+ if (options.markdown) {
138
+ const formater = options.markdown === true
139
+ ? "prettier"
140
+ : options.markdown;
141
+
142
+ configs.push({
143
+ files: [GLOB_MARKDOWN],
144
+ languageOptions: {
145
+ parser: parserPlain
146
+ },
147
+ name: "curev:formatter:markdown",
148
+ rules: {
149
+ [`format/${formater}`]: [
150
+ "error",
151
+ formater === "prettier"
152
+ ? {
153
+ printWidth: 120,
154
+ ...prettierOptions,
155
+ embeddedLanguageFormatting: "off",
156
+ parser: "markdown"
157
+ }
158
+ : {
159
+ ...dprintOptions,
160
+ language: "markdown"
161
+ }
162
+ ]
163
+ }
164
+ });
165
+ }
166
+
167
+ if (options.graphql) {
168
+ configs.push({
169
+ files: ["**/*.graphql"],
170
+ languageOptions: {
171
+ parser: parserPlain
172
+ },
173
+ name: "curev:formatter:graphql",
174
+ rules: {
175
+ "format/prettier": [
176
+ "error",
177
+ {
178
+ ...prettierOptions,
179
+ parser: "graphql"
180
+ }
181
+ ]
182
+ }
183
+ });
184
+ }
185
+
186
+ return configs;
187
+ }
@@ -0,0 +1,10 @@
1
+ import type { FlatConfigItem } from "../types";
2
+ import { GLOB_EXCLUDE } from "../globs";
3
+
4
+ export async function ignores(): Promise<FlatConfigItem[]> {
5
+ return [
6
+ {
7
+ ignores: GLOB_EXCLUDE
8
+ }
9
+ ];
10
+ }
@@ -0,0 +1,46 @@
1
+ import type { FlatConfigItem, OptionsStylistic } from "../types";
2
+ import { pluginAntfu, pluginImport } from "../plugins";
3
+ import { GLOB_SRC_EXT } from "../globs";
4
+
5
+ export async function imports(options: OptionsStylistic = {}): Promise<FlatConfigItem[]> {
6
+ const {
7
+ stylistic = true
8
+ } = options;
9
+
10
+ return [
11
+ {
12
+ name: "curev:imports",
13
+ plugins: {
14
+ curev: pluginAntfu,
15
+ import: pluginImport
16
+ },
17
+ rules: {
18
+ "antfu/import-dedupe": "error",
19
+ "antfu/no-import-dist": "error",
20
+ "antfu/no-import-node-modules-by-path": "error",
21
+
22
+ "import/first": "error",
23
+ "import/no-duplicates": "error",
24
+ "import/no-mutable-exports": "error",
25
+ "import/no-named-default": "error",
26
+ "import/no-self-import": "error",
27
+ "import/no-webpack-loader-syntax": "error",
28
+ "import/order": "error",
29
+
30
+ ...stylistic
31
+ ? {
32
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
33
+ }
34
+ : {}
35
+ }
36
+ },
37
+ {
38
+ files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
39
+ name: "curev:imports:bin",
40
+ rules: {
41
+ "antfu/no-import-dist": "off",
42
+ "antfu/no-import-node-modules-by-path": "off"
43
+ }
44
+ }
45
+ ];
46
+ }
@@ -0,0 +1,21 @@
1
+ export * from "./comments";
2
+ export * from "./ignores";
3
+ export * from "./imports";
4
+ export * from "./javascript";
5
+ export * from "./jsdoc";
6
+ export * from "./jsonc";
7
+ export * from "./markdown";
8
+ export * from "./node";
9
+ export * from "./perfectionist";
10
+ export * from "./formatters";
11
+ export * from "./react";
12
+ export * from "./sort";
13
+ export * from "./stylistic";
14
+ export * from "./svelte";
15
+ export * from "./test";
16
+ export * from "./typescript";
17
+ export * from "./unicorn";
18
+ export * from "./unocss";
19
+ export * from "./vue";
20
+ export * from "./yaml";
21
+ export * from "./toml";
@@ -0,0 +1,277 @@
1
+ import globals from "globals";
2
+ import type { FlatConfigItem, OptionsIsInEditor, OptionsOverrides } from "../types";
3
+ import { pluginAntfu, pluginUnusedImports } from "../plugins";
4
+ import { GLOB_SRC, GLOB_SRC_EXT } from "../globs";
5
+
6
+ export async function javascript(
7
+ options: OptionsIsInEditor & OptionsOverrides = {}
8
+ ): Promise<FlatConfigItem[]> {
9
+ const {
10
+ isInEditor = false,
11
+ overrides = {}
12
+ } = options;
13
+
14
+ return [
15
+ {
16
+ languageOptions: {
17
+ ecmaVersion: 2022,
18
+ globals: {
19
+ ...globals.browser,
20
+ ...globals.es2021,
21
+ ...globals.node,
22
+ document: "readonly",
23
+ navigator: "readonly",
24
+ window: "readonly"
25
+ },
26
+ parserOptions: {
27
+ ecmaFeatures: {
28
+ jsx: true
29
+ },
30
+ ecmaVersion: 2022,
31
+ sourceType: "module"
32
+ },
33
+ sourceType: "module"
34
+ },
35
+ linterOptions: {
36
+ reportUnusedDisableDirectives: true
37
+ },
38
+ name: "curev:javascript",
39
+ plugins: {
40
+ "antfu": pluginAntfu,
41
+ "unused-imports": pluginUnusedImports
42
+ },
43
+ rules: {
44
+ "no-var": "warn",
45
+ "object-shorthand": ["warn", "properties"],
46
+
47
+ "accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
48
+ "array-callback-return": ["error", {
49
+ allowImplicit: false,
50
+ checkForEach: false
51
+ }],
52
+ "camelcase": ["error", {
53
+ allow: ["^UNSAFE_"],
54
+ properties: "never",
55
+ ignoreGlobals: true,
56
+ ignoreImports: true
57
+ }],
58
+ "constructor-super": "error",
59
+ "default-case-last": "error",
60
+ "eol-last": "error",
61
+ "eqeqeq": ["error", "always", { null: "ignore" }],
62
+ "func-call-spacing": ["error", "never"],
63
+ "generator-star-spacing": ["error", { before: true, after: true }],
64
+ "lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
65
+ "multiline-ternary": ["error", "always-multiline"],
66
+ "new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
67
+ "new-parens": "error",
68
+ "no-array-constructor": "error",
69
+ "no-async-promise-executor": "error",
70
+ "no-caller": "error",
71
+ "no-case-declarations": "error",
72
+ "no-class-assign": "error",
73
+ "no-compare-neg-zero": "error",
74
+ "no-cond-assign": "error",
75
+ "no-const-assign": "error",
76
+ "no-constant-condition": ["error", { checkLoops: false }],
77
+ "no-control-regex": "error",
78
+ "no-debugger": "error",
79
+ "no-delete-var": "error",
80
+ "no-dupe-args": "error",
81
+ "no-dupe-class-members": "error",
82
+ "no-dupe-keys": "error",
83
+ "no-duplicate-case": "error",
84
+ "no-useless-backreference": "error",
85
+ "no-empty": ["error", { allowEmptyCatch: true }],
86
+ "no-empty-character-class": "error",
87
+ "no-empty-pattern": "error",
88
+ "no-eval": "error",
89
+ "no-ex-assign": "error",
90
+ "no-extend-native": "error",
91
+ "no-extra-bind": "error",
92
+ "no-extra-boolean-cast": "error",
93
+ "no-extra-parens": ["error", "functions"],
94
+ "no-fallthrough": "error",
95
+ "no-floating-decimal": "error",
96
+ "no-func-assign": "error",
97
+ "no-global-assign": "error",
98
+ "no-implied-eval": "error",
99
+ "no-import-assign": "error",
100
+ "no-invalid-regexp": "error",
101
+ "no-irregular-whitespace": "error",
102
+ "no-iterator": "error",
103
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
104
+ "no-lone-blocks": "error",
105
+ "no-loss-of-precision": "error",
106
+ "no-misleading-character-class": "error",
107
+ "no-prototype-builtins": "error",
108
+ "no-useless-catch": "error",
109
+ "no-mixed-operators": ["error", {
110
+ groups: [
111
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
112
+ ["&&", "||"],
113
+ ["in", "instanceof"]
114
+ ],
115
+ allowSamePrecedence: true
116
+ }],
117
+ "no-mixed-spaces-and-tabs": "error",
118
+ "no-multi-spaces": "error",
119
+ "no-multi-str": "error",
120
+ "no-new": "error",
121
+ "no-new-func": "error",
122
+ "no-new-object": "error",
123
+ "no-new-symbol": "error",
124
+ "no-new-wrappers": "error",
125
+ "no-obj-calls": "error",
126
+ "no-octal": "error",
127
+ "no-octal-escape": "error",
128
+ "no-proto": "error",
129
+ "no-redeclare": ["error", { builtinGlobals: false }],
130
+ "no-regex-spaces": "error",
131
+ "no-return-assign": ["error", "except-parens"],
132
+ "no-self-assign": ["error", { props: true }],
133
+ "no-self-compare": "error",
134
+ "no-sequences": "error",
135
+ "no-shadow-restricted-names": "error",
136
+ "no-sparse-arrays": "error",
137
+ "no-tabs": "error",
138
+ "no-template-curly-in-string": "error",
139
+ "no-this-before-super": "error",
140
+ "no-throw-literal": "error",
141
+ "no-trailing-spaces": [
142
+ "error",
143
+ {
144
+ skipBlankLines: true
145
+ }
146
+ ],
147
+ "no-multiple-empty-lines": [
148
+ "error",
149
+ {
150
+ max: 3,
151
+ maxBOF: 0,
152
+ maxEOF: 1
153
+ }
154
+ ],
155
+ "no-undef": "error",
156
+ "no-undef-init": "error",
157
+ "no-unexpected-multiline": "error",
158
+ "no-unmodified-loop-condition": "error",
159
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
160
+ "no-unreachable": "error",
161
+ "no-unreachable-loop": "error",
162
+ "no-unsafe-finally": "error",
163
+ "no-unsafe-negation": "error",
164
+ "no-unused-expressions": ["error", {
165
+ allowShortCircuit: true,
166
+ allowTernary: true,
167
+ allowTaggedTemplates: true
168
+ }],
169
+ "no-unused-vars": ["error", {
170
+ args: "none",
171
+ caughtErrors: "none",
172
+ ignoreRestSiblings: true,
173
+ vars: "all"
174
+ }],
175
+ "no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
176
+ "no-useless-call": "error",
177
+ "no-useless-computed-key": "error",
178
+ "no-useless-constructor": "error",
179
+ "no-useless-escape": "error",
180
+ "no-useless-rename": "error",
181
+ "no-useless-return": "error",
182
+ "no-void": "error",
183
+ "no-with": "error",
184
+ "object-curly-newline": ["error", { multiline: true, consistent: true }],
185
+ "object-curly-spacing": ["error", "always"],
186
+ "object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
187
+ "one-var": ["error", { initialized: "never" }],
188
+ "padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
189
+ "prefer-const": ["error", { destructuring: "all" }],
190
+ "prefer-promise-reject-errors": "error",
191
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
192
+ "rest-spread-spacing": ["error", "never"],
193
+ "symbol-description": "error",
194
+ "template-curly-spacing": ["error", "never"],
195
+ "template-tag-spacing": ["error", "never"],
196
+ "unicode-bom": ["error", "never"],
197
+ "use-isnan": ["error", {
198
+ enforceForSwitchCase: true,
199
+ enforceForIndexOf: true
200
+ }],
201
+ "valid-typeof": ["error", { requireStringLiterals: true }],
202
+ "wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
203
+ "yield-star-spacing": ["error", "both"],
204
+ "yoda": ["error", "never"],
205
+
206
+ "import/export": "error",
207
+ "import/first": "error",
208
+ "import/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
209
+ "import/no-duplicates": "error",
210
+ "import/no-named-default": "error",
211
+ "import/no-webpack-loader-syntax": "error",
212
+
213
+ "block-scoped-var": "error",
214
+ "no-alert": "error",
215
+ "no-console": ["error", { allow: ["warn", "error"] }],
216
+ "no-restricted-globals": [
217
+ "error",
218
+ { message: "Use `globalThis` instead.", name: "global" },
219
+ { message: "Use `globalThis` instead.", name: "self" }
220
+ ],
221
+ "no-restricted-properties": [
222
+ "error",
223
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
224
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
225
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
226
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
227
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
228
+ ],
229
+ "no-restricted-syntax": [
230
+ "error",
231
+ "DebuggerStatement",
232
+ "LabeledStatement",
233
+ "WithStatement",
234
+ "TSEnumDeclaration[const=true]",
235
+ "TSExportAssignment"
236
+ ],
237
+ "prefer-arrow-callback": [
238
+ "error",
239
+ {
240
+ allowNamedFunctions: false,
241
+ allowUnboundThis: true
242
+ }
243
+ ],
244
+ "prefer-exponentiation-operator": "error",
245
+ "prefer-rest-params": "error",
246
+ "prefer-spread": "error",
247
+ "prefer-template": "error",
248
+ "sort-imports": [
249
+ "error",
250
+ {
251
+ allowSeparatedGroups: false,
252
+ ignoreCase: false,
253
+ ignoreDeclarationSort: true,
254
+ ignoreMemberSort: false,
255
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
256
+ }
257
+ ],
258
+
259
+ "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
260
+
261
+ "unused-imports/no-unused-vars": [
262
+ "error",
263
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
264
+ ],
265
+ "vars-on-top": "error",
266
+ ...overrides
267
+ }
268
+ },
269
+ {
270
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
271
+ name: "curev:scripts-overrides",
272
+ rules: {
273
+ "no-console": "off"
274
+ }
275
+ }
276
+ ];
277
+ }
@@ -0,0 +1,41 @@
1
+ import { interopDefault } from "../utils";
2
+ import type { FlatConfigItem, OptionsStylistic } from "../types";
3
+
4
+ export async function jsdoc(options: OptionsStylistic = {}): Promise<FlatConfigItem[]> {
5
+ const {
6
+ stylistic = true
7
+ } = options;
8
+
9
+ return [
10
+ {
11
+ name: "curev:jsdoc",
12
+ plugins: {
13
+ jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
14
+ },
15
+ rules: {
16
+ "jsdoc/check-access": "warn",
17
+ "jsdoc/check-param-names": "warn",
18
+ "jsdoc/check-property-names": "warn",
19
+ "jsdoc/check-types": "warn",
20
+ "jsdoc/empty-tags": "warn",
21
+ "jsdoc/implements-on-classes": "warn",
22
+ "jsdoc/no-defaults": "warn",
23
+ "jsdoc/no-multi-asterisks": "warn",
24
+ "jsdoc/require-param-name": "warn",
25
+ "jsdoc/require-property": "warn",
26
+ "jsdoc/require-property-description": "warn",
27
+ "jsdoc/require-property-name": "warn",
28
+ "jsdoc/require-returns-check": "warn",
29
+ "jsdoc/require-returns-description": "warn",
30
+ "jsdoc/require-yields-check": "warn",
31
+
32
+ ...stylistic
33
+ ? {
34
+ "jsdoc/check-alignment": "warn",
35
+ "jsdoc/multiline-blocks": "warn"
36
+ }
37
+ : {}
38
+ }
39
+ }
40
+ ];
41
+ }
@@ -0,0 +1,86 @@
1
+ import type { FlatConfigItem, OptionsFiles, OptionsOverrides, OptionsStylistic } from "../types";
2
+ import { GLOB_JSON, GLOB_JSON5, GLOB_JSONC } from "../globs";
3
+ import { interopDefault } from "../utils";
4
+
5
+ export async function jsonc(
6
+ options: OptionsFiles & OptionsStylistic & OptionsOverrides = {}
7
+ ): Promise<FlatConfigItem[]> {
8
+ const {
9
+ files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
10
+ overrides = {},
11
+ stylistic = true
12
+ } = options;
13
+
14
+ const {
15
+ indent = 2
16
+ } = typeof stylistic === "boolean" ? {} : stylistic;
17
+
18
+ const [
19
+ pluginJsonc,
20
+ parserJsonc
21
+ ] = await Promise.all([
22
+ interopDefault(import("eslint-plugin-jsonc")),
23
+ interopDefault(import("jsonc-eslint-parser"))
24
+ ] as const);
25
+
26
+ return [
27
+ {
28
+ name: "curev:jsonc:setup",
29
+ plugins: {
30
+ jsonc: pluginJsonc as any
31
+ }
32
+ },
33
+ {
34
+ files,
35
+ languageOptions: {
36
+ parser: parserJsonc
37
+ },
38
+ name: "curev:jsonc:rules",
39
+ rules: {
40
+ "jsonc/no-bigint-literals": "error",
41
+ "jsonc/no-binary-expression": "error",
42
+ "jsonc/no-binary-numeric-literals": "error",
43
+ "jsonc/no-dupe-keys": "error",
44
+ "jsonc/no-escape-sequence-in-identifier": "error",
45
+ "jsonc/no-floating-decimal": "error",
46
+ "jsonc/no-hexadecimal-numeric-literals": "error",
47
+ "jsonc/no-infinity": "error",
48
+ "jsonc/no-multi-str": "error",
49
+ "jsonc/no-nan": "error",
50
+ "jsonc/no-number-props": "error",
51
+ "jsonc/no-numeric-separators": "error",
52
+ "jsonc/no-octal": "error",
53
+ "jsonc/no-octal-escape": "error",
54
+ "jsonc/no-octal-numeric-literals": "error",
55
+ "jsonc/no-parenthesized": "error",
56
+ "jsonc/no-plus-sign": "error",
57
+ "jsonc/no-regexp-literals": "error",
58
+ "jsonc/no-sparse-arrays": "error",
59
+ "jsonc/no-template-literals": "error",
60
+ "jsonc/no-undefined-value": "error",
61
+ "jsonc/no-unicode-codepoint-escapes": "error",
62
+ "jsonc/no-useless-escape": "error",
63
+ "jsonc/space-unary-ops": "error",
64
+ "jsonc/valid-json-number": "error",
65
+ "jsonc/vue-custom-block/no-parsing-error": "error",
66
+
67
+ ...stylistic
68
+ ? {
69
+ "jsonc/array-bracket-spacing": ["error", "never"],
70
+ "jsonc/comma-dangle": ["error", "never"],
71
+ "jsonc/comma-style": ["error", "last"],
72
+ "jsonc/indent": ["error", indent],
73
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
74
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
75
+ "jsonc/object-curly-spacing": ["error", "always"],
76
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
77
+ "jsonc/quote-props": "error",
78
+ "jsonc/quotes": "error"
79
+ }
80
+ : {},
81
+
82
+ ...overrides
83
+ }
84
+ }
85
+ ];
86
+ }