@kikiutils/eslint-config 11.3.0 → 11.5.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 CHANGED
@@ -12,7 +12,7 @@ Description
12
12
 
13
13
  ## Requirements
14
14
 
15
- - **Node.js** `>=22.12.0`
15
+ - **Node.js** `>=24.15.0`
16
16
 
17
17
  ## Installation
18
18
 
@@ -16,11 +16,9 @@ function createBaseRules(environment = "node") {
16
16
  "antfu/reasonable-newline": "off",
17
17
  "arrow-body-style": ["error", "as-needed"],
18
18
  "curly": ["error", "multi-line"],
19
+ "jsdoc/check-param-names": ["warn", { disableMissingParamChecks: true }],
19
20
  "jsdoc/check-tag-names": "error",
20
- "jsdoc/multiline-blocks": ["error", {
21
- noSingleLineBlocks: true,
22
- singleLineTags: ["type", "import"]
23
- }],
21
+ "jsdoc/multiline-blocks": "error",
24
22
  "jsdoc/no-blank-blocks": ["error", { enableFixer: true }],
25
23
  "jsdoc/require-asterisk-prefix": "error",
26
24
  "jsdoc/require-hyphen-before-param-description": [
@@ -1 +1 @@
1
- {"version":3,"file":"base-rules.js","names":[],"sources":["../../../src/_internals/configs/base-rules.ts"],"sourcesContent":["import type { Rules } from '@antfu/eslint-config';\n\nimport { restrictedSyntax } from './restricted-syntax';\n\nconst basePerfectionistSortOptions = {\n ignoreCase: false,\n type: 'natural',\n} as const;\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/comment-indent': 'error',\n 'kikiutils/compact-iteration-layout': 'error',\n 'kikiutils/consistent-condition-layout': 'error',\n 'kikiutils/consistent-parameter-layout': 'error',\n 'kikiutils/no-silent-catch': 'error',\n 'kikiutils/statement-padding': 'error',\n 'max-classes-per-file': [\n 'error',\n 1,\n ],\n 'no-constant-binary-expression': 'error',\n // An ignored error needs at least a comment in the block saying why.\n 'no-empty': [\n 'error',\n { allowEmptyCatch: false },\n ],\n 'no-promise-executor-return': [\n 'error',\n { allowVoid: true },\n ],\n 'no-restricted-imports': [\n 'error',\n {\n patterns: [\n {\n message: '`_internals` modules are private to their own directory; import the public module instead.',\n regex: String.raw`^[^.].*/_internals(/|$)`,\n },\n ],\n },\n ],\n 'no-restricted-syntax': [\n 'error',\n ...restrictedSyntax,\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 'unicorn/no-useless-promise-resolve-reject': 'error',\n 'unicorn/no-useless-spread': 'error',\n 'unicorn/prefer-array-find': 'error',\n 'unicorn/prefer-array-some': 'error',\n 'unicorn/prefer-at': 'error',\n 'unicorn/prefer-string-replace-all': 'error',\n };\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"base-rules.js","names":[],"sources":["../../../src/_internals/configs/base-rules.ts"],"sourcesContent":["import type { Rules } from '@antfu/eslint-config';\n\nimport { restrictedSyntax } from './restricted-syntax';\n\nconst basePerfectionistSortOptions = {\n ignoreCase: false,\n type: 'natural',\n} as const;\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-param-names': [\n 'warn',\n { disableMissingParamChecks: true },\n ],\n 'jsdoc/check-tag-names': 'error',\n 'jsdoc/multiline-blocks': 'error',\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/comment-indent': 'error',\n 'kikiutils/compact-iteration-layout': 'error',\n 'kikiutils/consistent-condition-layout': 'error',\n 'kikiutils/consistent-parameter-layout': 'error',\n 'kikiutils/no-silent-catch': 'error',\n 'kikiutils/statement-padding': 'error',\n 'max-classes-per-file': [\n 'error',\n 1,\n ],\n 'no-constant-binary-expression': 'error',\n // An ignored error needs at least a comment in the block saying why.\n 'no-empty': [\n 'error',\n { allowEmptyCatch: false },\n ],\n 'no-promise-executor-return': [\n 'error',\n { allowVoid: true },\n ],\n 'no-restricted-imports': [\n 'error',\n {\n patterns: [\n {\n message: '`_internals` modules are private to their own directory; import the public module instead.',\n regex: String.raw`^[^.].*/_internals(/|$)`,\n },\n ],\n },\n ],\n 'no-restricted-syntax': [\n 'error',\n ...restrictedSyntax,\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 'unicorn/no-useless-promise-resolve-reject': 'error',\n 'unicorn/no-useless-spread': 'error',\n 'unicorn/prefer-array-find': 'error',\n 'unicorn/prefer-array-some': 'error',\n 'unicorn/prefer-at': 'error',\n 'unicorn/prefer-string-replace-all': 'error',\n };\n}\n"],"mappings":"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"}
@@ -16,10 +16,7 @@ export declare const typescriptJsdocConfig: {
16
16
  'jsdoc/check-tag-names': ["error", {
17
17
  definedTags: string[];
18
18
  }];
19
- 'jsdoc/multiline-blocks': ["error", {
20
- noSingleLineBlocks: true;
21
- singleLineTags: never[];
22
- }];
19
+ 'jsdoc/multiline-blocks': "error";
23
20
  'jsdoc/no-types': "error";
24
21
  };
25
22
  settings: {
@@ -26,10 +26,7 @@ const typescriptJsdocConfig = {
26
26
  "typeParam",
27
27
  "virtual"
28
28
  ] }],
29
- "jsdoc/multiline-blocks": ["error", {
30
- noSingleLineBlocks: true,
31
- singleLineTags: []
32
- }],
29
+ "jsdoc/multiline-blocks": "error",
33
30
  "jsdoc/no-types": "error"
34
31
  },
35
32
  settings: { jsdoc: {
@@ -1 +1 @@
1
- {"version":3,"file":"jsdoc.js","names":[],"sources":["../../../src/_internals/configs/jsdoc.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\n\nexport const jsdocSettings = {\n jsdoc: {\n tagNamePreference: {\n arg: 'param',\n argument: 'param',\n desc: false,\n description: false,\n exception: 'throws',\n return: 'returns',\n types: false,\n },\n },\n};\n\nexport const typescriptJsdocConfig = {\n rules: {\n 'jsdoc/check-tag-names': [\n 'error',\n {\n definedTags: [\n 'alpha',\n 'beta',\n 'defaultValue',\n 'eventProperty',\n 'experimental',\n 'hidden',\n 'inheritDoc',\n 'internal',\n 'packageDocumentation',\n 'privateRemarks',\n 'remarks',\n 'sealed',\n 'typeParam',\n 'virtual',\n ],\n },\n ],\n 'jsdoc/multiline-blocks': [\n 'error',\n {\n noSingleLineBlocks: true,\n singleLineTags: [],\n },\n ],\n 'jsdoc/no-types': 'error',\n },\n settings: {\n jsdoc: {\n mode: 'typescript',\n tagNamePreference: {\n ...jsdocSettings.jsdoc.tagNamePreference,\n callback: false,\n class: false,\n constructor: false,\n default: 'defaultValue',\n function: false,\n method: false,\n readonly: false,\n static: false,\n template: false,\n type: false,\n typedef: false,\n typeParam: 'typeParam',\n virtual: 'virtual',\n },\n },\n },\n} satisfies TypedFlatConfigItem;\n"],"mappings":";AAEA,MAAa,gBAAgB,EACzB,OAAO,EACH,mBAAmB;CACf,KAAK;CACL,UAAU;CACV,MAAM;CACN,aAAa;CACb,WAAW;CACX,QAAQ;CACR,OAAO;AACX,EACJ,EACJ;AAEA,MAAa,wBAAwB;CACjC,OAAO;EACH,yBAAyB,CACrB,SACA,EACI,aAAa;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACJ,EACJ,CACJ;EACA,0BAA0B,CACtB,SACA;GACI,oBAAoB;GACpB,gBAAgB,CAAC;EACrB,CACJ;EACA,kBAAkB;CACtB;CACA,UAAU,EACN,OAAO;EACH,MAAM;EACN,mBAAmB;GACf,GAAG,cAAc,MAAM;GACvB,UAAU;GACV,OAAO;GACP,aAAa;GACb,SAAS;GACT,UAAU;GACV,QAAQ;GACR,UAAU;GACV,QAAQ;GACR,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;GACX,SAAS;EACb;CACJ,EACJ;AACJ"}
1
+ {"version":3,"file":"jsdoc.js","names":[],"sources":["../../../src/_internals/configs/jsdoc.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\n\nexport const jsdocSettings = {\n jsdoc: {\n tagNamePreference: {\n arg: 'param',\n argument: 'param',\n desc: false,\n description: false,\n exception: 'throws',\n return: 'returns',\n types: false,\n },\n },\n};\n\nexport const typescriptJsdocConfig = {\n rules: {\n 'jsdoc/check-tag-names': [\n 'error',\n {\n definedTags: [\n 'alpha',\n 'beta',\n 'defaultValue',\n 'eventProperty',\n 'experimental',\n 'hidden',\n 'inheritDoc',\n 'internal',\n 'packageDocumentation',\n 'privateRemarks',\n 'remarks',\n 'sealed',\n 'typeParam',\n 'virtual',\n ],\n },\n ],\n 'jsdoc/multiline-blocks': 'error',\n 'jsdoc/no-types': 'error',\n },\n settings: {\n jsdoc: {\n mode: 'typescript',\n tagNamePreference: {\n ...jsdocSettings.jsdoc.tagNamePreference,\n callback: false,\n class: false,\n constructor: false,\n default: 'defaultValue',\n function: false,\n method: false,\n readonly: false,\n static: false,\n template: false,\n type: false,\n typedef: false,\n typeParam: 'typeParam',\n virtual: 'virtual',\n },\n },\n },\n} satisfies TypedFlatConfigItem;\n"],"mappings":";AAEA,MAAa,gBAAgB,EACzB,OAAO,EACH,mBAAmB;CACf,KAAK;CACL,UAAU;CACV,MAAM;CACN,aAAa;CACb,WAAW;CACX,QAAQ;CACR,OAAO;AACX,EACJ,EACJ;AAEA,MAAa,wBAAwB;CACjC,OAAO;EACH,yBAAyB,CACrB,SACA,EACI,aAAa;GACT;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACJ,EACJ,CACJ;EACA,0BAA0B;EAC1B,kBAAkB;CACtB;CACA,UAAU,EACN,OAAO;EACH,MAAM;EACN,mBAAmB;GACf,GAAG,cAAc,MAAM;GACvB,UAAU;GACV,OAAO;GACP,aAAa;GACb,SAAS;GACT,UAAU;GACV,QAAQ;GACR,UAAU;GACV,QAAQ;GACR,UAAU;GACV,MAAM;GACN,SAAS;GACT,WAAW;GACX,SAAS;EACb;CACJ,EACJ;AACJ"}
@@ -6,6 +6,7 @@ function createTypeAwareConfig() {
6
6
  tsconfigRootDir: process.cwd()
7
7
  } },
8
8
  rules: {
9
+ "kikiutils/no-thenable-zod-refinement": "error",
9
10
  "kikiutils/promise-function-async": "error",
10
11
  "no-implied-eval": "off",
11
12
  "no-throw-literal": "off",
@@ -23,7 +24,6 @@ function createTypeAwareConfig() {
23
24
  }] }],
24
25
  "ts/no-for-in-array": "error",
25
26
  "ts/no-implied-eval": "error",
26
- "ts/no-meaningless-void-operator": "error",
27
27
  "ts/no-misused-promises": "error",
28
28
  "ts/no-misused-spread": "error",
29
29
  "ts/no-unnecessary-boolean-literal-compare": "error",
@@ -1 +1 @@
1
- {"version":3,"file":"type-aware.js","names":[],"sources":["../../../src/_internals/configs/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 'kikiutils/promise-function-async': 'error',\n // The typed replacements below report these more accurately.\n 'no-implied-eval': 'off',\n 'no-throw-literal': 'off',\n 'prefer-promise-reject-errors': 'off',\n 'ts/await-thenable': 'error',\n 'ts/consistent-type-exports': 'error',\n 'ts/no-array-delete': 'error',\n 'ts/no-base-to-string': 'error',\n 'ts/no-deprecated': 'error',\n 'ts/no-duplicate-type-constituents': '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-implied-eval': 'error',\n 'ts/no-meaningless-void-operator': 'error',\n 'ts/no-misused-promises': 'error',\n 'ts/no-misused-spread': 'error',\n 'ts/no-unnecessary-boolean-literal-compare': 'error',\n 'ts/no-unnecessary-template-expression': 'error',\n 'ts/no-unnecessary-type-arguments': 'error',\n 'ts/no-unnecessary-type-assertion': 'error',\n 'ts/only-throw-error': 'error',\n // Matches only-throw-error, which allows `any` and `unknown` by default.\n 'ts/prefer-promise-reject-errors': [\n 'error',\n {\n allowThrowingAny: true,\n allowThrowingUnknown: true,\n },\n ],\n 'ts/promise-function-async': 'off',\n 'ts/require-await': 'off',\n // Exhaustive-switch fallbacks interpolate the `never` value into their error message.\n 'ts/restrict-template-expressions': [\n 'error',\n { allowNever: true },\n ],\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,oCAAoC;GAEpC,mBAAmB;GACnB,oBAAoB;GACpB,gCAAgC;GAChC,qBAAqB;GACrB,8BAA8B;GAC9B,sBAAsB;GACtB,wBAAwB;GACxB,oBAAoB;GACpB,qCAAqC;GACrC,2BAA2B,CACvB,SACA,EACI,2BAA2B,CACvB;IACI,MAAM;IACN,MAAM;IACN,SAAS;GACb,CACJ,EACJ,CACJ;GACA,sBAAsB;GACtB,sBAAsB;GACtB,mCAAmC;GACnC,0BAA0B;GAC1B,wBAAwB;GACxB,6CAA6C;GAC7C,yCAAyC;GACzC,oCAAoC;GACpC,oCAAoC;GACpC,uBAAuB;GAEvB,mCAAmC,CAC/B,SACA;IACI,kBAAkB;IAClB,sBAAsB;GAC1B,CACJ;GACA,6BAA6B;GAC7B,oBAAoB;GAEpB,oCAAoC,CAChC,SACA,EAAE,YAAY,KAAK,CACvB;GACA,mBAAmB,CACf,SACA,QACJ;GACA,kCAAkC,CAC9B,SACA,EAAE,oCAAoC,KAAK,CAC/C;EACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"type-aware.js","names":[],"sources":["../../../src/_internals/configs/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 'kikiutils/no-thenable-zod-refinement': 'error',\n 'kikiutils/promise-function-async': 'error',\n // The typed replacements below report these more accurately.\n 'no-implied-eval': 'off',\n 'no-throw-literal': 'off',\n 'prefer-promise-reject-errors': 'off',\n 'ts/await-thenable': 'error',\n 'ts/consistent-type-exports': 'error',\n 'ts/no-array-delete': 'error',\n 'ts/no-base-to-string': 'error',\n 'ts/no-deprecated': 'error',\n 'ts/no-duplicate-type-constituents': '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-implied-eval': 'error',\n 'ts/no-misused-promises': 'error',\n 'ts/no-misused-spread': 'error',\n 'ts/no-unnecessary-boolean-literal-compare': 'error',\n 'ts/no-unnecessary-template-expression': 'error',\n 'ts/no-unnecessary-type-arguments': 'error',\n 'ts/no-unnecessary-type-assertion': 'error',\n 'ts/only-throw-error': 'error',\n // Matches only-throw-error, which allows `any` and `unknown` by default.\n 'ts/prefer-promise-reject-errors': [\n 'error',\n {\n allowThrowingAny: true,\n allowThrowingUnknown: true,\n },\n ],\n 'ts/promise-function-async': 'off',\n 'ts/require-await': 'off',\n // Exhaustive-switch fallbacks interpolate the `never` value into their error message.\n 'ts/restrict-template-expressions': [\n 'error',\n { allowNever: true },\n ],\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,wCAAwC;GACxC,oCAAoC;GAEpC,mBAAmB;GACnB,oBAAoB;GACpB,gCAAgC;GAChC,qBAAqB;GACrB,8BAA8B;GAC9B,sBAAsB;GACtB,wBAAwB;GACxB,oBAAoB;GACpB,qCAAqC;GACrC,2BAA2B,CACvB,SACA,EACI,2BAA2B,CACvB;IACI,MAAM;IACN,MAAM;IACN,SAAS;GACb,CACJ,EACJ,CACJ;GACA,sBAAsB;GACtB,sBAAsB;GACtB,0BAA0B;GAC1B,wBAAwB;GACxB,6CAA6C;GAC7C,yCAAyC;GACzC,oCAAoC;GACpC,oCAAoC;GACpC,uBAAuB;GAEvB,mCAAmC,CAC/B,SACA;IACI,kBAAkB;IAClB,sBAAsB;GAC1B,CACJ;GACA,6BAA6B;GAC7B,oBAAoB;GAEpB,oCAAoC,CAChC,SACA,EAAE,YAAY,KAAK,CACvB;GACA,mBAAmB,CACf,SACA,QACJ;GACA,kCAAkC,CAC9B,SACA,EAAE,oCAAoC,KAAK,CAC/C;EACJ;CACJ;AACJ"}
@@ -11,6 +11,7 @@ export declare const customPlugins: {
11
11
  'no-restricted-nuxt-syntax': import("eslint").Rule.RuleModule;
12
12
  'no-restricted-test-imports': import("eslint").Rule.RuleModule;
13
13
  'no-silent-catch': import("eslint").Rule.RuleModule;
14
+ 'no-thenable-zod-refinement': import("eslint").Rule.RuleModule;
14
15
  'promise-function-async': import("eslint").Rule.RuleModule;
15
16
  'statement-padding': import("eslint").Rule.RuleModule;
16
17
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/_internals/rules/index.ts"],"mappings":"A,qBAmBa"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/_internals/rules/index.ts"],"mappings":"A,qBAoBa"}
@@ -6,6 +6,7 @@ import { consistentParameterLayout } from "./consistent-parameter-layout.js";
6
6
  import { nitroRouteMethodSuffix } from "./nitro-route-method-suffix.js";
7
7
  import { noComposableInHeadGetter } from "./no-composable-in-head-getter.js";
8
8
  import { noSilentCatch } from "./no-silent-catch.js";
9
+ import { noThenableZodRefinement } from "./no-thenable-zod-refinement.js";
9
10
  import { promiseFunctionAsync } from "./promise-function-async.js";
10
11
  import { statementPadding } from "./statement-padding.js";
11
12
  // src/_internals/rules/index.ts
@@ -24,6 +25,7 @@ const customPlugins = { rules: {
24
25
  "no-restricted-nuxt-syntax": noRestrictedSyntax,
25
26
  "no-restricted-test-imports": noRestrictedImports,
26
27
  "no-silent-catch": noSilentCatch,
28
+ "no-thenable-zod-refinement": noThenableZodRefinement,
27
29
  "promise-function-async": promiseFunctionAsync,
28
30
  "statement-padding": statementPadding
29
31
  } };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/_internals/rules/index.ts"],"sourcesContent":["import { builtinRules } from 'eslint/use-at-your-own-risk';\n\nimport { commentIndent } from './comment-indent';\nimport { compactIterationLayout } from './compact-iteration-layout';\nimport { consistentConditionLayout } from './consistent-condition-layout';\nimport { consistentParameterLayout } from './consistent-parameter-layout';\nimport { nitroRouteMethodSuffix } from './nitro-route-method-suffix';\nimport { noComposableInHeadGetter } from './no-composable-in-head-getter';\nimport { noSilentCatch } from './no-silent-catch';\nimport { promiseFunctionAsync } from './promise-function-async';\nimport { statementPadding } from './statement-padding';\n\n// Each scope adds its restrictions under its own name: a later config replaces a rule's whole option list,\n// so sharing the core rule would drop the restrictions of every broader scope.\n// eslint-disable-next-line ts/no-deprecated -- No supported API exposes core rules yet; typescript-eslint uses it too.\nconst coreRules = builtinRules;\nconst noRestrictedImports = coreRules.get('no-restricted-imports')!;\nconst noRestrictedSyntax = coreRules.get('no-restricted-syntax')!;\n\nexport const customPlugins = {\n rules: {\n 'comment-indent': commentIndent,\n 'compact-iteration-layout': compactIterationLayout,\n 'consistent-condition-layout': consistentConditionLayout,\n 'consistent-parameter-layout': consistentParameterLayout,\n 'nitro-route-method-suffix': nitroRouteMethodSuffix,\n 'no-composable-in-head-getter': noComposableInHeadGetter,\n 'no-restricted-nuxt-page-syntax': noRestrictedSyntax,\n 'no-restricted-nuxt-server-imports': noRestrictedImports,\n 'no-restricted-nuxt-syntax': noRestrictedSyntax,\n 'no-restricted-test-imports': noRestrictedImports,\n 'no-silent-catch': noSilentCatch,\n 'promise-function-async': promiseFunctionAsync,\n 'statement-padding': statementPadding,\n },\n};\n"],"mappings":";;;;;;;;;;;AAeA,MAAM,YAAY;AAClB,MAAM,sBAAsB,UAAU,IAAI,uBAAuB;AACjE,MAAM,qBAAqB,UAAU,IAAI,sBAAsB;AAE/D,MAAa,gBAAgB,EACzB,OAAO;CACH,kBAAkB;CAClB,4BAA4B;CAC5B,+BAA+B;CAC/B,+BAA+B;CAC/B,6BAA6B;CAC7B,gCAAgC;CAChC,kCAAkC;CAClC,qCAAqC;CACrC,6BAA6B;CAC7B,8BAA8B;CAC9B,mBAAmB;CACnB,0BAA0B;CAC1B,qBAAqB;AACzB,EACJ"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/_internals/rules/index.ts"],"sourcesContent":["import { builtinRules } from 'eslint/use-at-your-own-risk';\n\nimport { commentIndent } from './comment-indent';\nimport { compactIterationLayout } from './compact-iteration-layout';\nimport { consistentConditionLayout } from './consistent-condition-layout';\nimport { consistentParameterLayout } from './consistent-parameter-layout';\nimport { nitroRouteMethodSuffix } from './nitro-route-method-suffix';\nimport { noComposableInHeadGetter } from './no-composable-in-head-getter';\nimport { noSilentCatch } from './no-silent-catch';\nimport { noThenableZodRefinement } from './no-thenable-zod-refinement';\nimport { promiseFunctionAsync } from './promise-function-async';\nimport { statementPadding } from './statement-padding';\n\n// Each scope adds its restrictions under its own name: a later config replaces a rule's whole option list,\n// so sharing the core rule would drop the restrictions of every broader scope.\n// eslint-disable-next-line ts/no-deprecated -- No supported API exposes core rules yet; typescript-eslint uses it too.\nconst coreRules = builtinRules;\nconst noRestrictedImports = coreRules.get('no-restricted-imports')!;\nconst noRestrictedSyntax = coreRules.get('no-restricted-syntax')!;\n\nexport const customPlugins = {\n rules: {\n 'comment-indent': commentIndent,\n 'compact-iteration-layout': compactIterationLayout,\n 'consistent-condition-layout': consistentConditionLayout,\n 'consistent-parameter-layout': consistentParameterLayout,\n 'nitro-route-method-suffix': nitroRouteMethodSuffix,\n 'no-composable-in-head-getter': noComposableInHeadGetter,\n 'no-restricted-nuxt-page-syntax': noRestrictedSyntax,\n 'no-restricted-nuxt-server-imports': noRestrictedImports,\n 'no-restricted-nuxt-syntax': noRestrictedSyntax,\n 'no-restricted-test-imports': noRestrictedImports,\n 'no-silent-catch': noSilentCatch,\n 'no-thenable-zod-refinement': noThenableZodRefinement,\n 'promise-function-async': promiseFunctionAsync,\n 'statement-padding': statementPadding,\n },\n};\n"],"mappings":";;;;;;;;;;;;AAgBA,MAAM,YAAY;AAClB,MAAM,sBAAsB,UAAU,IAAI,uBAAuB;AACjE,MAAM,qBAAqB,UAAU,IAAI,sBAAsB;AAE/D,MAAa,gBAAgB,EACzB,OAAO;CACH,kBAAkB;CAClB,4BAA4B;CAC5B,+BAA+B;CAC/B,+BAA+B;CAC/B,6BAA6B;CAC7B,gCAAgC;CAChC,kCAAkC;CAClC,qCAAqC;CACrC,6BAA6B;CAC7B,8BAA8B;CAC9B,mBAAmB;CACnB,8BAA8B;CAC9B,0BAA0B;CAC1B,qBAAqB;AACzB,EACJ"}
@@ -18,7 +18,8 @@ const noSilentCatch = {
18
18
  const { callee } = node;
19
19
  const callback = node.arguments[0];
20
20
  if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier" || callee.property.name !== "catch" || !callback || !isSilent(callback)) return;
21
- if (context.sourceCode.getCommentsInside(callback).length) return;
21
+ const { sourceCode } = context;
22
+ if ([...sourceCode.getCommentsBefore(callback), ...sourceCode.getCommentsInside(callback)].length) return;
22
23
  context.report({
23
24
  messageId: "silent",
24
25
  node: callback
@@ -27,7 +28,7 @@ const noSilentCatch = {
27
28
  },
28
29
  meta: {
29
30
  docs: { description: "Disallow `.catch()` callbacks that silently swallow the rejection." },
30
- messages: { silent: "Do not swallow the rejection silently: log it, or add a comment in the callback explaining why it can be ignored." },
31
+ 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." },
31
32
  schema: [],
32
33
  type: "problem"
33
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"no-silent-catch.js","names":[],"sources":["../../../src/_internals/rules/no-silent-catch.ts"],"sourcesContent":["import type { Rule } from 'eslint';\n\ntype CallArgument = Extract<Rule.Node, { type: 'CallExpression' }>['arguments'][number];\ntype Expression = Exclude<CallArgument, { type: 'SpreadElement' }>;\n\nfunction isNothing(node: Expression | null | undefined): boolean {\n if (!node) return true;\n if (node.type === 'Identifier') return node.name === 'undefined';\n if (node.type === 'Literal') return node.raw === 'null';\n return node.type === 'UnaryExpression' && node.operator === 'void' && node.argument.type === 'Literal';\n}\n\nfunction isSilent(callback: CallArgument): boolean {\n if (callback.type !== 'ArrowFunctionExpression' && callback.type !== 'FunctionExpression') return false;\n const { body } = callback;\n if (body.type !== 'BlockStatement') return isNothing(body);\n const [statement, ...rest] = body.body;\n return !statement || (!rest.length && statement.type === 'ReturnStatement' && isNothing(statement.argument));\n}\n\nexport const noSilentCatch: Rule.RuleModule = {\n create(context) {\n return {\n CallExpression(node) {\n const { callee } = node;\n const callback = node.arguments[0];\n if (\n callee.type !== 'MemberExpression'\n || callee.computed\n || callee.property.type !== 'Identifier'\n || callee.property.name !== 'catch'\n || !callback\n || !isSilent(callback)\n ) return;\n\n // A comment inside the callback is the reason the rejection can be ignored.\n if (context.sourceCode.getCommentsInside(callback).length) return;\n context.report({\n messageId: 'silent',\n node: callback,\n });\n },\n };\n },\n meta: {\n docs: { description: 'Disallow `.catch()` callbacks that silently swallow the rejection.' },\n messages: { silent: 'Do not swallow the rejection silently: log it, or add a comment in the callback explaining why it can be ignored.' },\n schema: [],\n type: 'problem',\n },\n};\n"],"mappings":";AAKA,SAAS,UAAU,MAA8C;CAC7D,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,KAAK,SAAS,cAAc,OAAO,KAAK,SAAS;CACrD,IAAI,KAAK,SAAS,WAAW,OAAO,KAAK,QAAQ;CACjD,OAAO,KAAK,SAAS,qBAAqB,KAAK,aAAa,UAAU,KAAK,SAAS,SAAS;AACjG;AAEA,SAAS,SAAS,UAAiC;CAC/C,IAAI,SAAS,SAAS,6BAA6B,SAAS,SAAS,sBAAsB,OAAO;CAClG,MAAM,EAAE,SAAS;CACjB,IAAI,KAAK,SAAS,kBAAkB,OAAO,UAAU,IAAI;CACzD,MAAM,CAAC,WAAW,GAAG,QAAQ,KAAK;CAClC,OAAO,CAAC,aAAc,CAAC,KAAK,UAAU,UAAU,SAAS,qBAAqB,UAAU,UAAU,QAAQ;AAC9G;AAEA,MAAa,gBAAiC;CAC1C,OAAO,SAAS;EACZ,OAAO,EACH,eAAe,MAAM;GACjB,MAAM,EAAE,WAAW;GACnB,MAAM,WAAW,KAAK,UAAU;GAChC,IACI,OAAO,SAAS,sBACb,OAAO,YACP,OAAO,SAAS,SAAS,gBACzB,OAAO,SAAS,SAAS,WACzB,CAAC,YACD,CAAC,SAAS,QAAQ,GACvB;GAGF,IAAI,QAAQ,WAAW,kBAAkB,QAAQ,CAAC,CAAC,QAAQ;GAC3D,QAAQ,OAAO;IACX,WAAW;IACX,MAAM;GACV,CAAC;EACL,EACJ;CACJ;CACA,MAAM;EACF,MAAM,EAAE,aAAa,qEAAqE;EAC1F,UAAU,EAAE,QAAQ,oHAAoH;EACxI,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
1
+ {"version":3,"file":"no-silent-catch.js","names":[],"sources":["../../../src/_internals/rules/no-silent-catch.ts"],"sourcesContent":["import type { Rule } from 'eslint';\n\ntype CallArgument = Extract<Rule.Node, { type: 'CallExpression' }>['arguments'][number];\ntype Expression = Exclude<CallArgument, { type: 'SpreadElement' }>;\n\nfunction isNothing(node: Expression | null | undefined): boolean {\n if (!node) return true;\n if (node.type === 'Identifier') return node.name === 'undefined';\n if (node.type === 'Literal') return node.raw === 'null';\n return node.type === 'UnaryExpression' && node.operator === 'void' && node.argument.type === 'Literal';\n}\n\nfunction isSilent(callback: CallArgument): boolean {\n if (callback.type !== 'ArrowFunctionExpression' && callback.type !== 'FunctionExpression') return false;\n const { body } = callback;\n if (body.type !== 'BlockStatement') return isNothing(body);\n const [statement, ...rest] = body.body;\n return !statement || (!rest.length && statement.type === 'ReturnStatement' && isNothing(statement.argument));\n}\n\nexport const noSilentCatch: Rule.RuleModule = {\n create(context) {\n return {\n CallExpression(node) {\n const { callee } = node;\n const callback = node.arguments[0];\n if (\n callee.type !== 'MemberExpression'\n || callee.computed\n || callee.property.type !== 'Identifier'\n || callee.property.name !== 'catch'\n || !callback\n || !isSilent(callback)\n ) return;\n\n // A comment right before or inside the callback is the reason the rejection can be ignored.\n const { sourceCode } = context;\n if (\n [\n ...sourceCode.getCommentsBefore(callback),\n ...sourceCode.getCommentsInside(callback),\n ].length\n ) return;\n\n context.report({\n messageId: 'silent',\n node: callback,\n });\n },\n };\n },\n meta: {\n docs: { description: 'Disallow `.catch()` callbacks that silently swallow the rejection.' },\n 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.' },\n schema: [],\n type: 'problem',\n },\n};\n"],"mappings":";AAKA,SAAS,UAAU,MAA8C;CAC7D,IAAI,CAAC,MAAM,OAAO;CAClB,IAAI,KAAK,SAAS,cAAc,OAAO,KAAK,SAAS;CACrD,IAAI,KAAK,SAAS,WAAW,OAAO,KAAK,QAAQ;CACjD,OAAO,KAAK,SAAS,qBAAqB,KAAK,aAAa,UAAU,KAAK,SAAS,SAAS;AACjG;AAEA,SAAS,SAAS,UAAiC;CAC/C,IAAI,SAAS,SAAS,6BAA6B,SAAS,SAAS,sBAAsB,OAAO;CAClG,MAAM,EAAE,SAAS;CACjB,IAAI,KAAK,SAAS,kBAAkB,OAAO,UAAU,IAAI;CACzD,MAAM,CAAC,WAAW,GAAG,QAAQ,KAAK;CAClC,OAAO,CAAC,aAAc,CAAC,KAAK,UAAU,UAAU,SAAS,qBAAqB,UAAU,UAAU,QAAQ;AAC9G;AAEA,MAAa,gBAAiC;CAC1C,OAAO,SAAS;EACZ,OAAO,EACH,eAAe,MAAM;GACjB,MAAM,EAAE,WAAW;GACnB,MAAM,WAAW,KAAK,UAAU;GAChC,IACI,OAAO,SAAS,sBACb,OAAO,YACP,OAAO,SAAS,SAAS,gBACzB,OAAO,SAAS,SAAS,WACzB,CAAC,YACD,CAAC,SAAS,QAAQ,GACvB;GAGF,MAAM,EAAE,eAAe;GACvB,IACI,CACI,GAAG,WAAW,kBAAkB,QAAQ,GACxC,GAAG,WAAW,kBAAkB,QAAQ,CAC5C,CAAC,CAAC,QACJ;GAEF,QAAQ,OAAO;IACX,WAAW;IACX,MAAM;GACV,CAAC;EACL,EACJ;CACJ;CACA,MAAM;EACF,MAAM,EAAE,aAAa,qEAAqE;EAC1F,UAAU,EAAE,QAAQ,kIAAkI;EACtJ,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
@@ -0,0 +1,3 @@
1
+ import { Rule } from "eslint";
2
+ export declare const noThenableZodRefinement: Rule.RuleModule;
3
+ //# sourceMappingURL=no-thenable-zod-refinement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-thenable-zod-refinement.d.ts","names":[],"sources":["../../../src/_internals/rules/no-thenable-zod-refinement.ts"],"mappings":";qBAyBa,yBAAyB,KAAK"}
@@ -0,0 +1,41 @@
1
+ // src/_internals/rules/no-thenable-zod-refinement.ts
2
+ const refinementMethods = /* @__PURE__ */ new Set([
3
+ "check",
4
+ "refine",
5
+ "superRefine"
6
+ ]);
7
+ function isNonPromiseThenable(type) {
8
+ return (type.isUnion() ? type.types : [type]).some((part) => part.getProperty("then") && part.getSymbol()?.getName() !== "Promise");
9
+ }
10
+ const noThenableZodRefinement = {
11
+ create(context) {
12
+ const services = context.sourceCode.parserServices;
13
+ const checker = services.program.getTypeChecker();
14
+ const getType = (node) => checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node));
15
+ return { CallExpression(node) {
16
+ const { callee } = node;
17
+ if (callee.type !== "MemberExpression" || callee.computed || callee.property.type !== "Identifier" || !refinementMethods.has(callee.property.name) || !getType(node).getProperty("_zod")) return;
18
+ const method = callee.property.name;
19
+ for (const callback of node.arguments) {
20
+ if (!getType(callback).getCallSignatures().some((signature) => isNonPromiseThenable(checker.getReturnTypeOfSignature(signature)))) continue;
21
+ context.report({
22
+ data: { method },
23
+ messageId: "thenable",
24
+ node: callback
25
+ });
26
+ }
27
+ } };
28
+ },
29
+ meta: {
30
+ docs: {
31
+ description: "Disallow Zod refinements and checks that return a thenable other than a Promise.",
32
+ requiresTypeChecking: true
33
+ },
34
+ 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." },
35
+ schema: [],
36
+ type: "problem"
37
+ }
38
+ };
39
+ export { noThenableZodRefinement };
40
+
41
+ //# sourceMappingURL=no-thenable-zod-refinement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-thenable-zod-refinement.js","names":[],"sources":["../../../src/_internals/rules/no-thenable-zod-refinement.ts"],"sourcesContent":["import type { Rule } from 'eslint';\nimport type {\n Node,\n Type,\n TypeChecker,\n} from 'typescript';\n\ninterface ParserServices {\n esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };\n program: { getTypeChecker: () => TypeChecker };\n}\n\nconst refinementMethods = new Set([\n 'check',\n 'refine',\n 'superRefine',\n]);\n\n// Zod awaits a refinement only when it returns a native Promise; any other thenable counts as a truthy result.\nfunction isNonPromiseThenable(type: Type): boolean {\n return (type.isUnion() ? type.types : [type]).some(\n (part) => part.getProperty('then') && part.getSymbol()?.getName() !== 'Promise',\n );\n}\n\nexport const noThenableZodRefinement: Rule.RuleModule = {\n create(context) {\n const services = context.sourceCode.parserServices as ParserServices;\n const checker = services.program.getTypeChecker();\n const getType = (node: unknown) => checker.getTypeAtLocation(services.esTreeNodeToTSNodeMap.get(node));\n\n return {\n CallExpression(node) {\n const { callee } = node;\n if (\n callee.type !== 'MemberExpression'\n || callee.computed\n || callee.property.type !== 'Identifier'\n || !refinementMethods.has(callee.property.name)\n // Covers schema methods such as `z.objectId().refine()` and standalone checks such as `z.refine()`.\n || !getType(node).getProperty('_zod')\n ) return;\n\n const method = callee.property.name;\n // `.check()` takes several checks; non-function checks have no call signatures.\n for (const callback of node.arguments) {\n const returnsThenable = getType(callback)\n .getCallSignatures()\n .some((signature) => isNonPromiseThenable(checker.getReturnTypeOfSignature(signature)));\n\n if (!returnsThenable) continue;\n context.report({\n data: { method },\n messageId: 'thenable',\n node: callback,\n });\n }\n },\n };\n },\n meta: {\n docs: {\n description: 'Disallow Zod refinements and checks that return a thenable other than a Promise.',\n requiresTypeChecking: true,\n } as Rule.RuleMetaData['docs'],\n 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.' },\n schema: [],\n type: 'problem',\n },\n};\n"],"mappings":";AAYA,MAAM,oCAAoB,IAAI,IAAI;CAC9B;CACA;CACA;AACJ,CAAC;AAGD,SAAS,qBAAqB,MAAqB;CAC/C,QAAQ,KAAK,QAAQ,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAA,CAAG,MACzC,SAAS,KAAK,YAAY,MAAM,KAAK,KAAK,UAAU,CAAC,EAAE,QAAQ,MAAM,SAC1E;AACJ;AAEA,MAAa,0BAA2C;CACpD,OAAO,SAAS;EACZ,MAAM,WAAW,QAAQ,WAAW;EACpC,MAAM,UAAU,SAAS,QAAQ,eAAe;EAChD,MAAM,WAAW,SAAkB,QAAQ,kBAAkB,SAAS,sBAAsB,IAAI,IAAI,CAAC;EAErG,OAAO,EACH,eAAe,MAAM;GACjB,MAAM,EAAE,WAAW;GACnB,IACI,OAAO,SAAS,sBACb,OAAO,YACP,OAAO,SAAS,SAAS,gBACzB,CAAC,kBAAkB,IAAI,OAAO,SAAS,IAAI,KAE3C,CAAC,QAAQ,IAAI,CAAC,CAAC,YAAY,MAAM,GACtC;GAEF,MAAM,SAAS,OAAO,SAAS;GAE/B,KAAK,MAAM,YAAY,KAAK,WAAW;IAKnC,IAAI,CAJoB,QAAQ,QAAQ,CAAC,CACpC,kBAAkB,CAAC,CACnB,MAAM,cAAc,qBAAqB,QAAQ,yBAAyB,SAAS,CAAC,CAEtE,GAAG;IACtB,QAAQ,OAAO;KACX,MAAM,EAAE,OAAO;KACf,WAAW;KACX,MAAM;IACV,CAAC;GACL;EACJ,EACJ;CACJ;CACA,MAAM;EACF,MAAM;GACF,aAAa;GACb,sBAAsB;EAC1B;EACA,UAAU,EAAE,UAAU,wLAAyL;EAC/M,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kikiutils/eslint-config",
3
3
  "type": "module",
4
- "version": "11.3.0",
4
+ "version": "11.5.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",
@@ -23,7 +23,7 @@
23
23
  "./src"
24
24
  ],
25
25
  "engines": {
26
- "node": ">=22.12.0"
26
+ "node": ">=24.15.0"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsdown",
@@ -33,7 +33,7 @@
33
33
  "lint": "eslint --cache --concurrency=auto --max-warnings 0",
34
34
  "lint:fix": "eslint --cache --concurrency=auto --fix --max-warnings 0",
35
35
  "prepack": "pnpm run build",
36
- "release": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && changelogen --hideAuthorEmail --push --release && npm publish",
36
+ "release": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && changelogen --clean --hideAuthorEmail --push --release && npm publish",
37
37
  "test": "vitest run --coverage",
38
38
  "test:watch": "vitest watch --coverage",
39
39
  "typecheck": "tsc -b --noEmit"
@@ -55,9 +55,9 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@eslint/css": "^2.0.1",
58
- "@html-eslint/parser": "^0.68.0",
58
+ "@html-eslint/parser": "^0.69.0",
59
59
  "@kikiutils/eslint-plugin-vue": "^10.10.0",
60
- "@typescript-eslint/eslint-plugin": "^8.73.0",
60
+ "@typescript-eslint/eslint-plugin": "^8.74.0",
61
61
  "eslint-plugin-better-tailwindcss": "^4.11.0",
62
62
  "eslint-plugin-format": "^2.0.1",
63
63
  "eslint-plugin-promise": "^7.3.0",
@@ -68,9 +68,9 @@
68
68
  "devDependencies": {
69
69
  "@antfu/eslint-config": "^10.0.0",
70
70
  "@arethetypeswrong/core": "^0.18.5",
71
- "@kikiutils/tsconfigs": "^7.0.0",
72
- "@types/node": "^26.6.6",
73
- "@vitest/coverage-v8": "^5.1.1",
71
+ "@kikiutils/tsconfigs": "^8.0.0",
72
+ "@types/node": "^26.6.11",
73
+ "@vitest/coverage-v8": "^5.1.2",
74
74
  "changelogen": "^0.6.2",
75
75
  "eslint": "^10.15.0",
76
76
  "knip": "^6.48.0",
@@ -80,6 +80,6 @@
80
80
  "type-fest": "^6.0.3",
81
81
  "typescript": "^6.0.3",
82
82
  "unplugin-unused": "^0.6.0",
83
- "vitest": "^5.1.1"
83
+ "vitest": "^5.1.2"
84
84
  }
85
85
  }
@@ -28,17 +28,12 @@ export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
28
28
  'error',
29
29
  'multi-line',
30
30
  ],
31
- 'jsdoc/check-tag-names': 'error',
32
- 'jsdoc/multiline-blocks': [
33
- 'error',
34
- {
35
- noSingleLineBlocks: true,
36
- singleLineTags: [
37
- 'type',
38
- 'import',
39
- ],
40
- },
31
+ 'jsdoc/check-param-names': [
32
+ 'warn',
33
+ { disableMissingParamChecks: true },
41
34
  ],
35
+ 'jsdoc/check-tag-names': 'error',
36
+ 'jsdoc/multiline-blocks': 'error',
42
37
  'jsdoc/no-blank-blocks': [
43
38
  'error',
44
39
  { enableFixer: true },
@@ -37,13 +37,7 @@ export const typescriptJsdocConfig = {
37
37
  ],
38
38
  },
39
39
  ],
40
- 'jsdoc/multiline-blocks': [
41
- 'error',
42
- {
43
- noSingleLineBlocks: true,
44
- singleLineTags: [],
45
- },
46
- ],
40
+ 'jsdoc/multiline-blocks': 'error',
47
41
  'jsdoc/no-types': 'error',
48
42
  },
49
43
  settings: {
@@ -9,6 +9,7 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
9
9
  },
10
10
  },
11
11
  rules: {
12
+ 'kikiutils/no-thenable-zod-refinement': 'error',
12
13
  'kikiutils/promise-function-async': 'error',
13
14
  // The typed replacements below report these more accurately.
14
15
  'no-implied-eval': 'off',
@@ -34,7 +35,6 @@ export function createTypeAwareConfig(): TypedFlatConfigItem {
34
35
  ],
35
36
  'ts/no-for-in-array': 'error',
36
37
  'ts/no-implied-eval': 'error',
37
- 'ts/no-meaningless-void-operator': 'error',
38
38
  'ts/no-misused-promises': 'error',
39
39
  'ts/no-misused-spread': 'error',
40
40
  'ts/no-unnecessary-boolean-literal-compare': 'error',
@@ -7,6 +7,7 @@ import { consistentParameterLayout } from './consistent-parameter-layout';
7
7
  import { nitroRouteMethodSuffix } from './nitro-route-method-suffix';
8
8
  import { noComposableInHeadGetter } from './no-composable-in-head-getter';
9
9
  import { noSilentCatch } from './no-silent-catch';
10
+ import { noThenableZodRefinement } from './no-thenable-zod-refinement';
10
11
  import { promiseFunctionAsync } from './promise-function-async';
11
12
  import { statementPadding } from './statement-padding';
12
13
 
@@ -30,6 +31,7 @@ export const customPlugins = {
30
31
  'no-restricted-nuxt-syntax': noRestrictedSyntax,
31
32
  'no-restricted-test-imports': noRestrictedImports,
32
33
  'no-silent-catch': noSilentCatch,
34
+ 'no-thenable-zod-refinement': noThenableZodRefinement,
33
35
  'promise-function-async': promiseFunctionAsync,
34
36
  'statement-padding': statementPadding,
35
37
  },
@@ -33,8 +33,15 @@ export const noSilentCatch: Rule.RuleModule = {
33
33
  || !isSilent(callback)
34
34
  ) return;
35
35
 
36
- // A comment inside the callback is the reason the rejection can be ignored.
37
- if (context.sourceCode.getCommentsInside(callback).length) return;
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
+
38
45
  context.report({
39
46
  messageId: 'silent',
40
47
  node: callback,
@@ -44,7 +51,7 @@ export const noSilentCatch: Rule.RuleModule = {
44
51
  },
45
52
  meta: {
46
53
  docs: { description: 'Disallow `.catch()` callbacks that silently swallow the rejection.' },
47
- messages: { silent: 'Do not swallow the rejection silently: log it, or add a comment in the callback explaining why it can be ignored.' },
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.' },
48
55
  schema: [],
49
56
  type: 'problem',
50
57
  },
@@ -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
+ };