@kikiutils/eslint-config 11.2.1 → 11.4.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 (94) hide show
  1. package/dist/_internals/configs/base-rules.d.ts +3 -0
  2. package/dist/_internals/configs/base-rules.d.ts.map +1 -0
  3. package/dist/_internals/configs/base-rules.js +190 -0
  4. package/dist/_internals/configs/base-rules.js.map +1 -0
  5. package/dist/_internals/configs/jsdoc.d.ts.map +1 -0
  6. package/dist/_internals/{jsdoc.js → configs/jsdoc.js} +1 -1
  7. package/dist/_internals/configs/jsdoc.js.map +1 -0
  8. package/dist/_internals/configs/restricted-syntax.d.ts.map +1 -0
  9. package/dist/_internals/configs/restricted-syntax.js +12 -0
  10. package/dist/_internals/configs/restricted-syntax.js.map +1 -0
  11. package/dist/_internals/configs/type-aware.d.ts.map +1 -0
  12. package/dist/_internals/configs/type-aware.js +48 -0
  13. package/dist/_internals/configs/type-aware.js.map +1 -0
  14. package/dist/_internals/configs/typefest.d.ts.map +1 -0
  15. package/dist/_internals/{typefest.js → configs/typefest.js} +1 -1
  16. package/dist/_internals/configs/typefest.js.map +1 -0
  17. package/dist/_internals/rules/comment-indent.d.ts +3 -0
  18. package/dist/_internals/rules/comment-indent.d.ts.map +1 -0
  19. package/dist/_internals/rules/comment-indent.js +58 -0
  20. package/dist/_internals/rules/comment-indent.js.map +1 -0
  21. package/dist/_internals/rules/index.d.ts +19 -0
  22. package/dist/_internals/rules/index.d.ts.map +1 -0
  23. package/dist/_internals/rules/index.js +34 -0
  24. package/dist/_internals/rules/index.js.map +1 -0
  25. package/dist/_internals/rules/nitro-route-method-suffix.d.ts +3 -0
  26. package/dist/_internals/rules/nitro-route-method-suffix.d.ts.map +1 -0
  27. package/dist/_internals/rules/nitro-route-method-suffix.js +25 -0
  28. package/dist/_internals/rules/nitro-route-method-suffix.js.map +1 -0
  29. package/dist/_internals/rules/no-composable-in-head-getter.d.ts +3 -0
  30. package/dist/_internals/rules/no-composable-in-head-getter.d.ts.map +1 -0
  31. package/dist/_internals/rules/no-composable-in-head-getter.js +41 -0
  32. package/dist/_internals/rules/no-composable-in-head-getter.js.map +1 -0
  33. package/dist/_internals/rules/no-silent-catch.d.ts +3 -0
  34. package/dist/_internals/rules/no-silent-catch.d.ts.map +1 -0
  35. package/dist/_internals/rules/no-silent-catch.js +38 -0
  36. package/dist/_internals/rules/no-silent-catch.js.map +1 -0
  37. package/dist/_internals/rules/no-thenable-zod-refinement.d.ts +3 -0
  38. package/dist/_internals/rules/no-thenable-zod-refinement.d.ts.map +1 -0
  39. package/dist/_internals/rules/no-thenable-zod-refinement.js +41 -0
  40. package/dist/_internals/rules/no-thenable-zod-refinement.js.map +1 -0
  41. package/dist/_internals/rules/promise-function-async.d.ts +3 -0
  42. package/dist/_internals/rules/promise-function-async.d.ts.map +1 -0
  43. package/dist/_internals/rules/promise-function-async.js +32 -0
  44. package/dist/_internals/rules/promise-function-async.js.map +1 -0
  45. package/dist/_internals/rules/statement-padding.js +2 -1
  46. package/dist/_internals/rules/statement-padding.js.map +1 -1
  47. package/dist/base.d.ts +3 -2
  48. package/dist/base.d.ts.map +1 -1
  49. package/dist/base.js +6 -183
  50. package/dist/base.js.map +1 -1
  51. package/dist/nuxt.d.ts +3 -0
  52. package/dist/nuxt.d.ts.map +1 -0
  53. package/dist/nuxt.js +94 -0
  54. package/dist/nuxt.js.map +1 -0
  55. package/dist/vue.d.ts.map +1 -1
  56. package/dist/vue.js +11 -14
  57. package/dist/vue.js.map +1 -1
  58. package/package.json +8 -6
  59. package/src/_internals/configs/base-rules.ts +335 -0
  60. package/src/_internals/{restricted-syntax.ts → configs/restricted-syntax.ts} +0 -4
  61. package/src/_internals/configs/type-aware.ts +70 -0
  62. package/src/_internals/rules/comment-indent.ts +87 -0
  63. package/src/_internals/rules/index.ts +38 -0
  64. package/src/_internals/rules/nitro-route-method-suffix.ts +27 -0
  65. package/src/_internals/rules/no-composable-in-head-getter.ts +52 -0
  66. package/src/_internals/rules/no-silent-catch.ts +58 -0
  67. package/src/_internals/rules/no-thenable-zod-refinement.ts +70 -0
  68. package/src/_internals/rules/promise-function-async.ts +56 -0
  69. package/src/_internals/rules/statement-padding.ts +1 -0
  70. package/src/base.ts +9 -334
  71. package/src/nuxt.ts +131 -0
  72. package/src/vue.ts +11 -14
  73. package/dist/_internals/jsdoc.d.ts.map +0 -1
  74. package/dist/_internals/jsdoc.js.map +0 -1
  75. package/dist/_internals/plugins.d.ts +0 -9
  76. package/dist/_internals/plugins.d.ts.map +0 -1
  77. package/dist/_internals/plugins.js +0 -14
  78. package/dist/_internals/plugins.js.map +0 -1
  79. package/dist/_internals/restricted-syntax.d.ts.map +0 -1
  80. package/dist/_internals/restricted-syntax.js +0 -16
  81. package/dist/_internals/restricted-syntax.js.map +0 -1
  82. package/dist/_internals/type-aware.d.ts.map +0 -1
  83. package/dist/_internals/type-aware.js +0 -29
  84. package/dist/_internals/type-aware.js.map +0 -1
  85. package/dist/_internals/typefest.d.ts.map +0 -1
  86. package/dist/_internals/typefest.js.map +0 -1
  87. package/src/_internals/plugins.ts +0 -13
  88. package/src/_internals/type-aware.ts +0 -42
  89. /package/dist/_internals/{jsdoc.d.ts → configs/jsdoc.d.ts} +0 -0
  90. /package/dist/_internals/{restricted-syntax.d.ts → configs/restricted-syntax.d.ts} +0 -0
  91. /package/dist/_internals/{type-aware.d.ts → configs/type-aware.d.ts} +0 -0
  92. /package/dist/_internals/{typefest.d.ts → configs/typefest.d.ts} +0 -0
  93. /package/src/_internals/{jsdoc.ts → configs/jsdoc.ts} +0 -0
  94. /package/src/_internals/{typefest.ts → configs/typefest.ts} +0 -0
@@ -0,0 +1,38 @@
1
+ import { builtinRules } from 'eslint/use-at-your-own-risk';
2
+
3
+ import { commentIndent } from './comment-indent';
4
+ import { compactIterationLayout } from './compact-iteration-layout';
5
+ import { consistentConditionLayout } from './consistent-condition-layout';
6
+ import { consistentParameterLayout } from './consistent-parameter-layout';
7
+ import { nitroRouteMethodSuffix } from './nitro-route-method-suffix';
8
+ import { noComposableInHeadGetter } from './no-composable-in-head-getter';
9
+ import { noSilentCatch } from './no-silent-catch';
10
+ import { noThenableZodRefinement } from './no-thenable-zod-refinement';
11
+ import { promiseFunctionAsync } from './promise-function-async';
12
+ import { statementPadding } from './statement-padding';
13
+
14
+ // Each scope adds its restrictions under its own name: a later config replaces a rule's whole option list,
15
+ // so sharing the core rule would drop the restrictions of every broader scope.
16
+ // eslint-disable-next-line ts/no-deprecated -- No supported API exposes core rules yet; typescript-eslint uses it too.
17
+ const coreRules = builtinRules;
18
+ const noRestrictedImports = coreRules.get('no-restricted-imports')!;
19
+ const noRestrictedSyntax = coreRules.get('no-restricted-syntax')!;
20
+
21
+ export const customPlugins = {
22
+ rules: {
23
+ 'comment-indent': commentIndent,
24
+ 'compact-iteration-layout': compactIterationLayout,
25
+ 'consistent-condition-layout': consistentConditionLayout,
26
+ 'consistent-parameter-layout': consistentParameterLayout,
27
+ 'nitro-route-method-suffix': nitroRouteMethodSuffix,
28
+ 'no-composable-in-head-getter': noComposableInHeadGetter,
29
+ 'no-restricted-nuxt-page-syntax': noRestrictedSyntax,
30
+ 'no-restricted-nuxt-server-imports': noRestrictedImports,
31
+ 'no-restricted-nuxt-syntax': noRestrictedSyntax,
32
+ 'no-restricted-test-imports': noRestrictedImports,
33
+ 'no-silent-catch': noSilentCatch,
34
+ 'no-thenable-zod-refinement': noThenableZodRefinement,
35
+ 'promise-function-async': promiseFunctionAsync,
36
+ 'statement-padding': statementPadding,
37
+ },
38
+ };
@@ -0,0 +1,27 @@
1
+ import { basename } from 'node:path';
2
+
3
+ import type { Rule } from 'eslint';
4
+
5
+ const methodSuffixPattern = /\.(?:delete|get|head|options|patch|post|put)$/;
6
+
7
+ export const nitroRouteMethodSuffix: Rule.RuleModule = {
8
+ create(context) {
9
+ return {
10
+ Program(node) {
11
+ const name = basename(context.filename).replace(/\.[cm]?[jt]s$/, '');
12
+ if (methodSuffixPattern.test(name)) return;
13
+ context.report({
14
+ data: { name },
15
+ loc: node.loc.start,
16
+ messageId: 'missing',
17
+ });
18
+ },
19
+ };
20
+ },
21
+ meta: {
22
+ docs: { description: 'Require an HTTP method suffix on Nitro route file names.' },
23
+ messages: { missing: 'Name this route `{{ name }}.get.ts`, `{{ name }}.post.ts`, or another method suffix; without one, the route accepts every HTTP method.' },
24
+ schema: [],
25
+ type: 'problem',
26
+ },
27
+ };
@@ -0,0 +1,52 @@
1
+ import type { Rule } from 'eslint';
2
+
3
+ const headComposables = new Set([
4
+ 'useHead',
5
+ 'useHeadSafe',
6
+ 'useSeoMeta',
7
+ 'useServerHead',
8
+ 'useServerHeadSafe',
9
+ 'useServerSeoMeta',
10
+ ]);
11
+
12
+ const composablePattern = /^use[A-Z]/;
13
+
14
+ export const noComposableInHeadGetter: Rule.RuleModule = {
15
+ create(context) {
16
+ return {
17
+ CallExpression(node) {
18
+ if (node.callee.type !== 'Identifier' || !composablePattern.test(node.callee.name)) return;
19
+ let insideFunction = false;
20
+ for (const parent of context.sourceCode.getAncestors(node).reverse()) {
21
+ if (parent.type === 'ArrowFunctionExpression' || parent.type === 'FunctionExpression') {
22
+ insideFunction = true;
23
+ }
24
+
25
+ if (
26
+ insideFunction
27
+ && parent.type === 'CallExpression'
28
+ && parent.callee.type === 'Identifier'
29
+ && headComposables.has(parent.callee.name)
30
+ ) {
31
+ context.report({
32
+ data: {
33
+ composable: node.callee.name,
34
+ head: parent.callee.name,
35
+ },
36
+ messageId: 'getter',
37
+ node,
38
+ });
39
+
40
+ return;
41
+ }
42
+ }
43
+ },
44
+ };
45
+ },
46
+ meta: {
47
+ docs: { description: 'Disallow calling composables inside `useHead`/`useSeoMeta` getters.' },
48
+ messages: { getter: '`{{ composable }}()` runs when the `{{ head }}` getter is evaluated after setup, outside the component context. Call it in setup and use its result in the getter.' },
49
+ schema: [],
50
+ type: 'problem',
51
+ },
52
+ };
@@ -0,0 +1,58 @@
1
+ import type { Rule } from 'eslint';
2
+
3
+ type CallArgument = Extract<Rule.Node, { type: 'CallExpression' }>['arguments'][number];
4
+ type Expression = Exclude<CallArgument, { type: 'SpreadElement' }>;
5
+
6
+ function isNothing(node: Expression | null | undefined): boolean {
7
+ if (!node) return true;
8
+ if (node.type === 'Identifier') return node.name === 'undefined';
9
+ if (node.type === 'Literal') return node.raw === 'null';
10
+ return node.type === 'UnaryExpression' && node.operator === 'void' && node.argument.type === 'Literal';
11
+ }
12
+
13
+ function isSilent(callback: CallArgument): boolean {
14
+ if (callback.type !== 'ArrowFunctionExpression' && callback.type !== 'FunctionExpression') return false;
15
+ const { body } = callback;
16
+ if (body.type !== 'BlockStatement') return isNothing(body);
17
+ const [statement, ...rest] = body.body;
18
+ return !statement || (!rest.length && statement.type === 'ReturnStatement' && isNothing(statement.argument));
19
+ }
20
+
21
+ export const noSilentCatch: Rule.RuleModule = {
22
+ create(context) {
23
+ return {
24
+ CallExpression(node) {
25
+ const { callee } = node;
26
+ const callback = node.arguments[0];
27
+ if (
28
+ callee.type !== 'MemberExpression'
29
+ || callee.computed
30
+ || callee.property.type !== 'Identifier'
31
+ || callee.property.name !== 'catch'
32
+ || !callback
33
+ || !isSilent(callback)
34
+ ) return;
35
+
36
+ // A comment right before or inside the callback is the reason the rejection can be ignored.
37
+ const { sourceCode } = context;
38
+ if (
39
+ [
40
+ ...sourceCode.getCommentsBefore(callback),
41
+ ...sourceCode.getCommentsInside(callback),
42
+ ].length
43
+ ) return;
44
+
45
+ context.report({
46
+ messageId: 'silent',
47
+ node: callback,
48
+ });
49
+ },
50
+ };
51
+ },
52
+ meta: {
53
+ docs: { description: 'Disallow `.catch()` callbacks that silently swallow the rejection.' },
54
+ messages: { silent: 'Do not swallow the rejection silently: log it, or add a comment before or inside the callback explaining why it can be ignored.' },
55
+ schema: [],
56
+ type: 'problem',
57
+ },
58
+ };
@@ -0,0 +1,70 @@
1
+ import type { Rule } from 'eslint';
2
+ import type {
3
+ Node,
4
+ Type,
5
+ TypeChecker,
6
+ } from 'typescript';
7
+
8
+ interface ParserServices {
9
+ esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };
10
+ program: { getTypeChecker: () => TypeChecker };
11
+ }
12
+
13
+ const refinementMethods = new Set([
14
+ 'check',
15
+ 'refine',
16
+ 'superRefine',
17
+ ]);
18
+
19
+ // Zod awaits a refinement only when it returns a native Promise; any other thenable counts as a truthy result.
20
+ function isNonPromiseThenable(type: Type): boolean {
21
+ return (type.isUnion() ? type.types : [type]).some(
22
+ (part) => part.getProperty('then') && part.getSymbol()?.getName() !== 'Promise',
23
+ );
24
+ }
25
+
26
+ export const noThenableZodRefinement: Rule.RuleModule = {
27
+ create(context) {
28
+ const services = context.sourceCode.parserServices as ParserServices;
29
+ const checker = services.program.getTypeChecker();
30
+ const getType = (node: unknown) => checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node));
31
+
32
+ return {
33
+ CallExpression(node) {
34
+ const { callee } = node;
35
+ if (
36
+ callee.type !== 'MemberExpression'
37
+ || callee.computed
38
+ || callee.property.type !== 'Identifier'
39
+ || !refinementMethods.has(callee.property.name)
40
+ // Covers schema methods such as `z.objectId().refine()` and standalone checks such as `z.refine()`.
41
+ || !getType(node).getProperty('_zod')
42
+ ) return;
43
+
44
+ const method = callee.property.name;
45
+ // `.check()` takes several checks; non-function checks have no call signatures.
46
+ for (const callback of node.arguments) {
47
+ const returnsThenable = getType(callback)
48
+ .getCallSignatures()
49
+ .some((signature) => isNonPromiseThenable(checker.getReturnTypeOfSignature(signature)));
50
+
51
+ if (!returnsThenable) continue;
52
+ context.report({
53
+ data: { method },
54
+ messageId: 'thenable',
55
+ node: callback,
56
+ });
57
+ }
58
+ },
59
+ };
60
+ },
61
+ meta: {
62
+ docs: {
63
+ description: 'Disallow Zod refinements and checks that return a thenable other than a Promise.',
64
+ requiresTypeChecking: true,
65
+ } as Rule.RuleMetaData['docs'],
66
+ messages: { thenable: 'Zod only awaits a native Promise, so this `{{ method }}()` callback\'s thenable (such as a Mongoose Query) counts as a passing check. Make the callback `async` and `await` the value.' },
67
+ schema: [],
68
+ type: 'problem',
69
+ },
70
+ };
@@ -0,0 +1,56 @@
1
+ import tseslint from '@typescript-eslint/eslint-plugin';
2
+ import type { Rule } from 'eslint';
3
+ import type {
4
+ Node,
5
+ SignatureDeclaration,
6
+ Type,
7
+ TypeChecker,
8
+ } from 'typescript';
9
+
10
+ interface ParserServices {
11
+ esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };
12
+ program: { getTypeChecker: () => TypeChecker };
13
+ }
14
+
15
+ const upstream = tseslint.rules['promise-function-async'] as unknown as Rule.RuleModule;
16
+ const promiseMembers = new Set([
17
+ 'catch',
18
+ 'finally',
19
+ 'then',
20
+ ]);
21
+
22
+ // A thenable with extra members, such as Nuxt's `AsyncData`, loses those members once the function becomes async.
23
+ function hasNonPromiseMembers(checker: TypeChecker, type: Type): boolean {
24
+ return (type.isUnion() ? type.types : [type]).some((part) => {
25
+ const names = checker.getPropertiesOfType(part).map((symbol) => symbol.getName());
26
+ return names.includes('then') && names.some((name) => !promiseMembers.has(name) && !name.startsWith('__@'));
27
+ });
28
+ }
29
+
30
+ export const promiseFunctionAsync: Rule.RuleModule = {
31
+ create(context) {
32
+ const report = (descriptor: Rule.ReportDescriptor) => {
33
+ if ('node' in descriptor) {
34
+ const services = context.sourceCode.parserServices as ParserServices;
35
+ const checker = services.program.getTypeChecker();
36
+ const tsNode = services.esTreeNodeToTSNodeMap.get(descriptor.node) as SignatureDeclaration;
37
+ // Overloads are what callers see, so they count alongside the implementation signature.
38
+ const signatures = [
39
+ checker.getSignatureFromDeclaration(tsNode),
40
+ ...checker.getTypeAtLocation(tsNode).getCallSignatures(),
41
+ ];
42
+
43
+ if (
44
+ signatures.some((signature) => signature
45
+ && hasNonPromiseMembers(checker, checker.getReturnTypeOfSignature(signature)))
46
+ ) return;
47
+ }
48
+
49
+ context.report(descriptor);
50
+ };
51
+
52
+ // The upstream rule validates that type information is available.
53
+ return upstream.create(Object.create(context, { report: { value: report } }));
54
+ },
55
+ meta: upstream.meta,
56
+ };
@@ -85,6 +85,7 @@ export const statementPadding: Rule.RuleModule = {
85
85
  Program: (node) => checkStatements(node.body),
86
86
  StaticBlock: (node) => checkStatements(node.body),
87
87
  SwitchCase: (node) => checkStatements(node.consequent),
88
+ TSModuleBlock: (node: Rule.Node & { body: StatementNode[] }) => checkStatements(node.body),
88
89
  };
89
90
  },
90
91
  meta: {
package/src/base.ts CHANGED
@@ -1,7 +1,4 @@
1
- import type {
2
- Rules,
3
- TypedFlatConfigItem,
4
- } from '@antfu/eslint-config';
1
+ import type { TypedFlatConfigItem } from '@antfu/eslint-config';
5
2
  import {
6
3
  GLOB_JS,
7
4
  GLOB_JSX,
@@ -12,21 +9,18 @@ import {
12
9
  // @ts-expect-error No declare file.
13
10
  import promise from 'eslint-plugin-promise';
14
11
 
12
+ import { createBaseRules } from './_internals/configs/base-rules';
15
13
  import {
16
14
  jsdocSettings,
17
15
  typescriptJsdocConfig,
18
- } from './_internals/jsdoc';
19
- import { customPlugins } from './_internals/plugins';
20
- import { restrictedSyntax } from './_internals/restricted-syntax';
21
- import { createTypeAwareConfig } from './_internals/type-aware';
22
- import { createTypefestConfig } from './_internals/typefest';
16
+ } from './_internals/configs/jsdoc';
17
+ import { createTypeAwareConfig } from './_internals/configs/type-aware';
18
+ import { createTypefestConfig } from './_internals/configs/typefest';
19
+ import { customPlugins } from './_internals/rules';
23
20
 
24
- // Constants/Variables
25
- const basePerfectionistSortOptions = {
26
- ignoreCase: false,
27
- type: 'natural',
28
- } as const;
21
+ export { createBaseRules };
29
22
 
23
+ // Constants/Variables
30
24
  const vscodeOrderSensitiveArrayProperties = [
31
25
  'args',
32
26
  'autoAttachSmartPattern',
@@ -123,7 +117,7 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
123
117
  'error',
124
118
  { compactTestCalls: true },
125
119
  ],
126
- 'no-restricted-imports': [
120
+ 'kikiutils/no-restricted-test-imports': [
127
121
  'error',
128
122
  {
129
123
  paths: [
@@ -195,322 +189,3 @@ export function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFl
195
189
  { ignores: ['**/.serena/**'] },
196
190
  ];
197
191
  }
198
-
199
- export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
200
- return {
201
- 'antfu/consistent-list-newline': [
202
- 'error',
203
- {
204
- ArrayExpression: false,
205
- ArrayPattern: false,
206
- },
207
- ],
208
- 'antfu/curly': 'off',
209
- 'antfu/if-newline': 'off',
210
- 'antfu/no-top-level-await': 'off',
211
- 'antfu/reasonable-newline': 'off',
212
- 'arrow-body-style': [
213
- 'error',
214
- 'as-needed',
215
- ],
216
- 'curly': [
217
- 'error',
218
- 'multi-line',
219
- ],
220
- 'jsdoc/check-tag-names': 'error',
221
- 'jsdoc/multiline-blocks': [
222
- 'error',
223
- {
224
- noSingleLineBlocks: true,
225
- singleLineTags: [
226
- 'type',
227
- 'import',
228
- ],
229
- },
230
- ],
231
- 'jsdoc/no-blank-blocks': [
232
- 'error',
233
- { enableFixer: true },
234
- ],
235
- 'jsdoc/require-asterisk-prefix': 'error',
236
- 'jsdoc/require-hyphen-before-param-description': [
237
- 'error',
238
- 'always',
239
- { tags: { typeParam: 'always' } },
240
- ],
241
- 'kikiutils/compact-iteration-layout': 'error',
242
- 'kikiutils/consistent-condition-layout': 'error',
243
- 'kikiutils/consistent-parameter-layout': 'error',
244
- 'kikiutils/statement-padding': 'error',
245
- 'max-classes-per-file': [
246
- 'error',
247
- 1,
248
- ],
249
- 'no-constant-binary-expression': 'error',
250
- // An ignored error needs at least a comment in the block saying why.
251
- 'no-empty': [
252
- 'error',
253
- { allowEmptyCatch: false },
254
- ],
255
- 'no-promise-executor-return': [
256
- 'error',
257
- { allowVoid: true },
258
- ],
259
- 'no-restricted-imports': [
260
- 'error',
261
- {
262
- patterns: [
263
- {
264
- message: '`_internals` modules are private to their own directory; import the public module instead.',
265
- regex: String.raw`^[^.].*/_internals(/|$)`,
266
- },
267
- ],
268
- },
269
- ],
270
- 'no-restricted-syntax': [
271
- 'error',
272
- ...restrictedSyntax,
273
- ],
274
- 'no-useless-assignment': 'error',
275
- 'perfectionist/sort-array-includes': [
276
- 'error',
277
- basePerfectionistSortOptions,
278
- ],
279
- 'perfectionist/sort-enums': [
280
- 'error',
281
- {
282
- ...basePerfectionistSortOptions,
283
- sortByValue: 'never',
284
- },
285
- ],
286
- 'perfectionist/sort-heritage-clauses': [
287
- 'error',
288
- basePerfectionistSortOptions,
289
- ],
290
- 'perfectionist/sort-imports': [
291
- 'error',
292
- {
293
- environment,
294
- groups: [
295
- 'side-effect',
296
- 'side-effect-style',
297
- 'style',
298
- [
299
- 'value-builtin',
300
- 'type-builtin',
301
- ],
302
- [
303
- 'value-external',
304
- 'type-external',
305
- ],
306
- [
307
- 'value-internal',
308
- 'type-internal',
309
- ],
310
- [
311
- 'value-parent',
312
- 'type-parent',
313
- ],
314
- [
315
- 'value-sibling',
316
- 'type-sibling',
317
- ],
318
- [
319
- 'value-index',
320
- 'type-index',
321
- ],
322
- 'unknown',
323
- ],
324
- ignoreCase: false,
325
- internalPattern: [
326
- '^#.*',
327
- '^@/.*',
328
- '^~/.*',
329
- ],
330
- type: 'natural',
331
- },
332
- ],
333
- 'perfectionist/sort-interfaces': [
334
- 'error',
335
- basePerfectionistSortOptions,
336
- ],
337
- 'perfectionist/sort-intersection-types': [
338
- 'error',
339
- basePerfectionistSortOptions,
340
- ],
341
- 'perfectionist/sort-maps': [
342
- 'error',
343
- basePerfectionistSortOptions,
344
- ],
345
- 'perfectionist/sort-modules': [
346
- 'error',
347
- {
348
- ...basePerfectionistSortOptions,
349
- groups: [
350
- 'declare-type',
351
- [
352
- 'export-type',
353
- 'type',
354
- ],
355
- 'declare-interface',
356
- [
357
- 'export-interface',
358
- 'interface',
359
- ],
360
- 'declare-enum',
361
- [
362
- 'enum',
363
- 'export-enum',
364
- ],
365
- 'declare-class',
366
- [
367
- 'class',
368
- 'export-class',
369
- ],
370
- 'declare-function',
371
- [
372
- 'export-function',
373
- 'function',
374
- ],
375
- ],
376
- },
377
- ],
378
- 'perfectionist/sort-object-types': [
379
- 'error',
380
- basePerfectionistSortOptions,
381
- ],
382
- 'perfectionist/sort-objects': [
383
- 'error',
384
- basePerfectionistSortOptions,
385
- ],
386
- 'perfectionist/sort-sets': [
387
- 'error',
388
- basePerfectionistSortOptions,
389
- ],
390
- 'perfectionist/sort-switch-case': [
391
- 'error',
392
- {
393
- ignoreCase: false,
394
- type: 'natural',
395
- },
396
- ],
397
- 'perfectionist/sort-union-types': [
398
- 'error',
399
- basePerfectionistSortOptions,
400
- ],
401
- 'perfectionist/sort-variable-declarations': [
402
- 'error',
403
- basePerfectionistSortOptions,
404
- ],
405
- 'preserve-caught-error': 'error',
406
- 'promise/no-multiple-resolved': 'error',
407
- 'promise/no-return-in-finally': 'error',
408
- 'promise/no-return-wrap': 'error',
409
- 'require-await': 'off',
410
- 'style/array-bracket-newline': [
411
- 'error',
412
- { multiline: true },
413
- ],
414
- 'style/array-element-newline': [
415
- 'error',
416
- {
417
- ArrayExpression: {
418
- consistent: true,
419
- minItems: 2,
420
- },
421
- ArrayPattern: { minItems: 3 },
422
- },
423
- ],
424
- 'style/arrow-parens': [
425
- 'error',
426
- 'always',
427
- ],
428
- 'style/brace-style': [
429
- 'error',
430
- '1tbs',
431
- { allowSingleLine: false },
432
- ],
433
- 'style/function-call-spacing': [
434
- 'error',
435
- 'never',
436
- ],
437
- 'style/indent': [
438
- 'error',
439
- 4,
440
- ],
441
- 'style/max-len': [
442
- 'warn',
443
- {
444
- code: 120,
445
- comments: 120,
446
- ignoreStrings: true,
447
- ignoreTemplateLiterals: true,
448
- },
449
- ],
450
- 'style/member-delimiter-style': [
451
- 'error',
452
- {
453
- multiline: {
454
- delimiter: 'semi',
455
- requireLast: true,
456
- },
457
- },
458
- ],
459
- 'style/no-extra-parens': [
460
- 'error',
461
- 'all',
462
- { nestedBinaryExpressions: false },
463
- ],
464
- 'style/no-extra-semi': 'error',
465
- 'style/object-curly-newline': [
466
- 'error',
467
- {
468
- ExportDeclaration: {
469
- minProperties: 2,
470
- multiline: true,
471
- },
472
- ImportDeclaration: {
473
- minProperties: 2,
474
- multiline: true,
475
- },
476
- ObjectExpression: {
477
- minProperties: 2,
478
- multiline: true,
479
- },
480
- ObjectPattern: {
481
- minProperties: 3,
482
- multiline: true,
483
- },
484
- },
485
- ],
486
- 'style/operator-linebreak': [
487
- 'error',
488
- 'before',
489
- { overrides: { '=': 'after' } },
490
- ],
491
- 'style/padding-line-between-statements': [
492
- 'error',
493
- {
494
- blankLine: 'always',
495
- next: [
496
- 'class',
497
- 'enum',
498
- 'function',
499
- ],
500
- prev: '*',
501
- },
502
- {
503
- blankLine: 'always',
504
- next: '*',
505
- prev: [
506
- 'class',
507
- 'function',
508
- ],
509
- },
510
- ],
511
- 'style/semi': [
512
- 'error',
513
- 'always',
514
- ],
515
- };
516
- }