@kikiutils/eslint-config 11.2.0 → 11.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +18 -0
- package/dist/_internals/rules/index.d.ts.map +1 -0
- package/dist/_internals/rules/index.js +32 -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 +37 -0
- package/dist/_internals/rules/no-silent-catch.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 +12 -15
- package/dist/vue.js.map +1 -1
- package/package.json +13 -11
- 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 +36 -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 +51 -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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/_internals/rules/no-silent-catch.ts
|
|
2
|
+
function isNothing(node) {
|
|
3
|
+
if (!node) return true;
|
|
4
|
+
if (node.type === "Identifier") return node.name === "undefined";
|
|
5
|
+
if (node.type === "Literal") return node.raw === "null";
|
|
6
|
+
return node.type === "UnaryExpression" && node.operator === "void" && node.argument.type === "Literal";
|
|
7
|
+
}
|
|
8
|
+
function isSilent(callback) {
|
|
9
|
+
if (callback.type !== "ArrowFunctionExpression" && callback.type !== "FunctionExpression") return false;
|
|
10
|
+
const { body } = callback;
|
|
11
|
+
if (body.type !== "BlockStatement") return isNothing(body);
|
|
12
|
+
const [statement, ...rest] = body.body;
|
|
13
|
+
return !statement || !rest.length && statement.type === "ReturnStatement" && isNothing(statement.argument);
|
|
14
|
+
}
|
|
15
|
+
const noSilentCatch = {
|
|
16
|
+
create(context) {
|
|
17
|
+
return { CallExpression(node) {
|
|
18
|
+
const { callee } = node;
|
|
19
|
+
const callback = node.arguments[0];
|
|
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;
|
|
22
|
+
context.report({
|
|
23
|
+
messageId: "silent",
|
|
24
|
+
node: callback
|
|
25
|
+
});
|
|
26
|
+
} };
|
|
27
|
+
},
|
|
28
|
+
meta: {
|
|
29
|
+
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
|
+
schema: [],
|
|
32
|
+
type: "problem"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export { noSilentCatch };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=no-silent-catch.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-function-async.d.ts","names":[],"sources":["../../../src/_internals/rules/promise-function-async.ts"],"mappings":";qBA6Ba,sBAAsB,KAAK"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import tseslint from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
// src/_internals/rules/promise-function-async.ts
|
|
3
|
+
const upstream = tseslint.rules["promise-function-async"];
|
|
4
|
+
const promiseMembers = /* @__PURE__ */ new Set([
|
|
5
|
+
"catch",
|
|
6
|
+
"finally",
|
|
7
|
+
"then"
|
|
8
|
+
]);
|
|
9
|
+
function hasNonPromiseMembers(checker, type) {
|
|
10
|
+
return (type.isUnion() ? type.types : [type]).some((part) => {
|
|
11
|
+
const names = checker.getPropertiesOfType(part).map((symbol) => symbol.getName());
|
|
12
|
+
return names.includes("then") && names.some((name) => !promiseMembers.has(name) && !name.startsWith("__@"));
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const promiseFunctionAsync = {
|
|
16
|
+
create(context) {
|
|
17
|
+
const report = (descriptor) => {
|
|
18
|
+
if ("node" in descriptor) {
|
|
19
|
+
const services = context.sourceCode.parserServices;
|
|
20
|
+
const checker = services.program.getTypeChecker();
|
|
21
|
+
const tsNode = services.esTreeNodeToTSNodeMap.get(descriptor.node);
|
|
22
|
+
if ([checker.getSignatureFromDeclaration(tsNode), ...checker.getTypeAtLocation(tsNode).getCallSignatures()].some((signature) => signature && hasNonPromiseMembers(checker, checker.getReturnTypeOfSignature(signature)))) return;
|
|
23
|
+
}
|
|
24
|
+
context.report(descriptor);
|
|
25
|
+
};
|
|
26
|
+
return upstream.create(Object.create(context, { report: { value: report } }));
|
|
27
|
+
},
|
|
28
|
+
meta: upstream.meta
|
|
29
|
+
};
|
|
30
|
+
export { promiseFunctionAsync };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=promise-function-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promise-function-async.js","names":[],"sources":["../../../src/_internals/rules/promise-function-async.ts"],"sourcesContent":["import tseslint from '@typescript-eslint/eslint-plugin';\nimport type { Rule } from 'eslint';\nimport type {\n Node,\n SignatureDeclaration,\n Type,\n TypeChecker,\n} from 'typescript';\n\ninterface ParserServices {\n esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };\n program: { getTypeChecker: () => TypeChecker };\n}\n\nconst upstream = tseslint.rules['promise-function-async'] as unknown as Rule.RuleModule;\nconst promiseMembers = new Set([\n 'catch',\n 'finally',\n 'then',\n]);\n\n// A thenable with extra members, such as Nuxt's `AsyncData`, loses those members once the function becomes async.\nfunction hasNonPromiseMembers(checker: TypeChecker, type: Type): boolean {\n return (type.isUnion() ? type.types : [type]).some((part) => {\n const names = checker.getPropertiesOfType(part).map((symbol) => symbol.getName());\n return names.includes('then') && names.some((name) => !promiseMembers.has(name) && !name.startsWith('__@'));\n });\n}\n\nexport const promiseFunctionAsync: Rule.RuleModule = {\n create(context) {\n const report = (descriptor: Rule.ReportDescriptor) => {\n if ('node' in descriptor) {\n const services = context.sourceCode.parserServices as ParserServices;\n const checker = services.program.getTypeChecker();\n const tsNode = services.esTreeNodeToTSNodeMap.get(descriptor.node) as SignatureDeclaration;\n // Overloads are what callers see, so they count alongside the implementation signature.\n const signatures = [\n checker.getSignatureFromDeclaration(tsNode),\n ...checker.getTypeAtLocation(tsNode).getCallSignatures(),\n ];\n\n if (\n signatures.some((signature) => signature\n && hasNonPromiseMembers(checker, checker.getReturnTypeOfSignature(signature)))\n ) return;\n }\n\n context.report(descriptor);\n };\n\n // The upstream rule validates that type information is available.\n return upstream.create(Object.create(context, { report: { value: report } }));\n },\n meta: upstream.meta,\n};\n"],"mappings":";;AAcA,MAAM,WAAW,SAAS,MAAM;AAChC,MAAM,iCAAiB,IAAI,IAAI;CAC3B;CACA;CACA;AACJ,CAAC;AAGD,SAAS,qBAAqB,SAAsB,MAAqB;CACrE,QAAQ,KAAK,QAAQ,IAAI,KAAK,QAAQ,CAAC,IAAI,EAAA,CAAG,MAAM,SAAS;EACzD,MAAM,QAAQ,QAAQ,oBAAoB,IAAI,CAAC,CAAC,KAAK,WAAW,OAAO,QAAQ,CAAC;EAChF,OAAO,MAAM,SAAS,MAAM,KAAK,MAAM,MAAM,SAAS,CAAC,eAAe,IAAI,IAAI,KAAK,CAAC,KAAK,WAAW,KAAK,CAAC;CAC9G,CAAC;AACL;AAEA,MAAa,uBAAwC;CACjD,OAAO,SAAS;EACZ,MAAM,UAAU,eAAsC;GAClD,IAAI,UAAU,YAAY;IACtB,MAAM,WAAW,QAAQ,WAAW;IACpC,MAAM,UAAU,SAAS,QAAQ,eAAe;IAChD,MAAM,SAAS,SAAS,sBAAsB,IAAI,WAAW,IAAI;IAOjE,IACI,CALA,QAAQ,4BAA4B,MAAM,GAC1C,GAAG,QAAQ,kBAAkB,MAAM,CAAC,CAAC,kBAAkB,CAI9C,CAAC,CAAC,MAAM,cAAc,aAC1B,qBAAqB,SAAS,QAAQ,yBAAyB,SAAS,CAAC,CAAC,GACjF;GACN;GAEA,QAAQ,OAAO,UAAU;EAC7B;EAGA,OAAO,SAAS,OAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,EAAE,OAAO,OAAO,EAAE,CAAC,CAAC;CAChF;CACA,MAAM,SAAS;AACnB"}
|
|
@@ -53,7 +53,8 @@ const statementPadding = {
|
|
|
53
53
|
BlockStatement: (node) => checkStatements(node.body),
|
|
54
54
|
Program: (node) => checkStatements(node.body),
|
|
55
55
|
StaticBlock: (node) => checkStatements(node.body),
|
|
56
|
-
SwitchCase: (node) => checkStatements(node.consequent)
|
|
56
|
+
SwitchCase: (node) => checkStatements(node.consequent),
|
|
57
|
+
TSModuleBlock: (node) => checkStatements(node.body)
|
|
57
58
|
};
|
|
58
59
|
},
|
|
59
60
|
meta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statement-padding.js","names":[],"sources":["../../../src/_internals/rules/statement-padding.ts"],"sourcesContent":["import type { Rule } from 'eslint';\n\ntype StatementNode = Extract<Rule.Node, { type: 'Program' }>['body'][number];\n\nexport const statementPadding: Rule.RuleModule = {\n create(context) {\n const { sourceCode } = context;\n\n function checkStatements(statements: readonly StatementNode[]): void {\n for (let index = 1; index < statements.length; index++) {\n const previous = statements[index - 1]!;\n const next = statements[index]!;\n if (\n [\n previous,\n next,\n ].some((node) =>\n node.type === 'ImportDeclaration'\n || node.type === 'ExportAllDeclaration'\n || (node.type === 'ExportNamedDeclaration' && node.source))\n ) continue;\n\n const previousFirstToken = sourceCode.getFirstToken(previous)!;\n const lastToken = sourceCode.getLastToken(previous)!;\n const firstToken = sourceCode.getFirstToken(next)!;\n const isMultiline = previousFirstToken.loc.start.line !== lastToken.loc.end.line;\n const blockNode = previous.type === 'ExportDefaultDeclaration'\n || previous.type === 'ExportNamedDeclaration'\n ? previous.declaration\n : previous;\n\n const hasBlockClosing = lastToken.value === '}' && blockNode && [\n 'BlockStatement',\n 'ClassDeclaration',\n 'ForInStatement',\n 'ForOfStatement',\n 'ForStatement',\n 'FunctionDeclaration',\n 'IfStatement',\n 'LabeledStatement',\n 'SwitchStatement',\n 'TryStatement',\n 'WhileStatement',\n 'WithStatement',\n ].includes(blockNode.type);\n\n if (!isMultiline && !hasBlockClosing) continue;\n let previousEnd = lastToken.range[1];\n let previousEndLine = lastToken.loc.end.line;\n let nextStart = firstToken.range[0];\n let nextStartLine = firstToken.loc.start.line;\n\n // Include trailing comments in the previous boundary, not leading comments of the next statement.\n for (const comment of sourceCode.getCommentsBefore(next)) {\n if (comment.loc!.start.line === previousEndLine) {\n previousEnd = comment.range![1];\n previousEndLine = comment.loc!.end.line;\n } else {\n nextStart = comment.range![0];\n nextStartLine = comment.loc!.start.line;\n break;\n }\n }\n\n if (nextStartLine > previousEndLine + 1) continue;\n const linebreakIndex = sourceCode.text.slice(previousEnd, nextStart).indexOf('\\n');\n const offset = linebreakIndex === -1 ? nextStart : previousEnd + linebreakIndex + 1;\n\n context.report({\n fix: (fixer) => fixer.insertTextBeforeRange(\n [\n offset,\n offset,\n ],\n linebreakIndex === -1 ? '\\n\\n' : '\\n',\n ),\n messageId: 'blankLine',\n node: next,\n });\n }\n }\n\n return {\n BlockStatement: (node) => checkStatements(node.body),\n Program: (node) => checkStatements(node.body),\n StaticBlock: (node) => checkStatements(node.body),\n SwitchCase: (node) => checkStatements(node.consequent),\n };\n },\n meta: {\n docs: { description: 'Separate complete multiline statements and block-ending statements with blank lines.' },\n fixable: 'whitespace',\n messages: { blankLine: 'Add a blank line between these complete statements.' },\n schema: [],\n type: 'layout',\n },\n};\n"],"mappings":";AAIA,MAAa,mBAAoC;CAC7C,OAAO,SAAS;EACZ,MAAM,EAAE,eAAe;EAEvB,SAAS,gBAAgB,YAA4C;GACjE,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;IACpD,MAAM,WAAW,WAAW,QAAQ;IACpC,MAAM,OAAO,WAAW;IACxB,IACI,CACI,UACA,IACJ,CAAC,CAAC,MAAM,SACJ,KAAK,SAAS,uBACX,KAAK,SAAS,0BACb,KAAK,SAAS,4BAA4B,KAAK,MAAO,GAChE;IAEF,MAAM,qBAAqB,WAAW,cAAc,QAAQ;IAC5D,MAAM,YAAY,WAAW,aAAa,QAAQ;IAClD,MAAM,aAAa,WAAW,cAAc,IAAI;IAChD,MAAM,cAAc,mBAAmB,IAAI,MAAM,SAAS,UAAU,IAAI,IAAI;IAC5E,MAAM,YAAY,SAAS,SAAS,8BAC/B,SAAS,SAAS,2BACjB,SAAS,cACT;IAEN,MAAM,kBAAkB,UAAU,UAAU,OAAO,aAAa;KAC5D;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACJ,CAAC,CAAC,SAAS,UAAU,IAAI;IAEzB,IAAI,CAAC,eAAe,CAAC,iBAAiB;IACtC,IAAI,cAAc,UAAU,MAAM;IAClC,IAAI,kBAAkB,UAAU,IAAI,IAAI;IACxC,IAAI,YAAY,WAAW,MAAM;IACjC,IAAI,gBAAgB,WAAW,IAAI,MAAM;IAGzC,KAAK,MAAM,WAAW,WAAW,kBAAkB,IAAI,GACnD,IAAI,QAAQ,IAAK,MAAM,SAAS,iBAAiB;KAC7C,cAAc,QAAQ,MAAO;KAC7B,kBAAkB,QAAQ,IAAK,IAAI;IACvC,OAAO;KACH,YAAY,QAAQ,MAAO;KAC3B,gBAAgB,QAAQ,IAAK,MAAM;KACnC;IACJ;IAGJ,IAAI,gBAAgB,kBAAkB,GAAG;IACzC,MAAM,iBAAiB,WAAW,KAAK,MAAM,aAAa,SAAS,CAAC,CAAC,QAAQ,IAAI;IACjF,MAAM,SAAS,mBAAmB,KAAK,YAAY,cAAc,iBAAiB;IAElF,QAAQ,OAAO;KACX,MAAM,UAAU,MAAM,sBAClB,CACI,QACA,MACJ,GACA,mBAAmB,KAAK,SAAS,IACrC;KACA,WAAW;KACX,MAAM;IACV,CAAC;GACL;EACJ;EAEA,OAAO;GACH,iBAAiB,SAAS,gBAAgB,KAAK,IAAI;GACnD,UAAU,SAAS,gBAAgB,KAAK,IAAI;GAC5C,cAAc,SAAS,gBAAgB,KAAK,IAAI;GAChD,aAAa,SAAS,gBAAgB,KAAK,UAAU;
|
|
1
|
+
{"version":3,"file":"statement-padding.js","names":[],"sources":["../../../src/_internals/rules/statement-padding.ts"],"sourcesContent":["import type { Rule } from 'eslint';\n\ntype StatementNode = Extract<Rule.Node, { type: 'Program' }>['body'][number];\n\nexport const statementPadding: Rule.RuleModule = {\n create(context) {\n const { sourceCode } = context;\n\n function checkStatements(statements: readonly StatementNode[]): void {\n for (let index = 1; index < statements.length; index++) {\n const previous = statements[index - 1]!;\n const next = statements[index]!;\n if (\n [\n previous,\n next,\n ].some((node) =>\n node.type === 'ImportDeclaration'\n || node.type === 'ExportAllDeclaration'\n || (node.type === 'ExportNamedDeclaration' && node.source))\n ) continue;\n\n const previousFirstToken = sourceCode.getFirstToken(previous)!;\n const lastToken = sourceCode.getLastToken(previous)!;\n const firstToken = sourceCode.getFirstToken(next)!;\n const isMultiline = previousFirstToken.loc.start.line !== lastToken.loc.end.line;\n const blockNode = previous.type === 'ExportDefaultDeclaration'\n || previous.type === 'ExportNamedDeclaration'\n ? previous.declaration\n : previous;\n\n const hasBlockClosing = lastToken.value === '}' && blockNode && [\n 'BlockStatement',\n 'ClassDeclaration',\n 'ForInStatement',\n 'ForOfStatement',\n 'ForStatement',\n 'FunctionDeclaration',\n 'IfStatement',\n 'LabeledStatement',\n 'SwitchStatement',\n 'TryStatement',\n 'WhileStatement',\n 'WithStatement',\n ].includes(blockNode.type);\n\n if (!isMultiline && !hasBlockClosing) continue;\n let previousEnd = lastToken.range[1];\n let previousEndLine = lastToken.loc.end.line;\n let nextStart = firstToken.range[0];\n let nextStartLine = firstToken.loc.start.line;\n\n // Include trailing comments in the previous boundary, not leading comments of the next statement.\n for (const comment of sourceCode.getCommentsBefore(next)) {\n if (comment.loc!.start.line === previousEndLine) {\n previousEnd = comment.range![1];\n previousEndLine = comment.loc!.end.line;\n } else {\n nextStart = comment.range![0];\n nextStartLine = comment.loc!.start.line;\n break;\n }\n }\n\n if (nextStartLine > previousEndLine + 1) continue;\n const linebreakIndex = sourceCode.text.slice(previousEnd, nextStart).indexOf('\\n');\n const offset = linebreakIndex === -1 ? nextStart : previousEnd + linebreakIndex + 1;\n\n context.report({\n fix: (fixer) => fixer.insertTextBeforeRange(\n [\n offset,\n offset,\n ],\n linebreakIndex === -1 ? '\\n\\n' : '\\n',\n ),\n messageId: 'blankLine',\n node: next,\n });\n }\n }\n\n return {\n BlockStatement: (node) => checkStatements(node.body),\n Program: (node) => checkStatements(node.body),\n StaticBlock: (node) => checkStatements(node.body),\n SwitchCase: (node) => checkStatements(node.consequent),\n TSModuleBlock: (node: Rule.Node & { body: StatementNode[] }) => checkStatements(node.body),\n };\n },\n meta: {\n docs: { description: 'Separate complete multiline statements and block-ending statements with blank lines.' },\n fixable: 'whitespace',\n messages: { blankLine: 'Add a blank line between these complete statements.' },\n schema: [],\n type: 'layout',\n },\n};\n"],"mappings":";AAIA,MAAa,mBAAoC;CAC7C,OAAO,SAAS;EACZ,MAAM,EAAE,eAAe;EAEvB,SAAS,gBAAgB,YAA4C;GACjE,KAAK,IAAI,QAAQ,GAAG,QAAQ,WAAW,QAAQ,SAAS;IACpD,MAAM,WAAW,WAAW,QAAQ;IACpC,MAAM,OAAO,WAAW;IACxB,IACI,CACI,UACA,IACJ,CAAC,CAAC,MAAM,SACJ,KAAK,SAAS,uBACX,KAAK,SAAS,0BACb,KAAK,SAAS,4BAA4B,KAAK,MAAO,GAChE;IAEF,MAAM,qBAAqB,WAAW,cAAc,QAAQ;IAC5D,MAAM,YAAY,WAAW,aAAa,QAAQ;IAClD,MAAM,aAAa,WAAW,cAAc,IAAI;IAChD,MAAM,cAAc,mBAAmB,IAAI,MAAM,SAAS,UAAU,IAAI,IAAI;IAC5E,MAAM,YAAY,SAAS,SAAS,8BAC/B,SAAS,SAAS,2BACjB,SAAS,cACT;IAEN,MAAM,kBAAkB,UAAU,UAAU,OAAO,aAAa;KAC5D;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACJ,CAAC,CAAC,SAAS,UAAU,IAAI;IAEzB,IAAI,CAAC,eAAe,CAAC,iBAAiB;IACtC,IAAI,cAAc,UAAU,MAAM;IAClC,IAAI,kBAAkB,UAAU,IAAI,IAAI;IACxC,IAAI,YAAY,WAAW,MAAM;IACjC,IAAI,gBAAgB,WAAW,IAAI,MAAM;IAGzC,KAAK,MAAM,WAAW,WAAW,kBAAkB,IAAI,GACnD,IAAI,QAAQ,IAAK,MAAM,SAAS,iBAAiB;KAC7C,cAAc,QAAQ,MAAO;KAC7B,kBAAkB,QAAQ,IAAK,IAAI;IACvC,OAAO;KACH,YAAY,QAAQ,MAAO;KAC3B,gBAAgB,QAAQ,IAAK,MAAM;KACnC;IACJ;IAGJ,IAAI,gBAAgB,kBAAkB,GAAG;IACzC,MAAM,iBAAiB,WAAW,KAAK,MAAM,aAAa,SAAS,CAAC,CAAC,QAAQ,IAAI;IACjF,MAAM,SAAS,mBAAmB,KAAK,YAAY,cAAc,iBAAiB;IAElF,QAAQ,OAAO;KACX,MAAM,UAAU,MAAM,sBAClB,CACI,QACA,MACJ,GACA,mBAAmB,KAAK,SAAS,IACrC;KACA,WAAW;KACX,MAAM;IACV,CAAC;GACL;EACJ;EAEA,OAAO;GACH,iBAAiB,SAAS,gBAAgB,KAAK,IAAI;GACnD,UAAU,SAAS,gBAAgB,KAAK,IAAI;GAC5C,cAAc,SAAS,gBAAgB,KAAK,IAAI;GAChD,aAAa,SAAS,gBAAgB,KAAK,UAAU;GACrD,gBAAgB,SAAgD,gBAAgB,KAAK,IAAI;EAC7F;CACJ;CACA,MAAM;EACF,MAAM,EAAE,aAAa,uFAAuF;EAC5G,SAAS;EACT,UAAU,EAAE,WAAW,sDAAsD;EAC7E,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
|
package/dist/base.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TypedFlatConfigItem } from "@antfu/eslint-config";
|
|
2
|
+
import { createBaseRules } from "./_internals/configs/base-rules.js";
|
|
2
3
|
export declare function createBaseConfigs(environment?: 'bun' | 'node'): TypedFlatConfigItem[];
|
|
3
|
-
export
|
|
4
|
+
export { createBaseRules };
|
|
4
5
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":[],"sources":["../src/base.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../src/base.ts"],"mappings":";;wBAoCgB,kBAAkB,+BAAuC"}
|
package/dist/base.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import { jsdocSettings, typescriptJsdocConfig } from "./_internals/jsdoc.js";
|
|
2
|
-
import { customPlugins } from "./_internals/plugins.js";
|
|
3
|
-
import { restrictedSyntax } from "./_internals/restricted-syntax.js";
|
|
4
|
-
import { createTypeAwareConfig } from "./_internals/type-aware.js";
|
|
5
|
-
import { createTypefestConfig } from "./_internals/typefest.js";
|
|
6
1
|
import { GLOB_JS, GLOB_JSX, GLOB_TESTS, GLOB_TS, GLOB_TSX } from "@antfu/eslint-config";
|
|
7
2
|
import promise from "eslint-plugin-promise";
|
|
3
|
+
import { createBaseRules } from "./_internals/configs/base-rules.js";
|
|
4
|
+
import { jsdocSettings, typescriptJsdocConfig } from "./_internals/configs/jsdoc.js";
|
|
5
|
+
import { createTypeAwareConfig } from "./_internals/configs/type-aware.js";
|
|
6
|
+
import { createTypefestConfig } from "./_internals/configs/typefest.js";
|
|
7
|
+
import { customPlugins } from "./_internals/rules/index.js";
|
|
8
8
|
// src/base.ts
|
|
9
|
-
const basePerfectionistSortOptions = {
|
|
10
|
-
ignoreCase: false,
|
|
11
|
-
type: "natural"
|
|
12
|
-
};
|
|
13
9
|
const vscodeOrderSensitiveArrayProperties = [
|
|
14
10
|
"args",
|
|
15
11
|
"autoAttachSmartPattern",
|
|
@@ -69,7 +65,7 @@ function createBaseConfigs(environment = "node") {
|
|
|
69
65
|
files: GLOB_TESTS,
|
|
70
66
|
rules: {
|
|
71
67
|
"kikiutils/consistent-parameter-layout": ["error", { compactTestCalls: true }],
|
|
72
|
-
"no-restricted-imports": ["error", { paths: [{
|
|
68
|
+
"kikiutils/no-restricted-test-imports": ["error", { paths: [{
|
|
73
69
|
importNames: ["expect"],
|
|
74
70
|
message: "Use `expect` from the test context.",
|
|
75
71
|
name: "vitest"
|
|
@@ -118,179 +114,6 @@ function createBaseConfigs(environment = "node") {
|
|
|
118
114
|
{ ignores: ["**/.serena/**"] }
|
|
119
115
|
];
|
|
120
116
|
}
|
|
121
|
-
function createBaseRules(environment = "node") {
|
|
122
|
-
return {
|
|
123
|
-
"antfu/consistent-list-newline": ["error", {
|
|
124
|
-
ArrayExpression: false,
|
|
125
|
-
ArrayPattern: false
|
|
126
|
-
}],
|
|
127
|
-
"antfu/curly": "off",
|
|
128
|
-
"antfu/if-newline": "off",
|
|
129
|
-
"antfu/no-top-level-await": "off",
|
|
130
|
-
"antfu/reasonable-newline": "off",
|
|
131
|
-
"arrow-body-style": ["error", "as-needed"],
|
|
132
|
-
"curly": ["error", "multi-line"],
|
|
133
|
-
"jsdoc/check-tag-names": "error",
|
|
134
|
-
"jsdoc/multiline-blocks": ["error", {
|
|
135
|
-
noSingleLineBlocks: true,
|
|
136
|
-
singleLineTags: ["type", "import"]
|
|
137
|
-
}],
|
|
138
|
-
"jsdoc/no-blank-blocks": ["error", { enableFixer: true }],
|
|
139
|
-
"jsdoc/require-asterisk-prefix": "error",
|
|
140
|
-
"jsdoc/require-hyphen-before-param-description": [
|
|
141
|
-
"error",
|
|
142
|
-
"always",
|
|
143
|
-
{ tags: { typeParam: "always" } }
|
|
144
|
-
],
|
|
145
|
-
"kikiutils/compact-iteration-layout": "error",
|
|
146
|
-
"kikiutils/consistent-condition-layout": "error",
|
|
147
|
-
"kikiutils/consistent-parameter-layout": "error",
|
|
148
|
-
"kikiutils/statement-padding": "error",
|
|
149
|
-
"max-classes-per-file": ["error", 1],
|
|
150
|
-
"no-constant-binary-expression": "error",
|
|
151
|
-
"no-empty": ["error", { allowEmptyCatch: false }],
|
|
152
|
-
"no-promise-executor-return": ["error", { allowVoid: true }],
|
|
153
|
-
"no-restricted-imports": ["error", { patterns: [{
|
|
154
|
-
message: "`_internals` modules are private to their own directory; import the public module instead.",
|
|
155
|
-
regex: String.raw`^[^.].*/_internals(/|$)`
|
|
156
|
-
}] }],
|
|
157
|
-
"no-restricted-syntax": ["error", ...restrictedSyntax],
|
|
158
|
-
"no-useless-assignment": "error",
|
|
159
|
-
"perfectionist/sort-array-includes": ["error", basePerfectionistSortOptions],
|
|
160
|
-
"perfectionist/sort-enums": ["error", {
|
|
161
|
-
...basePerfectionistSortOptions,
|
|
162
|
-
sortByValue: "never"
|
|
163
|
-
}],
|
|
164
|
-
"perfectionist/sort-heritage-clauses": ["error", basePerfectionistSortOptions],
|
|
165
|
-
"perfectionist/sort-imports": ["error", {
|
|
166
|
-
environment,
|
|
167
|
-
groups: [
|
|
168
|
-
"side-effect",
|
|
169
|
-
"side-effect-style",
|
|
170
|
-
"style",
|
|
171
|
-
["value-builtin", "type-builtin"],
|
|
172
|
-
["value-external", "type-external"],
|
|
173
|
-
["value-internal", "type-internal"],
|
|
174
|
-
["value-parent", "type-parent"],
|
|
175
|
-
["value-sibling", "type-sibling"],
|
|
176
|
-
["value-index", "type-index"],
|
|
177
|
-
"unknown"
|
|
178
|
-
],
|
|
179
|
-
ignoreCase: false,
|
|
180
|
-
internalPattern: [
|
|
181
|
-
"^#.*",
|
|
182
|
-
"^@/.*",
|
|
183
|
-
"^~/.*"
|
|
184
|
-
],
|
|
185
|
-
type: "natural"
|
|
186
|
-
}],
|
|
187
|
-
"perfectionist/sort-interfaces": ["error", basePerfectionistSortOptions],
|
|
188
|
-
"perfectionist/sort-intersection-types": ["error", basePerfectionistSortOptions],
|
|
189
|
-
"perfectionist/sort-maps": ["error", basePerfectionistSortOptions],
|
|
190
|
-
"perfectionist/sort-modules": ["error", {
|
|
191
|
-
...basePerfectionistSortOptions,
|
|
192
|
-
groups: [
|
|
193
|
-
"declare-type",
|
|
194
|
-
["export-type", "type"],
|
|
195
|
-
"declare-interface",
|
|
196
|
-
["export-interface", "interface"],
|
|
197
|
-
"declare-enum",
|
|
198
|
-
["enum", "export-enum"],
|
|
199
|
-
"declare-class",
|
|
200
|
-
["class", "export-class"],
|
|
201
|
-
"declare-function",
|
|
202
|
-
["export-function", "function"]
|
|
203
|
-
]
|
|
204
|
-
}],
|
|
205
|
-
"perfectionist/sort-object-types": ["error", basePerfectionistSortOptions],
|
|
206
|
-
"perfectionist/sort-objects": ["error", basePerfectionistSortOptions],
|
|
207
|
-
"perfectionist/sort-sets": ["error", basePerfectionistSortOptions],
|
|
208
|
-
"perfectionist/sort-switch-case": ["error", {
|
|
209
|
-
ignoreCase: false,
|
|
210
|
-
type: "natural"
|
|
211
|
-
}],
|
|
212
|
-
"perfectionist/sort-union-types": ["error", basePerfectionistSortOptions],
|
|
213
|
-
"perfectionist/sort-variable-declarations": ["error", basePerfectionistSortOptions],
|
|
214
|
-
"preserve-caught-error": "error",
|
|
215
|
-
"promise/no-multiple-resolved": "error",
|
|
216
|
-
"promise/no-return-in-finally": "error",
|
|
217
|
-
"promise/no-return-wrap": "error",
|
|
218
|
-
"require-await": "off",
|
|
219
|
-
"style/array-bracket-newline": ["error", { multiline: true }],
|
|
220
|
-
"style/array-element-newline": ["error", {
|
|
221
|
-
ArrayExpression: {
|
|
222
|
-
consistent: true,
|
|
223
|
-
minItems: 2
|
|
224
|
-
},
|
|
225
|
-
ArrayPattern: { minItems: 3 }
|
|
226
|
-
}],
|
|
227
|
-
"style/arrow-parens": ["error", "always"],
|
|
228
|
-
"style/brace-style": [
|
|
229
|
-
"error",
|
|
230
|
-
"1tbs",
|
|
231
|
-
{ allowSingleLine: false }
|
|
232
|
-
],
|
|
233
|
-
"style/function-call-spacing": ["error", "never"],
|
|
234
|
-
"style/indent": ["error", 4],
|
|
235
|
-
"style/max-len": ["warn", {
|
|
236
|
-
code: 120,
|
|
237
|
-
comments: 120,
|
|
238
|
-
ignoreStrings: true,
|
|
239
|
-
ignoreTemplateLiterals: true
|
|
240
|
-
}],
|
|
241
|
-
"style/member-delimiter-style": ["error", { multiline: {
|
|
242
|
-
delimiter: "semi",
|
|
243
|
-
requireLast: true
|
|
244
|
-
} }],
|
|
245
|
-
"style/no-extra-parens": [
|
|
246
|
-
"error",
|
|
247
|
-
"all",
|
|
248
|
-
{ nestedBinaryExpressions: false }
|
|
249
|
-
],
|
|
250
|
-
"style/no-extra-semi": "error",
|
|
251
|
-
"style/object-curly-newline": ["error", {
|
|
252
|
-
ExportDeclaration: {
|
|
253
|
-
minProperties: 2,
|
|
254
|
-
multiline: true
|
|
255
|
-
},
|
|
256
|
-
ImportDeclaration: {
|
|
257
|
-
minProperties: 2,
|
|
258
|
-
multiline: true
|
|
259
|
-
},
|
|
260
|
-
ObjectExpression: {
|
|
261
|
-
minProperties: 2,
|
|
262
|
-
multiline: true
|
|
263
|
-
},
|
|
264
|
-
ObjectPattern: {
|
|
265
|
-
minProperties: 3,
|
|
266
|
-
multiline: true
|
|
267
|
-
}
|
|
268
|
-
}],
|
|
269
|
-
"style/operator-linebreak": [
|
|
270
|
-
"error",
|
|
271
|
-
"before",
|
|
272
|
-
{ overrides: { "=": "after" } }
|
|
273
|
-
],
|
|
274
|
-
"style/padding-line-between-statements": [
|
|
275
|
-
"error",
|
|
276
|
-
{
|
|
277
|
-
blankLine: "always",
|
|
278
|
-
next: [
|
|
279
|
-
"class",
|
|
280
|
-
"enum",
|
|
281
|
-
"function"
|
|
282
|
-
],
|
|
283
|
-
prev: "*"
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
blankLine: "always",
|
|
287
|
-
next: "*",
|
|
288
|
-
prev: ["class", "function"]
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
"style/semi": ["error", "always"]
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
117
|
export { createBaseConfigs, createBaseRules };
|
|
295
118
|
|
|
296
119
|
//# sourceMappingURL=base.js.map
|
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 { restrictedSyntax } from './_internals/restricted-syntax';\nimport { createTypeAwareConfig } from './_internals/type-aware';\nimport { createTypefestConfig } from './_internals/typefest';\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 'style/linebreak-style': [\n 'error',\n 'unix',\n ],\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 // Type-fest and ts-extras\n {\n ...createTypefestConfig(),\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 // Serena's project files (`project.yml`, memories) are tool-generated and may be tracked.\n { ignores: ['**/.serena/**'] },\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 // 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 };\n}\n"],"mappings":";;;;;;;;AAwBA,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;GAC5B,yBAAyB,CACrB,SACA,MACJ;EACJ,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;GACA,UAAU,sBAAsB;EACpC;EAEA;GACI,GAAG,sBAAsB;GACzB,OAAO,CACH,SACA,QACJ;GACA,SAAS,CAAC,uBAAuB;EACrC;EAEA;GACI,GAAG,qBAAqB;GACxB,OAAO,CACH,SACA,QACJ;GACA,SAAS,CAAC,uBAAuB;EACrC;EAEA;GACI,OAAO;GACP,OAAO;IACH,yCAAyC,CACrC,SACA,EAAE,kBAAkB,KAAK,CAC7B;IACA,yBAAyB,CACrB,SACA,EACI,OAAO,CACH;KACI,aAAa,CAAC,QAAQ;KACtB,SAAS;KACT,MAAM;IACV,CACJ,EACJ,CACJ;IACA,4BAA4B,CACxB,SACA;KACI,IAAI;KACJ,MAAM;IACV,CACJ;IACA,oBAAoB;IACpB,4BAA4B;IAC5B,+BAA+B,CAC3B,SACA;KACI,wBAAwB;KACxB,6BAA6B;IACjC,CACJ;IACA,qBAAqB;IACrB,gCAAgC;IAChC,qBAAqB;IACrB,gCAAgC;IAChC,oBAAoB,CAChB,SACA;KACI,WAAW,EAAE,IAAI,WAAW;KAC5B,cAAc,EAAE,IAAI,OAAO,GAAG,MAAM;IACxC,CACJ;GACJ;EACJ;EAEA;GACI,OAAO,CAAC,mBAAmB;GAC3B,OAAO;IACH,2BAA2B,CACvB,SACA;KACI,OAAO;MACH,SAAS;MACT,MAAM;KACV;KAEA,aAAa,OAAO,GAAG,wBAAwB,oCAAoC;IACvF,CACJ;IACA,mBAAmB;KACf;KACA;KACA;MACI,eAAe;MACf,SAAS;KACb;IACJ;GACJ;EACJ;EAEA,EAAE,SAAS,CAAC,YAAY,EAAE;EAE1B,EAAE,SAAS,CAAC,eAAe,EAAE;CACjC;AACJ;AAEA,SAAgB,gBAAgB,cAA8B,QAAe;CACzE,OAAO;EACH,iCAAiC,CAC7B,SACA;GACI,iBAAiB;GACjB,cAAc;EAClB,CACJ;EACA,eAAe;EACf,oBAAoB;EACpB,4BAA4B;EAC5B,4BAA4B;EAC5B,oBAAoB,CAChB,SACA,WACJ;EACA,SAAS,CACL,SACA,YACJ;EACA,yBAAyB;EACzB,0BAA0B,CACtB,SACA;GACI,oBAAoB;GACpB,gBAAgB,CACZ,QACA,QACJ;EACJ,CACJ;EACA,yBAAyB,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;EAEjC,YAAY,CACR,SACA,EAAE,iBAAiB,MAAM,CAC7B;EACA,8BAA8B,CAC1B,SACA,EAAE,WAAW,KAAK,CACtB;EACA,yBAAyB,CACrB,SACA,EACI,UAAU,CACN;GACI,SAAS;GACT,OAAO,OAAO,GAAG;EACrB,CACJ,EACJ,CACJ;EACA,wBAAwB,CACpB,SACA,GAAG,gBACP;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"}
|
|
1
|
+
{"version":3,"file":"base.js","names":[],"sources":["../src/base.ts"],"sourcesContent":["import type { TypedFlatConfigItem } 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 { createBaseRules } from './_internals/configs/base-rules';\nimport {\n jsdocSettings,\n typescriptJsdocConfig,\n} from './_internals/configs/jsdoc';\nimport { createTypeAwareConfig } from './_internals/configs/type-aware';\nimport { createTypefestConfig } from './_internals/configs/typefest';\nimport { customPlugins } from './_internals/rules';\n\nexport { createBaseRules };\n\n// Constants/Variables\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 'style/linebreak-style': [\n 'error',\n 'unix',\n ],\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 // Type-fest and ts-extras\n {\n ...createTypefestConfig(),\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 'kikiutils/no-restricted-test-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 // Serena's project files (`project.yml`, memories) are tool-generated and may be tracked.\n { ignores: ['**/.serena/**'] },\n ];\n}\n"],"mappings":";;;;;;;;AAuBA,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;GAC5B,yBAAyB,CACrB,SACA,MACJ;EACJ,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;GACA,UAAU,sBAAsB;EACpC;EAEA;GACI,GAAG,sBAAsB;GACzB,OAAO,CACH,SACA,QACJ;GACA,SAAS,CAAC,uBAAuB;EACrC;EAEA;GACI,GAAG,qBAAqB;GACxB,OAAO,CACH,SACA,QACJ;GACA,SAAS,CAAC,uBAAuB;EACrC;EAEA;GACI,OAAO;GACP,OAAO;IACH,yCAAyC,CACrC,SACA,EAAE,kBAAkB,KAAK,CAC7B;IACA,wCAAwC,CACpC,SACA,EACI,OAAO,CACH;KACI,aAAa,CAAC,QAAQ;KACtB,SAAS;KACT,MAAM;IACV,CACJ,EACJ,CACJ;IACA,4BAA4B,CACxB,SACA;KACI,IAAI;KACJ,MAAM;IACV,CACJ;IACA,oBAAoB;IACpB,4BAA4B;IAC5B,+BAA+B,CAC3B,SACA;KACI,wBAAwB;KACxB,6BAA6B;IACjC,CACJ;IACA,qBAAqB;IACrB,gCAAgC;IAChC,qBAAqB;IACrB,gCAAgC;IAChC,oBAAoB,CAChB,SACA;KACI,WAAW,EAAE,IAAI,WAAW;KAC5B,cAAc,EAAE,IAAI,OAAO,GAAG,MAAM;IACxC,CACJ;GACJ;EACJ;EAEA;GACI,OAAO,CAAC,mBAAmB;GAC3B,OAAO;IACH,2BAA2B,CACvB,SACA;KACI,OAAO;MACH,SAAS;MACT,MAAM;KACV;KAEA,aAAa,OAAO,GAAG,wBAAwB,oCAAoC;IACvF,CACJ;IACA,mBAAmB;KACf;KACA;KACA;MACI,eAAe;MACf,SAAS;KACb;IACJ;GACJ;EACJ;EAEA,EAAE,SAAS,CAAC,YAAY,EAAE;EAE1B,EAAE,SAAS,CAAC,eAAe,EAAE;CACjC;AACJ"}
|
package/dist/nuxt.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.d.ts","names":[],"sources":["../src/nuxt.ts"],"mappings":";wBA8CgB,qBAAqB"}
|
package/dist/nuxt.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { GLOB_SRC, GLOB_TESTS, GLOB_VUE } from "@antfu/eslint-config";
|
|
4
|
+
import { customPlugins } from "./_internals/rules/index.js";
|
|
5
|
+
// src/nuxt.ts
|
|
6
|
+
const nuxtServerHelpers = [
|
|
7
|
+
"clearSession",
|
|
8
|
+
"createError",
|
|
9
|
+
"defineEventHandler",
|
|
10
|
+
"defineHandler",
|
|
11
|
+
"deleteCookie",
|
|
12
|
+
"eventHandler",
|
|
13
|
+
"getCookie",
|
|
14
|
+
"getQuery",
|
|
15
|
+
"getRequestHeader",
|
|
16
|
+
"getRequestHeaders",
|
|
17
|
+
"getRequestHost",
|
|
18
|
+
"getRequestIP",
|
|
19
|
+
"getRequestProtocol",
|
|
20
|
+
"getRequestURL",
|
|
21
|
+
"getRouteRules",
|
|
22
|
+
"getRouterParam",
|
|
23
|
+
"getRouterParams",
|
|
24
|
+
"getSession",
|
|
25
|
+
"getValidatedQuery",
|
|
26
|
+
"handleCors",
|
|
27
|
+
"parseCookies",
|
|
28
|
+
"readBody",
|
|
29
|
+
"readValidatedBody",
|
|
30
|
+
"sendRedirect",
|
|
31
|
+
"setCookie",
|
|
32
|
+
"setResponseStatus",
|
|
33
|
+
"updateSession",
|
|
34
|
+
"useAppConfig",
|
|
35
|
+
"useRuntimeConfig",
|
|
36
|
+
"useSession"
|
|
37
|
+
];
|
|
38
|
+
function createNuxtConfigs() {
|
|
39
|
+
const nuxtRestrictedSyntax = [{
|
|
40
|
+
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.",
|
|
41
|
+
selector: "Program > ExpressionStatement > AwaitExpression > CallExpression[callee.name=\"navigateTo\"]"
|
|
42
|
+
}, ...hasSeoUtils() ? [{
|
|
43
|
+
message: "nuxt-seo-utils infers og:title and og:description from `title` and `description`, X falls back to them for its title and description, and the seo layer sets `twitter:card`. Setting these keys stops the inference; set `title` and `description` instead.",
|
|
44
|
+
selector: "CallExpression[callee.name=/^use(Server)?SeoMeta$/] > ObjectExpression > Property[key.name=/^(ogDescription|ogTitle|twitterCard|twitterDescription|twitterTitle)$/]"
|
|
45
|
+
}] : []];
|
|
46
|
+
return [
|
|
47
|
+
{
|
|
48
|
+
files: [GLOB_SRC, GLOB_VUE],
|
|
49
|
+
plugins: { kikiutils: customPlugins },
|
|
50
|
+
rules: {
|
|
51
|
+
"kikiutils/no-composable-in-head-getter": "error",
|
|
52
|
+
"kikiutils/no-restricted-nuxt-syntax": ["error", ...nuxtRestrictedSyntax]
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
files: ["**/pages/**/*.{ts,vue}"],
|
|
57
|
+
rules: { "kikiutils/no-restricted-nuxt-page-syntax": ["error", {
|
|
58
|
+
message: "`<html lang>` follows the current locale through the i18n layer, or `app.head` in `nuxt.config.ts` without i18n; setting it in a page overrides it.",
|
|
59
|
+
selector: "CallExpression[callee.name=/^use(Server)?Head(Safe)?$/] Property[key.name=\"htmlAttrs\"] > ObjectExpression > Property[key.name=\"lang\"]"
|
|
60
|
+
}] }
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
files: ["**/server/{api,routes}/**/*.?([cm])[jt]s"],
|
|
64
|
+
ignores: GLOB_TESTS,
|
|
65
|
+
rules: { "kikiutils/nitro-route-method-suffix": "error" }
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
files: ["**/server/**/*.?([cm])[jt]s"],
|
|
69
|
+
rules: { "kikiutils/no-restricted-nuxt-server-imports": ["error", { paths: [
|
|
70
|
+
"#imports",
|
|
71
|
+
"h3",
|
|
72
|
+
"nitropack/runtime"
|
|
73
|
+
].map((name) => ({
|
|
74
|
+
importNames: nuxtServerHelpers,
|
|
75
|
+
message: "Import this helper from `nuxt/server`, which runs on Nuxt 4.6 and Nuxt 5; the h3 and Nitro versions expect a different event. Keep h3 or `nitropack/runtime` only for helpers `nuxt/server` does not provide.",
|
|
76
|
+
name
|
|
77
|
+
})) }] }
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
function hasSeoUtils() {
|
|
82
|
+
try {
|
|
83
|
+
const { dependencies, devDependencies } = JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf8"));
|
|
84
|
+
return ["@nuxtjs/seo", "nuxt-seo-utils"].some((name) => name in {
|
|
85
|
+
...dependencies,
|
|
86
|
+
...devDependencies
|
|
87
|
+
});
|
|
88
|
+
} catch {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export { createNuxtConfigs };
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=nuxt.js.map
|
package/dist/nuxt.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.js","names":[],"sources":["../src/nuxt.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nimport type { TypedFlatConfigItem } from '@antfu/eslint-config';\nimport {\n GLOB_SRC,\n GLOB_TESTS,\n GLOB_VUE,\n} from '@antfu/eslint-config';\n\nimport { customPlugins } from './_internals/rules';\n\n// Server helpers that `nuxt/server` provides since Nuxt 4.6.\nconst nuxtServerHelpers = [\n 'clearSession',\n 'createError',\n 'defineEventHandler',\n 'defineHandler',\n 'deleteCookie',\n 'eventHandler',\n 'getCookie',\n 'getQuery',\n 'getRequestHeader',\n 'getRequestHeaders',\n 'getRequestHost',\n 'getRequestIP',\n 'getRequestProtocol',\n 'getRequestURL',\n 'getRouteRules',\n 'getRouterParam',\n 'getRouterParams',\n 'getSession',\n 'getValidatedQuery',\n 'handleCors',\n 'parseCookies',\n 'readBody',\n 'readValidatedBody',\n 'sendRedirect',\n 'setCookie',\n 'setResponseStatus',\n 'updateSession',\n 'useAppConfig',\n 'useRuntimeConfig',\n 'useSession',\n];\n\nexport function createNuxtConfigs(): TypedFlatConfigItem[] {\n const nuxtRestrictedSyntax = [\n {\n 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.',\n selector: 'Program > ExpressionStatement > AwaitExpression > CallExpression[callee.name=\"navigateTo\"]',\n },\n ...hasSeoUtils()\n ? [\n {\n message: 'nuxt-seo-utils infers og:title and og:description from `title` and `description`, X falls back to them for its title and description, and the seo layer sets `twitter:card`. Setting these keys stops the inference; set `title` and `description` instead.',\n selector: 'CallExpression[callee.name=/^use(Server)?SeoMeta$/] > ObjectExpression > Property[key.name=/^(ogDescription|ogTitle|twitterCard|twitterDescription|twitterTitle)$/]',\n },\n ]\n : [],\n ];\n\n return [\n {\n files: [\n GLOB_SRC,\n GLOB_VUE,\n ],\n plugins: { kikiutils: customPlugins },\n rules: {\n 'kikiutils/no-composable-in-head-getter': 'error',\n 'kikiutils/no-restricted-nuxt-syntax': [\n 'error',\n ...nuxtRestrictedSyntax,\n ],\n },\n },\n {\n files: ['**/pages/**/*.{ts,vue}'],\n rules: {\n 'kikiutils/no-restricted-nuxt-page-syntax': [\n 'error',\n {\n message: '`<html lang>` follows the current locale through the i18n layer, or `app.head` in `nuxt.config.ts` without i18n; setting it in a page overrides it.',\n selector: 'CallExpression[callee.name=/^use(Server)?Head(Safe)?$/] Property[key.name=\"htmlAttrs\"] > ObjectExpression > Property[key.name=\"lang\"]',\n },\n ],\n },\n },\n {\n files: ['**/server/{api,routes}/**/*.?([cm])[jt]s'],\n ignores: GLOB_TESTS,\n rules: { 'kikiutils/nitro-route-method-suffix': 'error' },\n },\n {\n files: ['**/server/**/*.?([cm])[jt]s'],\n rules: {\n 'kikiutils/no-restricted-nuxt-server-imports': [\n 'error',\n {\n paths: [\n '#imports',\n 'h3',\n 'nitropack/runtime',\n ].map((name) => ({\n importNames: nuxtServerHelpers,\n message: 'Import this helper from `nuxt/server`, which runs on Nuxt 4.6 and Nuxt 5; the h3 and Nitro versions expect a different event. Keep h3 or `nitropack/runtime` only for helpers `nuxt/server` does not provide.',\n name,\n })),\n },\n ],\n },\n },\n ];\n}\n\nfunction hasSeoUtils(): boolean {\n try {\n const { dependencies, devDependencies } = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8'));\n return [\n '@nuxtjs/seo',\n 'nuxt-seo-utils',\n ].some((name) => name in {\n ...dependencies,\n ...devDependencies,\n });\n } catch {\n // Without a readable package.json, skip the rules that depend on the SEO modules.\n return false;\n }\n}\n"],"mappings":";;;;;AAaA,MAAM,oBAAoB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAEA,SAAgB,oBAA2C;CACvD,MAAM,uBAAuB,CACzB;EACI,SAAS;EACT,UAAU;CACd,GACA,GAAG,YAAY,IACT,CACE;EACI,SAAS;EACT,UAAU;CACd,CACJ,IACE,CAAC,CACX;CAEA,OAAO;EACH;GACI,OAAO,CACH,UACA,QACJ;GACA,SAAS,EAAE,WAAW,cAAc;GACpC,OAAO;IACH,0CAA0C;IAC1C,uCAAuC,CACnC,SACA,GAAG,oBACP;GACJ;EACJ;EACA;GACI,OAAO,CAAC,wBAAwB;GAChC,OAAO,EACH,4CAA4C,CACxC,SACA;IACI,SAAS;IACT,UAAU;GACd,CACJ,EACJ;EACJ;EACA;GACI,OAAO,CAAC,0CAA0C;GAClD,SAAS;GACT,OAAO,EAAE,uCAAuC,QAAQ;EAC5D;EACA;GACI,OAAO,CAAC,6BAA6B;GACrC,OAAO,EACH,+CAA+C,CAC3C,SACA,EACI,OAAO;IACH;IACA;IACA;GACJ,CAAC,CAAC,KAAK,UAAU;IACb,aAAa;IACb,SAAS;IACT;GACJ,EAAE,EACN,CACJ,EACJ;EACJ;CACJ;AACJ;AAEA,SAAS,cAAuB;CAC5B,IAAI;EACA,MAAM,EAAE,cAAc,oBAAoB,KAAK,MAAM,aAAa,KAAK,QAAQ,IAAI,GAAG,cAAc,GAAG,MAAM,CAAC;EAC9G,OAAO,CACH,eACA,gBACJ,CAAC,CAAC,MAAM,SAAS,QAAQ;GACrB,GAAG;GACH,GAAG;EACP,CAAC;CACL,QAAQ;EAEJ,OAAO;CACX;AACJ"}
|
package/dist/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"vue.d.ts","names":[],"sources":["../src/vue.ts"],"mappings":";wBAYgB,gBAAgB,+BAAuC"}
|
package/dist/vue.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { typescriptJsdocConfig } from "./_internals/jsdoc.js";
|
|
2
|
-
import { customPlugins } from "./_internals/plugins.js";
|
|
3
|
-
import { restrictedSyntax } from "./_internals/restricted-syntax.js";
|
|
4
|
-
import { createTypeAwareConfig } from "./_internals/type-aware.js";
|
|
5
|
-
import { createTypefestConfig } from "./_internals/typefest.js";
|
|
6
|
-
import { createBaseRules } from "./base.js";
|
|
7
|
-
import promise from "eslint-plugin-promise";
|
|
8
1
|
import kikiutilsEslintPluginVue from "@kikiutils/eslint-plugin-vue";
|
|
9
2
|
import betterTailwindcss from "eslint-plugin-better-tailwindcss";
|
|
3
|
+
import promise from "eslint-plugin-promise";
|
|
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
|