@kikiutils/eslint-config 10.1.1 → 10.2.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.
- package/README.md +2 -0
- package/dist/_internals/type-aware.js +3 -3
- package/dist/_internals/type-aware.js.map +1 -1
- package/dist/base.js +1 -1
- package/dist/base.js.map +1 -1
- package/package.json +1 -1
- package/src/_internals/type-aware.ts +6 -3
- package/src/base.ts +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,8 @@ Linted files must belong to a discoverable `tsconfig.json`; project references a
|
|
|
31
31
|
The default setup does not require an additional `typescript.tsconfigPath` option.
|
|
32
32
|
JavaScript files retain syntax-only linting.
|
|
33
33
|
TypeScript tool configs (`*.config.ts`, `*.config.mts`, `*.config.cts`) are excluded from type-aware checks.
|
|
34
|
+
Type-aware checks require Promise-returning functions to be `async` and returned promises to use `return await`.
|
|
35
|
+
Both `require-await` rules are disabled so `async` wrappers can preserve Promise-based error handling without an `await`.
|
|
34
36
|
Base configs keep linting Markdown itself, but exclude its code blocks from all lint rules.
|
|
35
37
|
Style configs format CSS and SCSS; indented Sass (`.sass`) is not supported.
|
|
36
38
|
|
|
@@ -6,7 +6,6 @@ function createTypeAwareConfig() {
|
|
|
6
6
|
tsconfigRootDir: process.cwd()
|
|
7
7
|
} },
|
|
8
8
|
rules: {
|
|
9
|
-
"require-await": "off",
|
|
10
9
|
"ts/await-thenable": "error",
|
|
11
10
|
"ts/no-base-to-string": "error",
|
|
12
11
|
"ts/no-floating-promises": ["error", { allowForKnownSafePromises: [{
|
|
@@ -18,8 +17,9 @@ function createTypeAwareConfig() {
|
|
|
18
17
|
"ts/no-misused-promises": "error",
|
|
19
18
|
"ts/no-misused-spread": "error",
|
|
20
19
|
"ts/no-unnecessary-type-assertion": "error",
|
|
21
|
-
"ts/
|
|
22
|
-
"ts/
|
|
20
|
+
"ts/promise-function-async": "error",
|
|
21
|
+
"ts/require-await": "off",
|
|
22
|
+
"ts/return-await": ["error", "always"],
|
|
23
23
|
"ts/switch-exhaustiveness-check": ["error", { considerDefaultExhaustiveForUnions: true }]
|
|
24
24
|
}
|
|
25
25
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-aware.js","names":[],"sources":["../../src/_internals/type-aware.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\n\nexport function createTypeAwareConfig(): TypedFlatConfigItem {\n return {\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: process.cwd(),\n },\n },\n rules: {\n '
|
|
1
|
+
{"version":3,"file":"type-aware.js","names":[],"sources":["../../src/_internals/type-aware.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\n\nexport function createTypeAwareConfig(): TypedFlatConfigItem {\n return {\n languageOptions: {\n parserOptions: {\n projectService: true,\n tsconfigRootDir: process.cwd(),\n },\n },\n rules: {\n 'ts/await-thenable': 'error',\n 'ts/no-base-to-string': 'error',\n 'ts/no-floating-promises': [\n 'error',\n {\n allowForKnownSafePromises: [\n {\n from: 'package',\n name: 'SafePromise',\n package: '@kikiutils/shared',\n },\n ],\n },\n ],\n 'ts/no-for-in-array': 'error',\n 'ts/no-misused-promises': 'error',\n 'ts/no-misused-spread': 'error',\n 'ts/no-unnecessary-type-assertion': 'error',\n 'ts/promise-function-async': 'error',\n 'ts/require-await': 'off',\n 'ts/return-await': [\n 'error',\n 'always',\n ],\n 'ts/switch-exhaustiveness-check': [\n 'error',\n { considerDefaultExhaustiveForUnions: true },\n ],\n },\n };\n}\n"],"mappings":";AAEA,SAAgB,wBAA6C;CACzD,OAAO;EACH,iBAAiB,EACb,eAAe;GACX,gBAAgB;GAChB,iBAAiB,QAAQ,IAAI;EACjC,EACJ;EACA,OAAO;GACH,qBAAqB;GACrB,wBAAwB;GACxB,2BAA2B,CACvB,SACA,EACI,2BAA2B,CACvB;IACI,MAAM;IACN,MAAM;IACN,SAAS;GACb,CACJ,EACJ,CACJ;GACA,sBAAsB;GACtB,0BAA0B;GAC1B,wBAAwB;GACxB,oCAAoC;GACpC,6BAA6B;GAC7B,oBAAoB;GACpB,mBAAmB,CACf,SACA,QACJ;GACA,kCAAkC,CAC9B,SACA,EAAE,oCAAoC,KAAK,CAC/C;EACJ;CACJ;AACJ"}
|
package/dist/base.js
CHANGED
|
@@ -200,7 +200,7 @@ function createBaseRules(environment = "node") {
|
|
|
200
200
|
"promise/no-multiple-resolved": "error",
|
|
201
201
|
"promise/no-return-in-finally": "error",
|
|
202
202
|
"promise/no-return-wrap": "error",
|
|
203
|
-
"require-await": "
|
|
203
|
+
"require-await": "off",
|
|
204
204
|
"style/array-bracket-newline": ["error", { multiline: true }],
|
|
205
205
|
"style/array-element-newline": ["error", {
|
|
206
206
|
ArrayExpression: {
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":[],"sources":["../src/base.ts"],"sourcesContent":["import type {\n Rules,\n TypedFlatConfigItem,\n} from '@antfu/eslint-config';\nimport {\n GLOB_JS,\n GLOB_JSX,\n GLOB_TESTS,\n GLOB_TS,\n GLOB_TSX,\n} from '@antfu/eslint-config';\n// @ts-expect-error No declare file.\nimport promise from 'eslint-plugin-promise';\n\nimport {\n jsdocSettings,\n typescriptJsdocConfig,\n} from './_internals/jsdoc';\nimport { customPlugins } from './_internals/plugins';\nimport { createTypeAwareConfig } from './_internals/type-aware';\n\n// Constants/Variables\nconst basePerfectionistSortOptions = {\n ignoreCase: false,\n type: 'natural',\n} as const;\n\nconst vscodeOrderSensitiveArrayProperties = [\n 'args',\n 'autoAttachSmartPattern',\n 'dependsOn',\n 'options',\n 'outFiles',\n 'problemMatcher',\n 'resolveSourceMapLocations',\n 'runtimeArgs',\n 'skipFiles',\n].join('|');\n\n// Functions\nexport function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {\n return [\n // All files\n {\n rules: {\n 'e18e/ban-dependencies': [\n 'error',\n { allowed: ['axios'] },\n ],\n 'e18e/prefer-static-regex': 'off',\n },\n },\n // JavaScript and TypeScript\n {\n files: [\n GLOB_JS,\n GLOB_JSX,\n GLOB_TS,\n GLOB_TSX,\n ],\n plugins: {\n kikiutils: customPlugins,\n promise,\n },\n rules: {\n ...createBaseRules(environment),\n 'node/prefer-global/process': [\n 'error',\n 'always',\n ],\n },\n settings: jsdocSettings,\n },\n // TypeScript\n {\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n rules: {\n ...typescriptJsdocConfig.rules,\n 'ts/array-type': [\n 'error',\n { default: 'array-simple' },\n ],\n 'ts/consistent-generic-constructors': [\n 'error',\n 'constructor',\n ],\n 'ts/no-redeclare': 'off',\n },\n settings: typescriptJsdocConfig.settings,\n },\n // Type-aware TypeScript\n {\n ...createTypeAwareConfig(),\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n ignores: ['**/*.config.?([cm])ts'],\n },\n // Tests\n {\n files: GLOB_TESTS,\n rules: {\n 'kikiutils/consistent-parameter-layout': [\n 'error',\n { compactTestCalls: true },\n ],\n 'no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n importNames: ['expect'],\n message: 'Use `expect` from the test context.',\n name: 'vitest',\n },\n ],\n },\n ],\n 'test/consistent-each-for': [\n 'error',\n {\n it: 'for',\n test: 'for',\n },\n ],\n 'test/prefer-each': 'error',\n 'test/prefer-hooks-on-top': 'error',\n 'test/prefer-lowercase-title': [\n 'error',\n {\n ignoreTopLevelDescribe: true,\n lowercaseFirstCharacterOnly: true,\n },\n ],\n 'test/prefer-to-be': 'error',\n 'test/valid-describe-callback': 'error',\n 'test/valid-expect': 'error',\n 'test/valid-expect-in-promise': 'error',\n 'test/valid-title': [\n 'error',\n {\n mustMatch: { it: '^should ' },\n mustNotMatch: { it: String.raw`\\.$` },\n },\n ],\n },\n },\n // VS Code JSONC\n {\n files: ['**/.vscode/*.json'],\n rules: {\n 'jsonc/sort-array-values': [\n 'error',\n {\n order: {\n natural: true,\n type: 'asc',\n },\n // Preserve ordered fields and any argument or option arrays nested inside them.\n pathPattern: String.raw`^(?!.*(?:^|\\.|\\[\")(?:${vscodeOrderSensitiveArrayProperties})(?:$|\\.|\\[|\"\\])).*`,\n },\n ],\n 'jsonc/sort-keys': [\n 'error',\n 'asc',\n {\n caseSensitive: true,\n natural: true,\n },\n ],\n },\n },\n // Ignore all extracted Markdown code blocks, but keep linting Markdown itself.\n { ignores: ['**/*.md/**'] },\n ];\n}\n\nexport function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {\n return {\n 'antfu/consistent-list-newline': [\n 'error',\n {\n ArrayExpression: false,\n ArrayPattern: false,\n },\n ],\n 'antfu/curly': 'off',\n 'antfu/if-newline': 'off',\n 'antfu/no-top-level-await': 'off',\n 'antfu/reasonable-newline': 'off',\n 'arrow-body-style': [\n 'error',\n 'as-needed',\n ],\n 'curly': [\n 'error',\n 'multi-line',\n ],\n 'jsdoc/check-tag-names': 'error',\n 'jsdoc/multiline-blocks': [\n 'error',\n {\n noSingleLineBlocks: true,\n singleLineTags: [\n 'type',\n 'import',\n ],\n },\n ],\n 'jsdoc/no-blank-blocks': [\n 'error',\n { enableFixer: true },\n ],\n 'jsdoc/require-asterisk-prefix': 'error',\n 'jsdoc/require-hyphen-before-param-description': [\n 'error',\n 'always',\n { tags: { typeParam: 'always' } },\n ],\n 'kikiutils/compact-iteration-layout': 'error',\n 'kikiutils/consistent-condition-layout': 'error',\n 'kikiutils/consistent-parameter-layout': 'error',\n 'kikiutils/statement-padding': 'error',\n 'max-classes-per-file': [\n 'error',\n 1,\n ],\n 'no-constant-binary-expression': 'error',\n 'no-promise-executor-return': [\n 'error',\n { allowVoid: true },\n ],\n 'no-useless-assignment': 'error',\n 'perfectionist/sort-array-includes': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-enums': [\n 'error',\n {\n ...basePerfectionistSortOptions,\n sortByValue: 'never',\n },\n ],\n 'perfectionist/sort-heritage-clauses': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-imports': [\n 'error',\n {\n environment,\n groups: [\n 'side-effect',\n 'side-effect-style',\n 'style',\n [\n 'value-builtin',\n 'type-builtin',\n ],\n [\n 'value-external',\n 'type-external',\n ],\n [\n 'value-internal',\n 'type-internal',\n ],\n [\n 'value-parent',\n 'type-parent',\n ],\n [\n 'value-sibling',\n 'type-sibling',\n ],\n [\n 'value-index',\n 'type-index',\n ],\n 'unknown',\n ],\n ignoreCase: false,\n internalPattern: [\n '^#.*',\n '^@/.*',\n '^~/.*',\n ],\n type: 'natural',\n },\n ],\n 'perfectionist/sort-interfaces': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-intersection-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-maps': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-modules': [\n 'error',\n {\n ...basePerfectionistSortOptions,\n groups: [\n 'declare-type',\n [\n 'export-type',\n 'type',\n ],\n 'declare-interface',\n [\n 'export-interface',\n 'interface',\n ],\n 'declare-enum',\n [\n 'enum',\n 'export-enum',\n ],\n 'declare-class',\n [\n 'class',\n 'export-class',\n ],\n 'declare-function',\n [\n 'export-function',\n 'function',\n ],\n ],\n },\n ],\n 'perfectionist/sort-object-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-objects': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-sets': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-switch-case': [\n 'error',\n {\n ignoreCase: false,\n type: 'natural',\n },\n ],\n 'perfectionist/sort-union-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-variable-declarations': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'preserve-caught-error': 'error',\n 'promise/no-multiple-resolved': 'error',\n 'promise/no-return-in-finally': 'error',\n 'promise/no-return-wrap': 'error',\n 'require-await': 'error',\n 'style/array-bracket-newline': [\n 'error',\n { multiline: true },\n ],\n 'style/array-element-newline': [\n 'error',\n {\n ArrayExpression: {\n consistent: true,\n minItems: 2,\n },\n ArrayPattern: { minItems: 3 },\n },\n ],\n 'style/arrow-parens': [\n 'error',\n 'always',\n ],\n 'style/brace-style': [\n 'error',\n '1tbs',\n { allowSingleLine: false },\n ],\n 'style/function-call-spacing': [\n 'error',\n 'never',\n ],\n 'style/indent': [\n 'error',\n 4,\n ],\n 'style/max-len': [\n 'warn',\n {\n code: 120,\n comments: 120,\n ignoreStrings: true,\n ignoreTemplateLiterals: true,\n },\n ],\n 'style/member-delimiter-style': [\n 'error',\n {\n multiline: {\n delimiter: 'semi',\n requireLast: true,\n },\n },\n ],\n 'style/no-extra-parens': [\n 'error',\n 'all',\n { nestedBinaryExpressions: false },\n ],\n 'style/no-extra-semi': 'error',\n 'style/object-curly-newline': [\n 'error',\n {\n ExportDeclaration: {\n minProperties: 2,\n multiline: true,\n },\n ImportDeclaration: {\n minProperties: 2,\n multiline: true,\n },\n ObjectExpression: {\n minProperties: 2,\n multiline: true,\n },\n ObjectPattern: {\n minProperties: 3,\n multiline: true,\n },\n },\n ],\n 'style/operator-linebreak': [\n 'error',\n 'before',\n { overrides: { '=': 'after' } },\n ],\n 'style/padding-line-between-statements': [\n 'error',\n {\n blankLine: 'always',\n next: [\n 'class',\n 'enum',\n 'function',\n ],\n prev: '*',\n },\n {\n blankLine: 'always',\n next: '*',\n prev: [\n 'class',\n 'function',\n ],\n },\n ],\n 'style/semi': [\n 'error',\n 'always',\n ],\n };\n}\n"],"mappings":";;;;;;AAsBA,MAAM,+BAA+B;CACjC,YAAY;CACZ,MAAM;AACV;AAEA,MAAM,sCAAsC;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,CAAC,KAAK,GAAG;AAGV,SAAgB,kBAAkB,cAA8B,QAA+B;CAC3F,OAAO;EAEH,EACI,OAAO;GACH,yBAAyB,CACrB,SACA,EAAE,SAAS,CAAC,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AAW;IACX,MAAM;KACF;KACA;KACA;IACJ;IACA,MAAM;GACV;GACA;IACI,WAAW;IACX,MAAM;IACN,MAAM,CACF,SACA,UACJ;GACJ;EACJ;EACA,cAAc,CACV,SACA,QACJ;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../src/base.ts"],"sourcesContent":["import type {\n Rules,\n TypedFlatConfigItem,\n} from '@antfu/eslint-config';\nimport {\n GLOB_JS,\n GLOB_JSX,\n GLOB_TESTS,\n GLOB_TS,\n GLOB_TSX,\n} from '@antfu/eslint-config';\n// @ts-expect-error No declare file.\nimport promise from 'eslint-plugin-promise';\n\nimport {\n jsdocSettings,\n typescriptJsdocConfig,\n} from './_internals/jsdoc';\nimport { customPlugins } from './_internals/plugins';\nimport { createTypeAwareConfig } from './_internals/type-aware';\n\n// Constants/Variables\nconst basePerfectionistSortOptions = {\n ignoreCase: false,\n type: 'natural',\n} as const;\n\nconst vscodeOrderSensitiveArrayProperties = [\n 'args',\n 'autoAttachSmartPattern',\n 'dependsOn',\n 'options',\n 'outFiles',\n 'problemMatcher',\n 'resolveSourceMapLocations',\n 'runtimeArgs',\n 'skipFiles',\n].join('|');\n\n// Functions\nexport function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {\n return [\n // All files\n {\n rules: {\n 'e18e/ban-dependencies': [\n 'error',\n { allowed: ['axios'] },\n ],\n 'e18e/prefer-static-regex': 'off',\n },\n },\n // JavaScript and TypeScript\n {\n files: [\n GLOB_JS,\n GLOB_JSX,\n GLOB_TS,\n GLOB_TSX,\n ],\n plugins: {\n kikiutils: customPlugins,\n promise,\n },\n rules: {\n ...createBaseRules(environment),\n 'node/prefer-global/process': [\n 'error',\n 'always',\n ],\n },\n settings: jsdocSettings,\n },\n // TypeScript\n {\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n rules: {\n ...typescriptJsdocConfig.rules,\n 'ts/array-type': [\n 'error',\n { default: 'array-simple' },\n ],\n 'ts/consistent-generic-constructors': [\n 'error',\n 'constructor',\n ],\n 'ts/no-redeclare': 'off',\n },\n settings: typescriptJsdocConfig.settings,\n },\n // Type-aware TypeScript\n {\n ...createTypeAwareConfig(),\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n ignores: ['**/*.config.?([cm])ts'],\n },\n // Tests\n {\n files: GLOB_TESTS,\n rules: {\n 'kikiutils/consistent-parameter-layout': [\n 'error',\n { compactTestCalls: true },\n ],\n 'no-restricted-imports': [\n 'error',\n {\n paths: [\n {\n importNames: ['expect'],\n message: 'Use `expect` from the test context.',\n name: 'vitest',\n },\n ],\n },\n ],\n 'test/consistent-each-for': [\n 'error',\n {\n it: 'for',\n test: 'for',\n },\n ],\n 'test/prefer-each': 'error',\n 'test/prefer-hooks-on-top': 'error',\n 'test/prefer-lowercase-title': [\n 'error',\n {\n ignoreTopLevelDescribe: true,\n lowercaseFirstCharacterOnly: true,\n },\n ],\n 'test/prefer-to-be': 'error',\n 'test/valid-describe-callback': 'error',\n 'test/valid-expect': 'error',\n 'test/valid-expect-in-promise': 'error',\n 'test/valid-title': [\n 'error',\n {\n mustMatch: { it: '^should ' },\n mustNotMatch: { it: String.raw`\\.$` },\n },\n ],\n },\n },\n // VS Code JSONC\n {\n files: ['**/.vscode/*.json'],\n rules: {\n 'jsonc/sort-array-values': [\n 'error',\n {\n order: {\n natural: true,\n type: 'asc',\n },\n // Preserve ordered fields and any argument or option arrays nested inside them.\n pathPattern: String.raw`^(?!.*(?:^|\\.|\\[\")(?:${vscodeOrderSensitiveArrayProperties})(?:$|\\.|\\[|\"\\])).*`,\n },\n ],\n 'jsonc/sort-keys': [\n 'error',\n 'asc',\n {\n caseSensitive: true,\n natural: true,\n },\n ],\n },\n },\n // Ignore all extracted Markdown code blocks, but keep linting Markdown itself.\n { ignores: ['**/*.md/**'] },\n ];\n}\n\nexport function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {\n return {\n 'antfu/consistent-list-newline': [\n 'error',\n {\n ArrayExpression: false,\n ArrayPattern: false,\n },\n ],\n 'antfu/curly': 'off',\n 'antfu/if-newline': 'off',\n 'antfu/no-top-level-await': 'off',\n 'antfu/reasonable-newline': 'off',\n 'arrow-body-style': [\n 'error',\n 'as-needed',\n ],\n 'curly': [\n 'error',\n 'multi-line',\n ],\n 'jsdoc/check-tag-names': 'error',\n 'jsdoc/multiline-blocks': [\n 'error',\n {\n noSingleLineBlocks: true,\n singleLineTags: [\n 'type',\n 'import',\n ],\n },\n ],\n 'jsdoc/no-blank-blocks': [\n 'error',\n { enableFixer: true },\n ],\n 'jsdoc/require-asterisk-prefix': 'error',\n 'jsdoc/require-hyphen-before-param-description': [\n 'error',\n 'always',\n { tags: { typeParam: 'always' } },\n ],\n 'kikiutils/compact-iteration-layout': 'error',\n 'kikiutils/consistent-condition-layout': 'error',\n 'kikiutils/consistent-parameter-layout': 'error',\n 'kikiutils/statement-padding': 'error',\n 'max-classes-per-file': [\n 'error',\n 1,\n ],\n 'no-constant-binary-expression': 'error',\n 'no-promise-executor-return': [\n 'error',\n { allowVoid: true },\n ],\n 'no-useless-assignment': 'error',\n 'perfectionist/sort-array-includes': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-enums': [\n 'error',\n {\n ...basePerfectionistSortOptions,\n sortByValue: 'never',\n },\n ],\n 'perfectionist/sort-heritage-clauses': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-imports': [\n 'error',\n {\n environment,\n groups: [\n 'side-effect',\n 'side-effect-style',\n 'style',\n [\n 'value-builtin',\n 'type-builtin',\n ],\n [\n 'value-external',\n 'type-external',\n ],\n [\n 'value-internal',\n 'type-internal',\n ],\n [\n 'value-parent',\n 'type-parent',\n ],\n [\n 'value-sibling',\n 'type-sibling',\n ],\n [\n 'value-index',\n 'type-index',\n ],\n 'unknown',\n ],\n ignoreCase: false,\n internalPattern: [\n '^#.*',\n '^@/.*',\n '^~/.*',\n ],\n type: 'natural',\n },\n ],\n 'perfectionist/sort-interfaces': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-intersection-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-maps': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-modules': [\n 'error',\n {\n ...basePerfectionistSortOptions,\n groups: [\n 'declare-type',\n [\n 'export-type',\n 'type',\n ],\n 'declare-interface',\n [\n 'export-interface',\n 'interface',\n ],\n 'declare-enum',\n [\n 'enum',\n 'export-enum',\n ],\n 'declare-class',\n [\n 'class',\n 'export-class',\n ],\n 'declare-function',\n [\n 'export-function',\n 'function',\n ],\n ],\n },\n ],\n 'perfectionist/sort-object-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-objects': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-sets': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-switch-case': [\n 'error',\n {\n ignoreCase: false,\n type: 'natural',\n },\n ],\n 'perfectionist/sort-union-types': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'perfectionist/sort-variable-declarations': [\n 'error',\n basePerfectionistSortOptions,\n ],\n 'preserve-caught-error': 'error',\n 'promise/no-multiple-resolved': 'error',\n 'promise/no-return-in-finally': 'error',\n 'promise/no-return-wrap': 'error',\n 'require-await': 'off',\n 'style/array-bracket-newline': [\n 'error',\n { multiline: true },\n ],\n 'style/array-element-newline': [\n 'error',\n {\n ArrayExpression: {\n consistent: true,\n minItems: 2,\n },\n ArrayPattern: { minItems: 3 },\n },\n ],\n 'style/arrow-parens': [\n 'error',\n 'always',\n ],\n 'style/brace-style': [\n 'error',\n '1tbs',\n { allowSingleLine: false },\n ],\n 'style/function-call-spacing': [\n 'error',\n 'never',\n ],\n 'style/indent': [\n 'error',\n 4,\n ],\n 'style/max-len': [\n 'warn',\n {\n code: 120,\n comments: 120,\n ignoreStrings: true,\n ignoreTemplateLiterals: true,\n },\n ],\n 'style/member-delimiter-style': [\n 'error',\n {\n multiline: {\n delimiter: 'semi',\n requireLast: true,\n },\n },\n ],\n 'style/no-extra-parens': [\n 'error',\n 'all',\n { nestedBinaryExpressions: false },\n ],\n 'style/no-extra-semi': 'error',\n 'style/object-curly-newline': [\n 'error',\n {\n ExportDeclaration: {\n minProperties: 2,\n multiline: true,\n },\n ImportDeclaration: {\n minProperties: 2,\n multiline: true,\n },\n ObjectExpression: {\n minProperties: 2,\n multiline: true,\n },\n ObjectPattern: {\n minProperties: 3,\n multiline: true,\n },\n },\n ],\n 'style/operator-linebreak': [\n 'error',\n 'before',\n { overrides: { '=': 'after' } },\n ],\n 'style/padding-line-between-statements': [\n 'error',\n {\n blankLine: 'always',\n next: [\n 'class',\n 'enum',\n 'function',\n ],\n prev: '*',\n },\n {\n blankLine: 'always',\n next: '*',\n prev: [\n 'class',\n 'function',\n ],\n },\n ],\n 'style/semi': [\n 'error',\n 'always',\n ],\n };\n}\n"],"mappings":";;;;;;AAsBA,MAAM,+BAA+B;CACjC,YAAY;CACZ,MAAM;AACV;AAEA,MAAM,sCAAsC;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,CAAC,KAAK,GAAG;AAGV,SAAgB,kBAAkB,cAA8B,QAA+B;CAC3F,OAAO;EAEH,EACI,OAAO;GACH,yBAAyB,CACrB,SACA,EAAE,SAAS,CAAC,OAAO,EAAE,CACzB;GACA,4BAA4B;EAChC,EACJ;EAEA;GACI,OAAO;IACH;IACA;IACA;IACA;GACJ;GACA,SAAS;IACL,WAAW;IACX;GACJ;GACA,OAAO;IACH,GAAG,gBAAgB,WAAW;IAC9B,8BAA8B,CAC1B,SACA,QACJ;GACJ;GACA,UAAU;EACd;EAEA;GACI,OAAO,CACH,SACA,QACJ;GACA,OAAO;IACH,GAAG,sBAAsB;IACzB,iBAAiB,CACb,SACA,EAAE,SAAS,eAAe,CAC9B;IACA,sCAAsC,CAClC,SACA,aACJ;IACA,mBAAmB;GACvB;GAC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AAyB,CACrB,SACA,EAAE,aAAa,KAAK,CACxB;EACA,iCAAiC;EACjC,iDAAiD;GAC7C;GACA;GACA,EAAE,MAAM,EAAE,WAAW,SAAS,EAAE;EACpC;EACA,sCAAsC;EACtC,yCAAyC;EACzC,yCAAyC;EACzC,+BAA+B;EAC/B,wBAAwB,CACpB,SACA,CACJ;EACA,iCAAiC;EACjC,8BAA8B,CAC1B,SACA,EAAE,WAAW,KAAK,CACtB;EACA,yBAAyB;EACzB,qCAAqC,CACjC,SACA,4BACJ;EACA,4BAA4B,CACxB,SACA;GACI,GAAG;GACH,aAAa;EACjB,CACJ;EACA,uCAAuC,CACnC,SACA,4BACJ;EACA,8BAA8B,CAC1B,SACA;GACI;GACA,QAAQ;IACJ;IACA;IACA;IACA,CACI,iBACA,cACJ;IACA,CACI,kBACA,eACJ;IACA,CACI,kBACA,eACJ;IACA,CACI,gBACA,aACJ;IACA,CACI,iBACA,cACJ;IACA,CACI,eACA,YACJ;IACA;GACJ;GACA,YAAY;GACZ,iBAAiB;IACb;IACA;IACA;GACJ;GACA,MAAM;EACV,CACJ;EACA,iCAAiC,CAC7B,SACA,4BACJ;EACA,yCAAyC,CACrC,SACA,4BACJ;EACA,2BAA2B,CACvB,SACA,4BACJ;EACA,8BAA8B,CAC1B,SACA;GACI,GAAG;GACH,QAAQ;IACJ;IACA,CACI,eACA,MACJ;IACA;IACA,CACI,oBACA,WACJ;IACA;IACA,CACI,QACA,aACJ;IACA;IACA,CACI,SACA,cACJ;IACA;IACA,CACI,mBACA,UACJ;GACJ;EACJ,CACJ;EACA,mCAAmC,CAC/B,SACA,4BACJ;EACA,8BAA8B,CAC1B,SACA,4BACJ;EACA,2BAA2B,CACvB,SACA,4BACJ;EACA,kCAAkC,CAC9B,SACA;GACI,YAAY;GACZ,MAAM;EACV,CACJ;EACA,kCAAkC,CAC9B,SACA,4BACJ;EACA,4CAA4C,CACxC,SACA,4BACJ;EACA,yBAAyB;EACzB,gCAAgC;EAChC,gCAAgC;EAChC,0BAA0B;EAC1B,iBAAiB;EACjB,+BAA+B,CAC3B,SACA,EAAE,WAAW,KAAK,CACtB;EACA,+BAA+B,CAC3B,SACA;GACI,iBAAiB;IACb,YAAY;IACZ,UAAU;GACd;GACA,cAAc,EAAE,UAAU,EAAE;EAChC,CACJ;EACA,sBAAsB,CAClB,SACA,QACJ;EACA,qBAAqB;GACjB;GACA;GACA,EAAE,iBAAiB,MAAM;EAC7B;EACA,+BAA+B,CAC3B,SACA,OACJ;EACA,gBAAgB,CACZ,SACA,CACJ;EACA,iBAAiB,CACb,QACA;GACI,MAAM;GACN,UAAU;GACV,eAAe;GACf,wBAAwB;EAC5B,CACJ;EACA,gCAAgC,CAC5B,SACA,EACI,WAAW;GACP,WAAW;GACX,aAAa;EACjB,EACJ,CACJ;EACA,yBAAyB;GACrB;GACA;GACA,EAAE,yBAAyB,MAAM;EACrC;EACA,uBAAuB;EACvB,8BAA8B,CAC1B,SACA;GACI,mBAAmB;IACf,eAAe;IACf,WAAW;GACf;GACA,mBAAmB;IACf,eAAe;IACf,WAAW;GACf;GACA,kBAAkB;IACd,eAAe;IACf,WAAW;GACf;GACA,eAAe;IACX,eAAe;IACf,WAAW;GACf;EACJ,CACJ;EACA,4BAA4B;GACxB;GACA;GACA,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE;EAClC;EACA,yCAAyC;GACrC;GACA;IACI,WAAW;IACX,MAAM;KACF;KACA;KACA;IACJ;IACA,MAAM;GACV;GACA;IACI,WAAW;IACX,MAAM;IACN,MAAM,CACF,SACA,UACJ;GACJ;EACJ;EACA,cAAc,CACV,SACA,QACJ;CACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.2.0",
|
|
5
5
|
"description": "Using antfu/eslint-config as a base for eslint-config, slightly modified the settings and added additional plugins, mainly for my own use.",
|
|
6
6
|
"author": "kiki-kanri",
|
|
7
7
|
"license": "MIT",
|
|
@@ -9,7 +9,6 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
9
9
|
},
|
|
10
10
|
},
|
|
11
11
|
rules: {
|
|
12
|
-
'require-await': 'off',
|
|
13
12
|
'ts/await-thenable': 'error',
|
|
14
13
|
'ts/no-base-to-string': 'error',
|
|
15
14
|
'ts/no-floating-promises': [
|
|
@@ -28,8 +27,12 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
|
28
27
|
'ts/no-misused-promises': 'error',
|
|
29
28
|
'ts/no-misused-spread': 'error',
|
|
30
29
|
'ts/no-unnecessary-type-assertion': 'error',
|
|
31
|
-
'ts/
|
|
32
|
-
'ts/
|
|
30
|
+
'ts/promise-function-async': 'error',
|
|
31
|
+
'ts/require-await': 'off',
|
|
32
|
+
'ts/return-await': [
|
|
33
|
+
'error',
|
|
34
|
+
'always',
|
|
35
|
+
],
|
|
33
36
|
'ts/switch-exhaustiveness-check': [
|
|
34
37
|
'error',
|
|
35
38
|
{ considerDefaultExhaustiveForUnions: true },
|
package/src/base.ts
CHANGED
|
@@ -369,7 +369,7 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
|
369
369
|
'promise/no-multiple-resolved': 'error',
|
|
370
370
|
'promise/no-return-in-finally': 'error',
|
|
371
371
|
'promise/no-return-wrap': 'error',
|
|
372
|
-
'require-await': '
|
|
372
|
+
'require-await': 'off',
|
|
373
373
|
'style/array-bracket-newline': [
|
|
374
374
|
'error',
|
|
375
375
|
{ multiline: true },
|