@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.
- package/dist/_internals/configs/base-rules.d.ts +3 -0
- package/dist/_internals/configs/base-rules.d.ts.map +1 -0
- package/dist/_internals/configs/base-rules.js +190 -0
- package/dist/_internals/configs/base-rules.js.map +1 -0
- package/dist/_internals/configs/jsdoc.d.ts.map +1 -0
- package/dist/_internals/{jsdoc.js → configs/jsdoc.js} +1 -1
- package/dist/_internals/configs/jsdoc.js.map +1 -0
- package/dist/_internals/configs/restricted-syntax.d.ts.map +1 -0
- package/dist/_internals/configs/restricted-syntax.js +12 -0
- package/dist/_internals/configs/restricted-syntax.js.map +1 -0
- package/dist/_internals/configs/type-aware.d.ts.map +1 -0
- package/dist/_internals/configs/type-aware.js +48 -0
- package/dist/_internals/configs/type-aware.js.map +1 -0
- package/dist/_internals/configs/typefest.d.ts.map +1 -0
- package/dist/_internals/{typefest.js → configs/typefest.js} +1 -1
- package/dist/_internals/configs/typefest.js.map +1 -0
- package/dist/_internals/rules/comment-indent.d.ts +3 -0
- package/dist/_internals/rules/comment-indent.d.ts.map +1 -0
- package/dist/_internals/rules/comment-indent.js +58 -0
- package/dist/_internals/rules/comment-indent.js.map +1 -0
- package/dist/_internals/rules/index.d.ts +19 -0
- package/dist/_internals/rules/index.d.ts.map +1 -0
- package/dist/_internals/rules/index.js +34 -0
- package/dist/_internals/rules/index.js.map +1 -0
- package/dist/_internals/rules/nitro-route-method-suffix.d.ts +3 -0
- package/dist/_internals/rules/nitro-route-method-suffix.d.ts.map +1 -0
- package/dist/_internals/rules/nitro-route-method-suffix.js +25 -0
- package/dist/_internals/rules/nitro-route-method-suffix.js.map +1 -0
- package/dist/_internals/rules/no-composable-in-head-getter.d.ts +3 -0
- package/dist/_internals/rules/no-composable-in-head-getter.d.ts.map +1 -0
- package/dist/_internals/rules/no-composable-in-head-getter.js +41 -0
- package/dist/_internals/rules/no-composable-in-head-getter.js.map +1 -0
- package/dist/_internals/rules/no-silent-catch.d.ts +3 -0
- package/dist/_internals/rules/no-silent-catch.d.ts.map +1 -0
- package/dist/_internals/rules/no-silent-catch.js +38 -0
- package/dist/_internals/rules/no-silent-catch.js.map +1 -0
- package/dist/_internals/rules/no-thenable-zod-refinement.d.ts +3 -0
- package/dist/_internals/rules/no-thenable-zod-refinement.d.ts.map +1 -0
- package/dist/_internals/rules/no-thenable-zod-refinement.js +41 -0
- package/dist/_internals/rules/no-thenable-zod-refinement.js.map +1 -0
- package/dist/_internals/rules/promise-function-async.d.ts +3 -0
- package/dist/_internals/rules/promise-function-async.d.ts.map +1 -0
- package/dist/_internals/rules/promise-function-async.js +32 -0
- package/dist/_internals/rules/promise-function-async.js.map +1 -0
- package/dist/_internals/rules/statement-padding.js +2 -1
- package/dist/_internals/rules/statement-padding.js.map +1 -1
- package/dist/base.d.ts +3 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +6 -183
- package/dist/base.js.map +1 -1
- package/dist/nuxt.d.ts +3 -0
- package/dist/nuxt.d.ts.map +1 -0
- package/dist/nuxt.js +94 -0
- package/dist/nuxt.js.map +1 -0
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +11 -14
- package/dist/vue.js.map +1 -1
- package/package.json +8 -6
- package/src/_internals/configs/base-rules.ts +335 -0
- package/src/_internals/{restricted-syntax.ts → configs/restricted-syntax.ts} +0 -4
- package/src/_internals/configs/type-aware.ts +70 -0
- package/src/_internals/rules/comment-indent.ts +87 -0
- package/src/_internals/rules/index.ts +38 -0
- package/src/_internals/rules/nitro-route-method-suffix.ts +27 -0
- package/src/_internals/rules/no-composable-in-head-getter.ts +52 -0
- package/src/_internals/rules/no-silent-catch.ts +58 -0
- package/src/_internals/rules/no-thenable-zod-refinement.ts +70 -0
- package/src/_internals/rules/promise-function-async.ts +56 -0
- package/src/_internals/rules/statement-padding.ts +1 -0
- package/src/base.ts +9 -334
- package/src/nuxt.ts +131 -0
- package/src/vue.ts +11 -14
- package/dist/_internals/jsdoc.d.ts.map +0 -1
- package/dist/_internals/jsdoc.js.map +0 -1
- package/dist/_internals/plugins.d.ts +0 -9
- package/dist/_internals/plugins.d.ts.map +0 -1
- package/dist/_internals/plugins.js +0 -14
- package/dist/_internals/plugins.js.map +0 -1
- package/dist/_internals/restricted-syntax.d.ts.map +0 -1
- package/dist/_internals/restricted-syntax.js +0 -16
- package/dist/_internals/restricted-syntax.js.map +0 -1
- package/dist/_internals/type-aware.d.ts.map +0 -1
- package/dist/_internals/type-aware.js +0 -29
- package/dist/_internals/type-aware.js.map +0 -1
- package/dist/_internals/typefest.d.ts.map +0 -1
- package/dist/_internals/typefest.js.map +0 -1
- package/src/_internals/plugins.ts +0 -13
- package/src/_internals/type-aware.ts +0 -42
- /package/dist/_internals/{jsdoc.d.ts → configs/jsdoc.d.ts} +0 -0
- /package/dist/_internals/{restricted-syntax.d.ts → configs/restricted-syntax.d.ts} +0 -0
- /package/dist/_internals/{type-aware.d.ts → configs/type-aware.d.ts} +0 -0
- /package/dist/_internals/{typefest.d.ts → configs/typefest.d.ts} +0 -0
- /package/src/_internals/{jsdoc.ts → configs/jsdoc.ts} +0 -0
- /package/src/_internals/{typefest.ts → configs/typefest.ts} +0 -0
package/dist/vue.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import kikiutilsEslintPluginVue from "@kikiutils/eslint-plugin-vue";
|
|
2
2
|
import betterTailwindcss from "eslint-plugin-better-tailwindcss";
|
|
3
3
|
import promise from "eslint-plugin-promise";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { createBaseRules } from "./base.js";
|
|
4
|
+
import { createBaseRules } from "./_internals/configs/base-rules.js";
|
|
5
|
+
import { typescriptJsdocConfig } from "./_internals/configs/jsdoc.js";
|
|
6
|
+
import { createTypeAwareConfig } from "./_internals/configs/type-aware.js";
|
|
7
|
+
import { createTypefestConfig } from "./_internals/configs/typefest.js";
|
|
8
|
+
import { customPlugins } from "./_internals/rules/index.js";
|
|
10
9
|
// src/vue.ts
|
|
11
10
|
function createVueConfig(environment = "node") {
|
|
12
11
|
const typeAwareConfig = createTypeAwareConfig();
|
|
@@ -39,14 +38,6 @@ function createVueConfig(environment = "node") {
|
|
|
39
38
|
"better-tailwindcss/no-deprecated-classes": "warn",
|
|
40
39
|
"better-tailwindcss/no-duplicate-classes": "error",
|
|
41
40
|
"better-tailwindcss/no-unnecessary-whitespace": "error",
|
|
42
|
-
"no-restricted-syntax": [
|
|
43
|
-
"error",
|
|
44
|
-
...restrictedSyntax,
|
|
45
|
-
{
|
|
46
|
-
message: "Do not redirect with a top-level `await navigateTo()` in setup: under KeepAlive it interrupts a pending Suspense and leaves the page stuck. Use `definePageMeta({ redirect })` or a route middleware.",
|
|
47
|
-
selector: "Program > ExpressionStatement > AwaitExpression > CallExpression[callee.name=\"navigateTo\"]"
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
41
|
"style/max-len": "off",
|
|
51
42
|
"ts/array-type": ["error", { default: "array-simple" }],
|
|
52
43
|
"vue/attribute-hyphenation": "error",
|
|
@@ -75,14 +66,20 @@ function createVueConfig(environment = "node") {
|
|
|
75
66
|
template: 120
|
|
76
67
|
}],
|
|
77
68
|
"vue/no-dupe-keys": "error",
|
|
69
|
+
"vue/no-import-compiler-macros": "error",
|
|
78
70
|
"vue/no-lone-template": "error",
|
|
79
71
|
"vue/no-multi-spaces": "error",
|
|
80
72
|
"vue/no-multiple-objects-in-class": "error",
|
|
81
73
|
"vue/no-root-v-if": "error",
|
|
82
74
|
"vue/no-template-target-blank": "error",
|
|
75
|
+
"vue/no-unused-emit-declarations": "error",
|
|
76
|
+
"vue/no-unused-properties": "error",
|
|
77
|
+
"vue/no-useless-mustaches": "error",
|
|
83
78
|
"vue/no-v-html": "error",
|
|
84
79
|
"vue/prefer-define-options": "error",
|
|
80
|
+
"vue/prefer-use-template-ref": "error",
|
|
85
81
|
"vue/require-explicit-emits": "error",
|
|
82
|
+
"vue/require-macro-variable-name": "error",
|
|
86
83
|
"vue/require-typed-ref": "error"
|
|
87
84
|
},
|
|
88
85
|
settings: typescriptJsdocConfig.settings
|
package/dist/vue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\nimport kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss';\n// @ts-expect-error No declare file.\nimport promise from 'eslint-plugin-promise';\n\nimport {
|
|
1
|
+
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\nimport kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss';\n// @ts-expect-error No declare file.\nimport promise from 'eslint-plugin-promise';\n\nimport { createBaseRules } from './_internals/configs/base-rules';\nimport { typescriptJsdocConfig } from './_internals/configs/jsdoc';\nimport { createTypeAwareConfig } from './_internals/configs/type-aware';\nimport { createTypefestConfig } from './_internals/configs/typefest';\nimport { customPlugins } from './_internals/rules';\n\nexport function createVueConfig(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem {\n const typeAwareConfig = createTypeAwareConfig();\n const typefestConfig = createTypefestConfig();\n return {\n files: ['**/*.vue'],\n languageOptions: typeAwareConfig.languageOptions,\n plugins: {\n ...typefestConfig.plugins,\n '@kikiutils/vue': kikiutilsEslintPluginVue,\n 'better-tailwindcss': betterTailwindcss,\n 'kikiutils': customPlugins,\n promise,\n },\n rules: {\n ...createBaseRules(environment),\n ...typescriptJsdocConfig.rules,\n ...typeAwareConfig.rules,\n ...typefestConfig.rules,\n '@kikiutils/vue/attributes-order': [\n 'error',\n {\n alphabetical: true,\n alphabeticalEnhanced: true,\n },\n ],\n '@kikiutils/vue/class-hex-color-case': 'error',\n 'better-tailwindcss/enforce-consistent-class-order': 'error',\n 'better-tailwindcss/enforce-consistent-important-position': 'error',\n 'better-tailwindcss/enforce-consistent-variable-syntax': 'error',\n 'better-tailwindcss/enforce-consistent-variant-order': 'error',\n 'better-tailwindcss/enforce-shorthand-classes': 'error',\n 'better-tailwindcss/no-deprecated-classes': 'warn',\n 'better-tailwindcss/no-duplicate-classes': 'error',\n 'better-tailwindcss/no-unnecessary-whitespace': 'error',\n 'style/max-len': 'off',\n 'ts/array-type': [\n 'error',\n { default: 'array-simple' },\n ],\n 'vue/attribute-hyphenation': 'error',\n 'vue/attributes-order': 'off',\n 'vue/block-order': [\n 'error',\n {\n order: [\n 'template',\n 'script',\n 'style',\n ],\n },\n ],\n 'vue/component-api-style': 'error',\n 'vue/define-emits-declaration': 'error',\n 'vue/define-props-declaration': 'error',\n 'vue/enforce-style-attribute': 'error',\n 'vue/html-closing-bracket-newline': 'error',\n 'vue/html-closing-bracket-spacing': 'error',\n 'vue/html-indent': [\n 'error',\n 4,\n ],\n 'vue/max-attributes-per-line': [\n 'error',\n {\n multiline: 1,\n singleline: 1,\n },\n ],\n 'vue/max-len': [\n 'warn',\n {\n code: 120,\n comments: 120,\n ignoreStrings: true,\n ignoreTemplateLiterals: true,\n template: 120,\n },\n ],\n 'vue/no-dupe-keys': 'error',\n 'vue/no-import-compiler-macros': 'error',\n 'vue/no-lone-template': 'error',\n 'vue/no-multi-spaces': 'error',\n 'vue/no-multiple-objects-in-class': 'error',\n 'vue/no-root-v-if': 'error',\n 'vue/no-template-target-blank': 'error',\n 'vue/no-unused-emit-declarations': 'error',\n 'vue/no-unused-properties': 'error',\n 'vue/no-useless-mustaches': 'error',\n 'vue/no-v-html': 'error',\n 'vue/prefer-define-options': 'error',\n 'vue/prefer-use-template-ref': 'error',\n 'vue/require-explicit-emits': 'error',\n 'vue/require-macro-variable-name': 'error',\n 'vue/require-typed-ref': 'error',\n },\n settings: typescriptJsdocConfig.settings,\n };\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,gBAAgB,cAA8B,QAA6B;CACvF,MAAM,kBAAkB,sBAAsB;CAC9C,MAAM,iBAAiB,qBAAqB;CAC5C,OAAO;EACH,OAAO,CAAC,UAAU;EAClB,iBAAiB,gBAAgB;EACjC,SAAS;GACL,GAAG,eAAe;GAClB,kBAAkB;GAClB,sBAAsB;GACtB,aAAa;GACb;EACJ;EACA,OAAO;GACH,GAAG,gBAAgB,WAAW;GAC9B,GAAG,sBAAsB;GACzB,GAAG,gBAAgB;GACnB,GAAG,eAAe;GAClB,mCAAmC,CAC/B,SACA;IACI,cAAc;IACd,sBAAsB;GAC1B,CACJ;GACA,uCAAuC;GACvC,qDAAqD;GACrD,4DAA4D;GAC5D,yDAAyD;GACzD,uDAAuD;GACvD,gDAAgD;GAChD,4CAA4C;GAC5C,2CAA2C;GAC3C,gDAAgD;GAChD,iBAAiB;GACjB,iBAAiB,CACb,SACA,EAAE,SAAS,eAAe,CAC9B;GACA,6BAA6B;GAC7B,wBAAwB;GACxB,mBAAmB,CACf,SACA,EACI,OAAO;IACH;IACA;IACA;GACJ,EACJ,CACJ;GACA,2BAA2B;GAC3B,gCAAgC;GAChC,gCAAgC;GAChC,+BAA+B;GAC/B,oCAAoC;GACpC,oCAAoC;GACpC,mBAAmB,CACf,SACA,CACJ;GACA,+BAA+B,CAC3B,SACA;IACI,WAAW;IACX,YAAY;GAChB,CACJ;GACA,eAAe,CACX,QACA;IACI,MAAM;IACN,UAAU;IACV,eAAe;IACf,wBAAwB;IACxB,UAAU;GACd,CACJ;GACA,oBAAoB;GACpB,iCAAiC;GACjC,wBAAwB;GACxB,uBAAuB;GACvB,oCAAoC;GACpC,oBAAoB;GACpB,gCAAgC;GAChC,mCAAmC;GACnC,4BAA4B;GAC5B,4BAA4B;GAC5B,iBAAiB;GACjB,6BAA6B;GAC7B,+BAA+B;GAC/B,8BAA8B;GAC9B,mCAAmC;GACnC,yBAAyB;EAC7B;EACA,UAAU,sBAAsB;CACpC;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kikiutils/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "11.
|
|
4
|
+
"version": "11.4.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",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"exports": {
|
|
15
15
|
"./base": "./dist/base.js",
|
|
16
|
+
"./nuxt": "./dist/nuxt.js",
|
|
16
17
|
"./style": "./dist/style.js",
|
|
17
18
|
"./vue": "./dist/vue.js",
|
|
18
19
|
"./package.json": "./package.json"
|
|
@@ -29,10 +30,10 @@
|
|
|
29
30
|
"bumplog": "changelogen --bump --hideAuthorEmail",
|
|
30
31
|
"knip:deps": "knip --dependencies",
|
|
31
32
|
"knip:exports": "knip --exports",
|
|
32
|
-
"lint": "eslint --max-warnings 0",
|
|
33
|
-
"lint:fix": "eslint --fix --max-warnings 0",
|
|
33
|
+
"lint": "eslint --cache --concurrency=auto --max-warnings 0",
|
|
34
|
+
"lint:fix": "eslint --cache --concurrency=auto --fix --max-warnings 0",
|
|
34
35
|
"prepack": "pnpm run build",
|
|
35
|
-
"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",
|
|
36
37
|
"test": "vitest run --coverage",
|
|
37
38
|
"test:watch": "vitest watch --coverage",
|
|
38
39
|
"typecheck": "tsc -b --noEmit"
|
|
@@ -56,10 +57,11 @@
|
|
|
56
57
|
"@eslint/css": "^2.0.1",
|
|
57
58
|
"@html-eslint/parser": "^0.68.0",
|
|
58
59
|
"@kikiutils/eslint-plugin-vue": "^10.10.0",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.73.0",
|
|
59
61
|
"eslint-plugin-better-tailwindcss": "^4.11.0",
|
|
60
62
|
"eslint-plugin-format": "^2.0.1",
|
|
61
63
|
"eslint-plugin-promise": "^7.3.0",
|
|
62
|
-
"eslint-plugin-typefest": "^1.7.
|
|
64
|
+
"eslint-plugin-typefest": "^1.7.1",
|
|
63
65
|
"tailwind-csstree": "^0.4.2",
|
|
64
66
|
"vue-eslint-parser": "^10.4.2"
|
|
65
67
|
},
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
"@vitest/coverage-v8": "^5.1.1",
|
|
72
74
|
"changelogen": "^0.6.2",
|
|
73
75
|
"eslint": "^10.15.0",
|
|
74
|
-
"knip": "^6.
|
|
76
|
+
"knip": "^6.48.0",
|
|
75
77
|
"publint": "^0.3.25",
|
|
76
78
|
"ts-extras": "^3.0.0",
|
|
77
79
|
"tsdown": "^0.23.7",
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import type { Rules } from '@antfu/eslint-config';
|
|
2
|
+
|
|
3
|
+
import { restrictedSyntax } from './restricted-syntax';
|
|
4
|
+
|
|
5
|
+
const basePerfectionistSortOptions = {
|
|
6
|
+
ignoreCase: false,
|
|
7
|
+
type: 'natural',
|
|
8
|
+
} as const;
|
|
9
|
+
|
|
10
|
+
export function createBaseRules(environment: 'bun' | 'node' = 'node'): Rules {
|
|
11
|
+
return {
|
|
12
|
+
'antfu/consistent-list-newline': [
|
|
13
|
+
'error',
|
|
14
|
+
{
|
|
15
|
+
ArrayExpression: false,
|
|
16
|
+
ArrayPattern: false,
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
'antfu/curly': 'off',
|
|
20
|
+
'antfu/if-newline': 'off',
|
|
21
|
+
'antfu/no-top-level-await': 'off',
|
|
22
|
+
'antfu/reasonable-newline': 'off',
|
|
23
|
+
'arrow-body-style': [
|
|
24
|
+
'error',
|
|
25
|
+
'as-needed',
|
|
26
|
+
],
|
|
27
|
+
'curly': [
|
|
28
|
+
'error',
|
|
29
|
+
'multi-line',
|
|
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
|
+
},
|
|
41
|
+
],
|
|
42
|
+
'jsdoc/no-blank-blocks': [
|
|
43
|
+
'error',
|
|
44
|
+
{ enableFixer: true },
|
|
45
|
+
],
|
|
46
|
+
'jsdoc/require-asterisk-prefix': 'error',
|
|
47
|
+
'jsdoc/require-hyphen-before-param-description': [
|
|
48
|
+
'error',
|
|
49
|
+
'always',
|
|
50
|
+
{ tags: { typeParam: 'always' } },
|
|
51
|
+
],
|
|
52
|
+
'kikiutils/comment-indent': 'error',
|
|
53
|
+
'kikiutils/compact-iteration-layout': 'error',
|
|
54
|
+
'kikiutils/consistent-condition-layout': 'error',
|
|
55
|
+
'kikiutils/consistent-parameter-layout': 'error',
|
|
56
|
+
'kikiutils/no-silent-catch': 'error',
|
|
57
|
+
'kikiutils/statement-padding': 'error',
|
|
58
|
+
'max-classes-per-file': [
|
|
59
|
+
'error',
|
|
60
|
+
1,
|
|
61
|
+
],
|
|
62
|
+
'no-constant-binary-expression': 'error',
|
|
63
|
+
// An ignored error needs at least a comment in the block saying why.
|
|
64
|
+
'no-empty': [
|
|
65
|
+
'error',
|
|
66
|
+
{ allowEmptyCatch: false },
|
|
67
|
+
],
|
|
68
|
+
'no-promise-executor-return': [
|
|
69
|
+
'error',
|
|
70
|
+
{ allowVoid: true },
|
|
71
|
+
],
|
|
72
|
+
'no-restricted-imports': [
|
|
73
|
+
'error',
|
|
74
|
+
{
|
|
75
|
+
patterns: [
|
|
76
|
+
{
|
|
77
|
+
message: '`_internals` modules are private to their own directory; import the public module instead.',
|
|
78
|
+
regex: String.raw`^[^.].*/_internals(/|$)`,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
'no-restricted-syntax': [
|
|
84
|
+
'error',
|
|
85
|
+
...restrictedSyntax,
|
|
86
|
+
],
|
|
87
|
+
'no-useless-assignment': 'error',
|
|
88
|
+
'perfectionist/sort-array-includes': [
|
|
89
|
+
'error',
|
|
90
|
+
basePerfectionistSortOptions,
|
|
91
|
+
],
|
|
92
|
+
'perfectionist/sort-enums': [
|
|
93
|
+
'error',
|
|
94
|
+
{
|
|
95
|
+
...basePerfectionistSortOptions,
|
|
96
|
+
sortByValue: 'never',
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
'perfectionist/sort-heritage-clauses': [
|
|
100
|
+
'error',
|
|
101
|
+
basePerfectionistSortOptions,
|
|
102
|
+
],
|
|
103
|
+
'perfectionist/sort-imports': [
|
|
104
|
+
'error',
|
|
105
|
+
{
|
|
106
|
+
environment,
|
|
107
|
+
groups: [
|
|
108
|
+
'side-effect',
|
|
109
|
+
'side-effect-style',
|
|
110
|
+
'style',
|
|
111
|
+
[
|
|
112
|
+
'value-builtin',
|
|
113
|
+
'type-builtin',
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
'value-external',
|
|
117
|
+
'type-external',
|
|
118
|
+
],
|
|
119
|
+
[
|
|
120
|
+
'value-internal',
|
|
121
|
+
'type-internal',
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
'value-parent',
|
|
125
|
+
'type-parent',
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
'value-sibling',
|
|
129
|
+
'type-sibling',
|
|
130
|
+
],
|
|
131
|
+
[
|
|
132
|
+
'value-index',
|
|
133
|
+
'type-index',
|
|
134
|
+
],
|
|
135
|
+
'unknown',
|
|
136
|
+
],
|
|
137
|
+
ignoreCase: false,
|
|
138
|
+
internalPattern: [
|
|
139
|
+
'^#.*',
|
|
140
|
+
'^@/.*',
|
|
141
|
+
'^~/.*',
|
|
142
|
+
],
|
|
143
|
+
type: 'natural',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
'perfectionist/sort-interfaces': [
|
|
147
|
+
'error',
|
|
148
|
+
basePerfectionistSortOptions,
|
|
149
|
+
],
|
|
150
|
+
'perfectionist/sort-intersection-types': [
|
|
151
|
+
'error',
|
|
152
|
+
basePerfectionistSortOptions,
|
|
153
|
+
],
|
|
154
|
+
'perfectionist/sort-maps': [
|
|
155
|
+
'error',
|
|
156
|
+
basePerfectionistSortOptions,
|
|
157
|
+
],
|
|
158
|
+
'perfectionist/sort-modules': [
|
|
159
|
+
'error',
|
|
160
|
+
{
|
|
161
|
+
...basePerfectionistSortOptions,
|
|
162
|
+
groups: [
|
|
163
|
+
'declare-type',
|
|
164
|
+
[
|
|
165
|
+
'export-type',
|
|
166
|
+
'type',
|
|
167
|
+
],
|
|
168
|
+
'declare-interface',
|
|
169
|
+
[
|
|
170
|
+
'export-interface',
|
|
171
|
+
'interface',
|
|
172
|
+
],
|
|
173
|
+
'declare-enum',
|
|
174
|
+
[
|
|
175
|
+
'enum',
|
|
176
|
+
'export-enum',
|
|
177
|
+
],
|
|
178
|
+
'declare-class',
|
|
179
|
+
[
|
|
180
|
+
'class',
|
|
181
|
+
'export-class',
|
|
182
|
+
],
|
|
183
|
+
'declare-function',
|
|
184
|
+
[
|
|
185
|
+
'export-function',
|
|
186
|
+
'function',
|
|
187
|
+
],
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
'perfectionist/sort-object-types': [
|
|
192
|
+
'error',
|
|
193
|
+
basePerfectionistSortOptions,
|
|
194
|
+
],
|
|
195
|
+
'perfectionist/sort-objects': [
|
|
196
|
+
'error',
|
|
197
|
+
basePerfectionistSortOptions,
|
|
198
|
+
],
|
|
199
|
+
'perfectionist/sort-sets': [
|
|
200
|
+
'error',
|
|
201
|
+
basePerfectionistSortOptions,
|
|
202
|
+
],
|
|
203
|
+
'perfectionist/sort-switch-case': [
|
|
204
|
+
'error',
|
|
205
|
+
{
|
|
206
|
+
ignoreCase: false,
|
|
207
|
+
type: 'natural',
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
'perfectionist/sort-union-types': [
|
|
211
|
+
'error',
|
|
212
|
+
basePerfectionistSortOptions,
|
|
213
|
+
],
|
|
214
|
+
'perfectionist/sort-variable-declarations': [
|
|
215
|
+
'error',
|
|
216
|
+
basePerfectionistSortOptions,
|
|
217
|
+
],
|
|
218
|
+
'preserve-caught-error': 'error',
|
|
219
|
+
'promise/no-multiple-resolved': 'error',
|
|
220
|
+
'promise/no-return-in-finally': 'error',
|
|
221
|
+
'promise/no-return-wrap': 'error',
|
|
222
|
+
'require-await': 'off',
|
|
223
|
+
'style/array-bracket-newline': [
|
|
224
|
+
'error',
|
|
225
|
+
{ multiline: true },
|
|
226
|
+
],
|
|
227
|
+
'style/array-element-newline': [
|
|
228
|
+
'error',
|
|
229
|
+
{
|
|
230
|
+
ArrayExpression: {
|
|
231
|
+
consistent: true,
|
|
232
|
+
minItems: 2,
|
|
233
|
+
},
|
|
234
|
+
ArrayPattern: { minItems: 3 },
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
'style/arrow-parens': [
|
|
238
|
+
'error',
|
|
239
|
+
'always',
|
|
240
|
+
],
|
|
241
|
+
'style/brace-style': [
|
|
242
|
+
'error',
|
|
243
|
+
'1tbs',
|
|
244
|
+
{ allowSingleLine: false },
|
|
245
|
+
],
|
|
246
|
+
'style/function-call-spacing': [
|
|
247
|
+
'error',
|
|
248
|
+
'never',
|
|
249
|
+
],
|
|
250
|
+
'style/indent': [
|
|
251
|
+
'error',
|
|
252
|
+
4,
|
|
253
|
+
],
|
|
254
|
+
'style/max-len': [
|
|
255
|
+
'warn',
|
|
256
|
+
{
|
|
257
|
+
code: 120,
|
|
258
|
+
comments: 120,
|
|
259
|
+
ignoreStrings: true,
|
|
260
|
+
ignoreTemplateLiterals: true,
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
'style/member-delimiter-style': [
|
|
264
|
+
'error',
|
|
265
|
+
{
|
|
266
|
+
multiline: {
|
|
267
|
+
delimiter: 'semi',
|
|
268
|
+
requireLast: true,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
],
|
|
272
|
+
'style/no-extra-parens': [
|
|
273
|
+
'error',
|
|
274
|
+
'all',
|
|
275
|
+
{ nestedBinaryExpressions: false },
|
|
276
|
+
],
|
|
277
|
+
'style/no-extra-semi': 'error',
|
|
278
|
+
'style/object-curly-newline': [
|
|
279
|
+
'error',
|
|
280
|
+
{
|
|
281
|
+
ExportDeclaration: {
|
|
282
|
+
minProperties: 2,
|
|
283
|
+
multiline: true,
|
|
284
|
+
},
|
|
285
|
+
ImportDeclaration: {
|
|
286
|
+
minProperties: 2,
|
|
287
|
+
multiline: true,
|
|
288
|
+
},
|
|
289
|
+
ObjectExpression: {
|
|
290
|
+
minProperties: 2,
|
|
291
|
+
multiline: true,
|
|
292
|
+
},
|
|
293
|
+
ObjectPattern: {
|
|
294
|
+
minProperties: 3,
|
|
295
|
+
multiline: true,
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
],
|
|
299
|
+
'style/operator-linebreak': [
|
|
300
|
+
'error',
|
|
301
|
+
'before',
|
|
302
|
+
{ overrides: { '=': 'after' } },
|
|
303
|
+
],
|
|
304
|
+
'style/padding-line-between-statements': [
|
|
305
|
+
'error',
|
|
306
|
+
{
|
|
307
|
+
blankLine: 'always',
|
|
308
|
+
next: [
|
|
309
|
+
'class',
|
|
310
|
+
'enum',
|
|
311
|
+
'function',
|
|
312
|
+
],
|
|
313
|
+
prev: '*',
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
blankLine: 'always',
|
|
317
|
+
next: '*',
|
|
318
|
+
prev: [
|
|
319
|
+
'class',
|
|
320
|
+
'function',
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
'style/semi': [
|
|
325
|
+
'error',
|
|
326
|
+
'always',
|
|
327
|
+
],
|
|
328
|
+
'unicorn/no-useless-promise-resolve-reject': 'error',
|
|
329
|
+
'unicorn/no-useless-spread': 'error',
|
|
330
|
+
'unicorn/prefer-array-find': 'error',
|
|
331
|
+
'unicorn/prefer-array-some': 'error',
|
|
332
|
+
'unicorn/prefer-at': 'error',
|
|
333
|
+
'unicorn/prefer-string-replace-all': 'error',
|
|
334
|
+
};
|
|
335
|
+
}
|
|
@@ -5,8 +5,4 @@ export const restrictedSyntax = [
|
|
|
5
5
|
message: 'Use `axios.isAxiosError(error)`; `instanceof` fails when the error comes from another copy of axios.',
|
|
6
6
|
selector: 'BinaryExpression[operator="instanceof"][right.name="AxiosError"]',
|
|
7
7
|
},
|
|
8
|
-
{
|
|
9
|
-
message: 'Do not swallow the rejection silently: log it, or handle it in a way that shows why it can be ignored.',
|
|
10
|
-
selector: 'CallExpression[callee.property.name="catch"] > ArrowFunctionExpression[body.type="BlockStatement"][body.body.length=0]',
|
|
11
|
-
},
|
|
12
8
|
];
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from '@antfu/eslint-config';
|
|
2
|
+
|
|
3
|
+
export function createTypeAwareConfig(): TypedFlatConfigItem {
|
|
4
|
+
return {
|
|
5
|
+
languageOptions: {
|
|
6
|
+
parserOptions: {
|
|
7
|
+
projectService: true,
|
|
8
|
+
tsconfigRootDir: process.cwd(),
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
'kikiutils/no-thenable-zod-refinement': 'error',
|
|
13
|
+
'kikiutils/promise-function-async': 'error',
|
|
14
|
+
// The typed replacements below report these more accurately.
|
|
15
|
+
'no-implied-eval': 'off',
|
|
16
|
+
'no-throw-literal': 'off',
|
|
17
|
+
'prefer-promise-reject-errors': 'off',
|
|
18
|
+
'ts/await-thenable': 'error',
|
|
19
|
+
'ts/consistent-type-exports': 'error',
|
|
20
|
+
'ts/no-array-delete': 'error',
|
|
21
|
+
'ts/no-base-to-string': 'error',
|
|
22
|
+
'ts/no-deprecated': 'error',
|
|
23
|
+
'ts/no-duplicate-type-constituents': 'error',
|
|
24
|
+
'ts/no-floating-promises': [
|
|
25
|
+
'error',
|
|
26
|
+
{
|
|
27
|
+
allowForKnownSafePromises: [
|
|
28
|
+
{
|
|
29
|
+
from: 'package',
|
|
30
|
+
name: 'SafePromise',
|
|
31
|
+
package: '@kikiutils/shared',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
'ts/no-for-in-array': 'error',
|
|
37
|
+
'ts/no-implied-eval': 'error',
|
|
38
|
+
'ts/no-misused-promises': 'error',
|
|
39
|
+
'ts/no-misused-spread': 'error',
|
|
40
|
+
'ts/no-unnecessary-boolean-literal-compare': 'error',
|
|
41
|
+
'ts/no-unnecessary-template-expression': 'error',
|
|
42
|
+
'ts/no-unnecessary-type-arguments': 'error',
|
|
43
|
+
'ts/no-unnecessary-type-assertion': 'error',
|
|
44
|
+
'ts/only-throw-error': 'error',
|
|
45
|
+
// Matches only-throw-error, which allows `any` and `unknown` by default.
|
|
46
|
+
'ts/prefer-promise-reject-errors': [
|
|
47
|
+
'error',
|
|
48
|
+
{
|
|
49
|
+
allowThrowingAny: true,
|
|
50
|
+
allowThrowingUnknown: true,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
'ts/promise-function-async': 'off',
|
|
54
|
+
'ts/require-await': 'off',
|
|
55
|
+
// Exhaustive-switch fallbacks interpolate the `never` value into their error message.
|
|
56
|
+
'ts/restrict-template-expressions': [
|
|
57
|
+
'error',
|
|
58
|
+
{ allowNever: true },
|
|
59
|
+
],
|
|
60
|
+
'ts/return-await': [
|
|
61
|
+
'error',
|
|
62
|
+
'always',
|
|
63
|
+
],
|
|
64
|
+
'ts/switch-exhaustiveness-check': [
|
|
65
|
+
'error',
|
|
66
|
+
{ considerDefaultExhaustiveForUnions: true },
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AST,
|
|
3
|
+
Rule,
|
|
4
|
+
} from 'eslint';
|
|
5
|
+
|
|
6
|
+
type Comment = ReturnType<Rule.RuleContext['sourceCode']['getAllComments']>[number];
|
|
7
|
+
|
|
8
|
+
const closingPunctuators = new Set([
|
|
9
|
+
')',
|
|
10
|
+
']',
|
|
11
|
+
'}',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const openingPunctuators = new Set([
|
|
15
|
+
'(',
|
|
16
|
+
'[',
|
|
17
|
+
'{',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const commentIndent: Rule.RuleModule = {
|
|
21
|
+
create(context) {
|
|
22
|
+
const { sourceCode } = context;
|
|
23
|
+
const getIndent = (line: number) => /^[\t ]*/.exec(sourceCode.lines[line - 1]!)![0];
|
|
24
|
+
const startsLine = (token: AST.Token | Comment) => {
|
|
25
|
+
const previous = sourceCode.getTokenBefore(token, { includeComments: true });
|
|
26
|
+
return !previous || previous.loc!.end.line < token.loc!.start.line;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
Program() {
|
|
31
|
+
for (const comment of sourceCode.getAllComments()) {
|
|
32
|
+
if (!startsLine(comment)) continue;
|
|
33
|
+
// style/indent lets a comment align with the opening bracket before it, which leaves comments
|
|
34
|
+
// at the outer depth after a fixer nests the bracket's contents one level deeper.
|
|
35
|
+
let anchor = sourceCode.getTokenBefore(comment, { includeComments: true });
|
|
36
|
+
while ((anchor?.type === 'Block' || anchor?.type === 'Line') && startsLine(anchor)) {
|
|
37
|
+
anchor = sourceCode.getTokenBefore(anchor, { includeComments: true });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (anchor?.type !== 'Punctuator' || !openingPunctuators.has(anchor.value)) continue;
|
|
41
|
+
const next = sourceCode.getTokenAfter(comment);
|
|
42
|
+
if (!next || closingPunctuators.has(next.value) || !startsLine(next)) continue;
|
|
43
|
+
const { end, start } = comment.loc!;
|
|
44
|
+
// style/indent only lets a comment follow the next code when no blank line separates them.
|
|
45
|
+
const gapLines = sourceCode.lines.slice(end.line, next.loc.start.line - 1);
|
|
46
|
+
if (gapLines.some((text) => !text.trim())) continue;
|
|
47
|
+
const indent = getIndent(start.line);
|
|
48
|
+
const expected = getIndent(next.loc.start.line);
|
|
49
|
+
if (indent === expected) continue;
|
|
50
|
+
const commentLines = Array.from(
|
|
51
|
+
{ length: end.line - start.line + 1 },
|
|
52
|
+
(_, index) => start.line + index,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
context.report({
|
|
56
|
+
// Shift a multiline block comment as a whole so its continuation lines stay aligned.
|
|
57
|
+
fix: (fixer) => commentLines
|
|
58
|
+
.filter((line) => sourceCode.lines[line - 1]!.startsWith(indent))
|
|
59
|
+
.map((line) => {
|
|
60
|
+
const offset = sourceCode.getIndexFromLoc({
|
|
61
|
+
column: 0,
|
|
62
|
+
line,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return fixer.replaceTextRange(
|
|
66
|
+
[
|
|
67
|
+
offset,
|
|
68
|
+
offset + indent.length,
|
|
69
|
+
],
|
|
70
|
+
expected,
|
|
71
|
+
);
|
|
72
|
+
}),
|
|
73
|
+
loc: comment.loc!,
|
|
74
|
+
messageId: 'align',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
meta: {
|
|
81
|
+
docs: { description: 'Align comments after an opening bracket with the code that follows them.' },
|
|
82
|
+
fixable: 'whitespace',
|
|
83
|
+
messages: { align: 'Indent this comment like the code that follows it.' },
|
|
84
|
+
schema: [],
|
|
85
|
+
type: 'layout',
|
|
86
|
+
},
|
|
87
|
+
};
|