@kikiutils/eslint-config 12.0.3 → 12.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/_internals/rules/comment-indent.d.ts.map +1 -1
- package/dist/_internals/rules/comment-indent.js +36 -27
- package/dist/_internals/rules/comment-indent.js.map +1 -1
- package/dist/_internals/rules/compact-iteration-layout.js +1 -0
- package/dist/_internals/rules/compact-iteration-layout.js.map +1 -1
- package/dist/_internals/rules/consistent-parameter-layout.js +23 -36
- package/dist/_internals/rules/consistent-parameter-layout.js.map +1 -1
- package/dist/_internals/rules/no-composable-in-head-getter.d.ts.map +1 -1
- package/dist/_internals/rules/no-composable-in-head-getter.js +20 -27
- package/dist/_internals/rules/no-composable-in-head-getter.js.map +1 -1
- package/dist/_internals/rules/no-silent-catch.js +2 -2
- package/dist/_internals/rules/no-silent-catch.js.map +1 -1
- package/dist/_internals/rules/no-thenable-zod-refinement.d.ts.map +1 -1
- package/dist/_internals/rules/no-thenable-zod-refinement.js.map +1 -1
- package/dist/_internals/rules/prefer-enhanced-date.d.ts.map +1 -1
- package/dist/_internals/rules/prefer-enhanced-date.js +38 -42
- package/dist/_internals/rules/prefer-enhanced-date.js.map +1 -1
- package/dist/_internals/rules/statement-padding.js +1 -1
- package/dist/_internals/rules/statement-padding.js.map +1 -1
- package/dist/_internals/rules/utils.d.ts +1 -1
- package/dist/_internals/rules/utils.js.map +1 -1
- package/dist/base.js.map +1 -1
- package/dist/nuxt.js +1 -4
- package/dist/nuxt.js.map +1 -1
- package/dist/vue.d.ts.map +1 -1
- package/dist/vue.js +8 -2
- package/dist/vue.js.map +1 -1
- package/package.json +4 -4
- package/src/_internals/rules/comment-indent.ts +44 -52
- package/src/_internals/rules/compact-iteration-layout.ts +1 -0
- package/src/_internals/rules/consistent-parameter-layout.ts +41 -66
- package/src/_internals/rules/no-composable-in-head-getter.ts +23 -28
- package/src/_internals/rules/no-silent-catch.ts +2 -3
- package/src/_internals/rules/no-thenable-zod-refinement.ts +1 -2
- package/src/_internals/rules/prefer-enhanced-date.ts +58 -88
- package/src/_internals/rules/statement-padding.ts +1 -1
- package/src/_internals/rules/utils.ts +1 -1
- package/src/base.ts +0 -2
- package/src/nuxt.ts +2 -6
- package/src/vue.ts +9 -2
|
@@ -51,7 +51,7 @@ const staticMethods = new Map(objectEntries({
|
|
|
51
51
|
startOfTomorrow: "startOfTomorrow",
|
|
52
52
|
startOfYesterday: "startOfYesterday"
|
|
53
53
|
}));
|
|
54
|
-
const
|
|
54
|
+
const unparenthesizedReceiverTypes = /* @__PURE__ */ new Set([
|
|
55
55
|
"CallExpression",
|
|
56
56
|
"Identifier",
|
|
57
57
|
"MemberExpression",
|
|
@@ -83,7 +83,6 @@ const preferEnhancedDate = {
|
|
|
83
83
|
const nodeMap = services?.esTreeNodeToTSNodeMap;
|
|
84
84
|
const dateFnsCalls = /* @__PURE__ */ new Map();
|
|
85
85
|
const plans = /* @__PURE__ */ new Map();
|
|
86
|
-
const chainedCalls = /* @__PURE__ */ new Set();
|
|
87
86
|
function isEnhancedDate(node) {
|
|
88
87
|
if (!checker || !nodeMap) return false;
|
|
89
88
|
return checker.getTypeAtLocation(nodeMap.get(node)).getSymbol()?.getName() === "EnhancedDate";
|
|
@@ -92,44 +91,45 @@ const preferEnhancedDate = {
|
|
|
92
91
|
if (node.type !== "Identifier" || node.name !== "Date") return false;
|
|
93
92
|
return (findVariable(sourceCode.getScope(node), "Date")?.defs ?? []).every((definition) => definition.type === "ImportBinding" && isTypeImport(definition.parent));
|
|
94
93
|
}
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
const unresolved = {};
|
|
95
|
+
const imports = {};
|
|
96
|
+
function hasUnresolvedReference(name) {
|
|
97
|
+
return unresolved[name] ??= sourceCode.scopeManager.globalScope.through.some((reference) => reference.identifier.name === name);
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
const
|
|
100
|
-
if (variable) return variable.defs.every((definition) => definition.type !== "ImportBinding" || !isTypeImport(definition.node) && !isTypeImport(definition.parent)) ? [] : void 0;
|
|
101
|
-
if (isUnresolved(name)) return [];
|
|
102
|
-
const { body, sourceType } = sourceCode.ast;
|
|
103
|
-
if (sourceType !== "module" || /\.c[jt]s$/.test(context.filename)) return;
|
|
99
|
+
function createImport(fixer, name) {
|
|
100
|
+
const { body } = sourceCode.ast;
|
|
104
101
|
const importText = `import { ${name} } from '${importSources[name]}';`;
|
|
105
102
|
const lastImport = body.findLast((statement) => statement.type === "ImportDeclaration");
|
|
106
103
|
if (lastImport) {
|
|
107
104
|
const after = sourceCode.getTokenAfter(lastImport, { includeComments: true });
|
|
108
|
-
const
|
|
109
|
-
return
|
|
105
|
+
const isTrailingComment = (after?.type === "Block" || after?.type === "Line") && after.loc.start.line === lastImport.loc.end.line;
|
|
106
|
+
return fixer.insertTextAfterRange((isTrailingComment ? after : lastImport).range, `\n${importText}`);
|
|
110
107
|
}
|
|
111
108
|
const lastDirective = body.findLast((statement) => "directive" in statement && !!statement.directive);
|
|
112
|
-
if (lastDirective) return
|
|
109
|
+
if (lastDirective) return fixer.insertTextAfter(lastDirective, `\n\n${importText}`);
|
|
113
110
|
const [first] = body;
|
|
114
|
-
let
|
|
111
|
+
let range = first.range;
|
|
115
112
|
let line = first.loc.start.line;
|
|
116
113
|
for (const comment of sourceCode.getCommentsBefore(first).toReversed()) {
|
|
117
114
|
if (comment.type === "Shebang" || comment.loc.end.line + 1 < line) break;
|
|
118
|
-
|
|
115
|
+
range = comment.range;
|
|
119
116
|
line = comment.loc.start.line;
|
|
120
117
|
}
|
|
121
|
-
return
|
|
118
|
+
return fixer.insertTextBeforeRange(range, `${importText}\n\n`);
|
|
122
119
|
}
|
|
123
120
|
function isSharedFormatDateAvailable(node) {
|
|
124
121
|
const definitions = findVariable(sourceCode.getScope(node), "formatDate")?.defs;
|
|
125
|
-
if (!definitions) return !
|
|
122
|
+
if (!definitions) return !hasUnresolvedReference("formatDate");
|
|
126
123
|
return definitions.length > 0 && definitions.every((definition) => definition.type === "ImportBinding" && definition.parent.source.value === importSources.formatDate);
|
|
127
124
|
}
|
|
128
125
|
function withProvided(node, fixer, name, fix) {
|
|
129
|
-
const
|
|
130
|
-
return
|
|
126
|
+
const variable = findVariable(sourceCode.getScope(node), name);
|
|
127
|
+
if (variable) return variable.defs.every((definition) => definition.type !== "ImportBinding" || !isTypeImport(definition.node) && !isTypeImport(definition.parent)) ? fix : null;
|
|
128
|
+
if (hasUnresolvedReference(name)) return fix;
|
|
129
|
+
if (sourceCode.ast.sourceType !== "module" || /\.c[jt]s$/.test(context.filename)) return null;
|
|
130
|
+
return [fix, imports[name] ??= createImport(fixer, name)];
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function getArgumentTokensWithParens(node, openParen) {
|
|
133
133
|
let first = sourceCode.getFirstToken(node);
|
|
134
134
|
let last = sourceCode.getLastToken(node);
|
|
135
135
|
for (;;) {
|
|
@@ -147,9 +147,6 @@ const preferEnhancedDate = {
|
|
|
147
147
|
plans.set(node, plan);
|
|
148
148
|
return plan;
|
|
149
149
|
}
|
|
150
|
-
function getRewrittenText(node, edit) {
|
|
151
|
-
return edit.text + sourceCode.text.slice(edit.range[1], node.range[1]);
|
|
152
|
-
}
|
|
153
150
|
function createPlan(node, name) {
|
|
154
151
|
if (node.optional || node.arguments.some((argument) => argument.type === "SpreadElement")) return;
|
|
155
152
|
const openParen = sourceCode.getTokenAfter(node.callee, (token) => token.value === "(");
|
|
@@ -175,12 +172,6 @@ const preferEnhancedDate = {
|
|
|
175
172
|
const isExisting = !isFresh && isEnhancedDate(target);
|
|
176
173
|
const isWrapped = !isFresh && !isExisting;
|
|
177
174
|
if (name === "isValid" && isWrapped) return;
|
|
178
|
-
const [firstToken, lastToken] = getArgumentTokens(target, openParen);
|
|
179
|
-
const targetText = sourceCode.text.slice(firstToken.range[0], lastToken.range[1]);
|
|
180
|
-
const closeParen = sourceCode.getLastToken(node);
|
|
181
|
-
const separator = rest.length ? sourceCode.getTokenAfter(lastToken) : closeParen;
|
|
182
|
-
const hasLostComments = sourceCode.commentsExistBetween(openParen, firstToken) || sourceCode.commentsExistBetween(lastToken, separator);
|
|
183
|
-
const awaitsLater = isWrapped && rest.some((argument) => sourceCode.getTokens(argument).some((token) => token.value === "await" || token.value === "yield"));
|
|
184
175
|
if (name === "format" && isWrapped && isSharedFormatDateAvailable(node)) return {
|
|
185
176
|
edit: {
|
|
186
177
|
provides: "formatDate",
|
|
@@ -190,24 +181,29 @@ const preferEnhancedDate = {
|
|
|
190
181
|
replacement: "formatDate()",
|
|
191
182
|
returnsDate: false
|
|
192
183
|
};
|
|
184
|
+
const [firstToken, lastToken] = getArgumentTokensWithParens(target, openParen);
|
|
185
|
+
const targetText = sourceCode.text.slice(firstToken.range[0], lastToken.range[1]);
|
|
186
|
+
const closeParen = sourceCode.getLastToken(node);
|
|
187
|
+
const separator = rest.length ? sourceCode.getTokenAfter(lastToken) : closeParen;
|
|
188
|
+
const hasLostComments = sourceCode.commentsExistBetween(openParen, firstToken) || sourceCode.commentsExistBetween(lastToken, separator);
|
|
189
|
+
const awaitsLater = isWrapped && rest.some((argument) => sourceCode.getFirstToken(argument, (token) => token.value === "await" || token.value === "yield"));
|
|
190
|
+
const replacement = `${isWrapped ? "new EnhancedDate(date)" : "date"}.${name}()`;
|
|
191
|
+
const returnsDate = /^(?:add|endOf|startOf|sub)[A-Z]/.test(name);
|
|
192
|
+
if (hasLostComments || awaitsLater) return {
|
|
193
|
+
replacement,
|
|
194
|
+
returnsDate
|
|
195
|
+
};
|
|
193
196
|
let receiver = `new EnhancedDate(${targetText})`;
|
|
194
197
|
if (innerEdit) {
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
receiver = sourceCode.text.slice(firstToken.range[0], target.range[0]) + innerEdit.text + sourceCode.text.slice(innerEdit.range[1], lastToken.range[1]);
|
|
199
|
+
delete inner.edit;
|
|
197
200
|
} else if (isNewDate) {
|
|
198
201
|
const callee = target.callee;
|
|
199
202
|
receiver = `new EnhancedDate${sourceCode.text.slice(callee.range[1], target.range[1]) || "()"}`;
|
|
200
203
|
} else if (isExisting) {
|
|
201
204
|
const isParenthesized = firstToken !== sourceCode.getFirstToken(target);
|
|
202
|
-
receiver =
|
|
205
|
+
receiver = unparenthesizedReceiverTypes.has(target.type) || isParenthesized ? targetText : `(${targetText})`;
|
|
203
206
|
}
|
|
204
|
-
const replacement = `${isWrapped ? "new EnhancedDate(date)" : "date"}.${name}()`;
|
|
205
|
-
const returnsDate = /^(?:add|endOf|startOf|sub)[A-Z]/.test(name);
|
|
206
|
-
if (hasLostComments || awaitsLater) return {
|
|
207
|
-
replacement,
|
|
208
|
-
returnsDate
|
|
209
|
-
};
|
|
210
|
-
if (innerEdit) chainedCalls.add(target);
|
|
211
207
|
return {
|
|
212
208
|
edit: {
|
|
213
209
|
provides: innerEdit ? innerEdit.provides : isExisting ? void 0 : "EnhancedDate",
|
|
@@ -219,9 +215,9 @@ const preferEnhancedDate = {
|
|
|
219
215
|
};
|
|
220
216
|
}
|
|
221
217
|
function reportDateFnsCall(node, name) {
|
|
222
|
-
const plan =
|
|
218
|
+
const plan = plans.get(node);
|
|
223
219
|
if (!plan) return;
|
|
224
|
-
const edit =
|
|
220
|
+
const { edit } = plan;
|
|
225
221
|
context.report({
|
|
226
222
|
data: {
|
|
227
223
|
name,
|
|
@@ -229,7 +225,7 @@ const preferEnhancedDate = {
|
|
|
229
225
|
},
|
|
230
226
|
fix: edit ? (fixer) => {
|
|
231
227
|
const fix = fixer.replaceTextRange(edit.range, edit.text);
|
|
232
|
-
return edit.provides ? withProvided(node, fixer, edit.provides, fix) :
|
|
228
|
+
return edit.provides ? withProvided(node, fixer, edit.provides, fix) : fix;
|
|
233
229
|
} : null,
|
|
234
230
|
messageId: "dateFns",
|
|
235
231
|
node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-enhanced-date.js","names":[],"sources":["../../../src/_internals/rules/prefer-enhanced-date.ts"],"sourcesContent":["import type {\n AST,\n Rule,\n Scope,\n} from 'eslint';\nimport { objectEntries } from 'ts-extras';\n\nimport type { ParserServices } from './utils';\n\ntype CallNode = Extract<Rule.Node, { type: 'CallExpression' }>;\ntype ProvidedName = keyof typeof importSources;\n\n// Replaces the start of a call up to `range[1]` with `text`; the rest of the call stays as written.\ninterface Edit {\n provides?: ProvidedName;\n range: AST.Range;\n text: string;\n}\n\ninterface Plan {\n edit?: Edit;\n replacement: string;\n returnsDate: boolean;\n}\n\nconst importSources = {\n EnhancedDate: '@kikiutils/shared/classes/enhanced-date',\n formatDate: '@kikiutils/shared/datetime',\n} as const;\n\n// EnhancedDate mirrors these date-fns functions with the date as `this` and the remaining arguments, options included.\nconst instanceMethods = new Set([\n ...[\n 'Days',\n 'Hours',\n 'Milliseconds',\n 'Minutes',\n 'Months',\n 'Seconds',\n 'Weeks',\n 'Years',\n ].flatMap((unit) => [\n `add${unit}`,\n `sub${unit}`,\n ]),\n ...[\n 'Day',\n 'Minute',\n 'Month',\n 'Week',\n ].flatMap((unit) => [\n `endOf${unit}`,\n `startOf${unit}`,\n ]),\n 'differenceInCalendarDays',\n 'differenceInCalendarWeeks',\n 'differenceInMinutes',\n 'differenceInSeconds',\n 'format',\n 'formatDistanceToNow',\n 'getUnixTime',\n 'isAfter',\n 'isBefore',\n 'isEqual',\n 'isFuture',\n 'isSameDay',\n 'isSameMinute',\n 'isToday',\n 'isTomorrow',\n 'isValid',\n]);\n\nconst staticMethods = new Map<string, string>(objectEntries({\n endOfToday: 'endOfToday',\n endOfTomorrow: 'endOfTomorrow',\n endOfYesterday: 'endOfYesterday',\n fromUnixTime: 'fromUnixSeconds',\n max: 'max',\n min: 'min',\n parse: 'fromFormat',\n parseISO: 'fromISO',\n startOfToday: 'startOfToday',\n startOfTomorrow: 'startOfTomorrow',\n startOfYesterday: 'startOfYesterday',\n}));\n\n// Receivers that need no parentheses before a member access.\nconst memberSafeTypes = new Set([\n 'CallExpression',\n 'Identifier',\n 'MemberExpression',\n 'NewExpression',\n 'ThisExpression',\n]);\n\nfunction findVariable(scope: Scope.Scope, name: string): Scope.Variable | undefined {\n for (let current: null | Scope.Scope = scope; current; current = current.upper) {\n const variable = current.set.get(name);\n if (variable) return variable;\n }\n}\n\n// `date-fns/fp` is curried and `date-fns/locale` has no date functions; `formatDate` is date-fns' alias of `format`.\nfunction getDateFnsName(source: string, importedName: string): string | undefined {\n let name = importedName;\n if (source !== 'date-fns') {\n if (!source.startsWith('date-fns/') || /^date-fns\\/(?:fp|locale)(?:\\/|$)/.test(source)) return;\n if (importedName === 'default') name = source.slice('date-fns/'.length);\n }\n\n return name === 'formatDate' ? 'format' : name;\n}\n\nfunction isTypeImport(node: unknown): boolean {\n return (node as { importKind?: string }).importKind === 'type';\n}\n\nexport const preferEnhancedDate: Rule.RuleModule = {\n create(context) {\n const { sourceCode } = context;\n const services = sourceCode.parserServices as Partial<ParserServices> | undefined;\n // Type information only finds receivers that already are EnhancedDate; files without it are still fixed.\n const checker = services?.program?.getTypeChecker();\n const nodeMap = services?.esTreeNodeToTSNodeMap;\n // Calls are collected first so a call can chain onto the rewrite of a date-fns call in its arguments.\n const dateFnsCalls = new Map<CallNode, string>();\n const plans = new Map<CallNode, Plan | undefined>();\n const chainedCalls = new Set<CallNode>();\n\n function isEnhancedDate(node: Rule.Node): boolean {\n if (!checker || !nodeMap) return false;\n return checker.getTypeAtLocation(nodeMap.get(node)).getSymbol()?.getName() === 'EnhancedDate';\n }\n\n function isNativeDate(node: Rule.Node): boolean {\n if (node.type !== 'Identifier' || node.name !== 'Date') return false;\n // Value references skip type-only declarations; anything else declared as `Date` is not the global.\n const definitions = findVariable(sourceCode.getScope(node), 'Date')?.defs ?? [];\n return definitions.every((definition) => definition.type === 'ImportBinding' && isTypeImport(definition.parent));\n }\n\n // Nuxt auto-imports and globals the parser does not know show up as unresolved references.\n function isUnresolved(name: string): boolean {\n return sourceCode.scopeManager.globalScope!.through.some((reference) => reference.identifier.name === name);\n }\n\n // Returns undefined when the name cannot be provided, such as a type-only binding or a CommonJS file.\n function provide(node: Rule.Node, fixer: Rule.RuleFixer, name: ProvidedName): Rule.Fix[] | undefined {\n const variable = findVariable(sourceCode.getScope(node), name);\n if (variable) {\n // Configured globals have no definitions.\n const isValue = variable.defs.every((definition) => definition.type !== 'ImportBinding' || (!isTypeImport(definition.node) && !isTypeImport(definition.parent)));\n return isValue ? [] : undefined;\n }\n\n if (isUnresolved(name)) return [];\n const { body, sourceType } = sourceCode.ast;\n // Configs often parse CommonJS files as modules, so the extension decides as well.\n if (sourceType !== 'module' || /\\.c[jt]s$/.test(context.filename)) return;\n const importText = `import { ${name} } from '${importSources[name]}';`;\n const lastImport = body.findLast((statement) => statement.type === 'ImportDeclaration');\n if (lastImport) {\n // A trailing comment, such as `// eslint-disable-line`, stays on the import it belongs to.\n const after = sourceCode.getTokenAfter(lastImport, { includeComments: true });\n const isTrailingComment = (after?.type === 'Block' || after?.type === 'Line') && after.loc!.start.line === lastImport.loc!.end.line;\n const end = isTrailingComment ? after.range![1] : lastImport.range![1];\n return [\n fixer.insertTextAfterRange(\n [\n end,\n end,\n ],\n `\\n${importText}`,\n ),\n ];\n }\n\n const lastDirective = body.findLast((statement) => 'directive' in statement && !!statement.directive);\n if (lastDirective) return [fixer.insertTextAfter(lastDirective, `\\n\\n${importText}`)];\n // Comments directly above the first statement, such as JSDoc or `eslint-disable-next-line`, stay attached to it.\n const [first] = body;\n let start = first!.range![0];\n let line = first!.loc!.start.line;\n for (const comment of sourceCode.getCommentsBefore(first!).toReversed()) {\n if ((comment.type as string) === 'Shebang' || comment.loc!.end.line + 1 < line) break;\n start = comment.range![0];\n line = comment.loc!.start.line;\n }\n\n return [\n fixer.insertTextBeforeRange(\n [\n start,\n start,\n ],\n `${importText}\\n\\n`,\n ),\n ];\n }\n\n // Another local, date-fns, global or auto-imported `formatDate` may take other arguments, so those files keep the wrapper.\n function isSharedFormatDateAvailable(node: Rule.Node): boolean {\n const definitions = findVariable(sourceCode.getScope(node), 'formatDate')?.defs;\n if (!definitions) return !isUnresolved('formatDate');\n return definitions.length > 0 && definitions.every((definition) => definition.type === 'ImportBinding'\n && (definition.parent as unknown as { source: { value: unknown } }).source.value === importSources.formatDate);\n }\n\n function withProvided(node: Rule.Node, fixer: Rule.RuleFixer, name: ProvidedName, fix: Rule.Fix): null | Rule.Fix[] {\n const provided = provide(node, fixer, name);\n return provided\n ? [\n fix,\n ...provided,\n ]\n : null;\n }\n\n // Includes the parentheses written around an argument, which belong to its text.\n function getArgumentTokens(node: Rule.Node, openParen: AST.Token): [AST.Token, AST.Token] {\n let first = sourceCode.getFirstToken(node)!;\n let last = sourceCode.getLastToken(node)!;\n for (;;) {\n const before = sourceCode.getTokenBefore(first)!;\n const after = sourceCode.getTokenAfter(last)!;\n if (before === openParen || before.value !== '(' || after.value !== ')') break;\n first = before;\n last = after;\n }\n\n return [\n first,\n last,\n ];\n }\n\n function getPlan(node: CallNode): Plan | undefined {\n if (plans.has(node)) return plans.get(node);\n const plan = createPlan(node, dateFnsCalls.get(node)!);\n plans.set(node, plan);\n return plan;\n }\n\n function getRewrittenText(node: Rule.Node, edit: Edit): string {\n return edit.text + sourceCode.text.slice(edit.range[1], node.range![1]);\n }\n\n function createPlan(node: CallNode, name: string): Plan | undefined {\n if (node.optional || node.arguments.some((argument) => argument.type === 'SpreadElement')) return;\n const openParen = sourceCode.getTokenAfter(node.callee, (token) => token.value === '(')!;\n const staticMethod = staticMethods.get(name);\n if (staticMethod) {\n // `fromUnixSeconds()` takes no options; `fromUnixTime()` options only pick the returned Date class.\n if (name === 'fromUnixTime' && node.arguments.length > 1) return;\n return {\n edit: {\n provides: 'EnhancedDate',\n range: [\n node.range![0],\n openParen.range[0],\n ],\n text: `EnhancedDate.${staticMethod}`,\n },\n replacement: `EnhancedDate.${staticMethod}()`,\n returnsDate: true,\n };\n }\n\n const [target, ...rest] = node.arguments as Rule.Node[];\n if (!target || !instanceMethods.has(name)) return;\n // A date-fns call that is rewritten too returns a new EnhancedDate, so the method chains onto its rewrite.\n const inner = target.type === 'CallExpression' && dateFnsCalls.has(target) ? getPlan(target) : undefined;\n const innerEdit = inner?.returnsDate ? inner.edit : undefined;\n const isNewDate = target.type === 'NewExpression'\n && target.callee.type === 'Identifier'\n && (target.callee.name === 'EnhancedDate' || isNativeDate(target.callee as Rule.Node));\n\n const isFresh = !!innerEdit || isNewDate;\n const isExisting = !isFresh && isEnhancedDate(target);\n const isWrapped = !isFresh && !isExisting;\n // date-fns `isValid()` is false for anything but a Date or number, which a wrapper would parse instead.\n if (name === 'isValid' && isWrapped) return;\n const [firstToken, lastToken] = getArgumentTokens(target, openParen);\n const targetText = sourceCode.text.slice(firstToken.range[0], lastToken.range[1]);\n const closeParen = sourceCode.getLastToken(node)!;\n const separator = rest.length ? sourceCode.getTokenAfter(lastToken)! : closeParen;\n const hasLostComments = sourceCode.commentsExistBetween(openParen, firstToken) || sourceCode.commentsExistBetween(lastToken, separator);\n // A wrapper copies the date before an awaited argument settles, while date-fns reads it afterwards.\n const awaitsLater = isWrapped && rest.some((argument) => sourceCode.getTokens(argument).some((token) => token.value === 'await' || token.value === 'yield'));\n // Shared's `formatDate` takes the same arguments and reads better than a wrapper.\n if (name === 'format' && isWrapped && isSharedFormatDateAvailable(node)) {\n return {\n edit: {\n provides: 'formatDate',\n range: [\n node.range![0],\n openParen.range[0],\n ],\n text: 'formatDate',\n },\n replacement: 'formatDate()',\n returnsDate: false,\n };\n }\n\n let receiver = `new EnhancedDate(${targetText})`;\n if (innerEdit) {\n const [start, end] = target.range!;\n receiver = sourceCode.text.slice(firstToken.range[0], start) + getRewrittenText(target, innerEdit) + sourceCode.text.slice(end, lastToken.range[1]);\n } else if (isNewDate) {\n const callee = target.callee as Rule.Node;\n receiver = `new EnhancedDate${sourceCode.text.slice(callee.range![1], target.range![1]) || '()'}`;\n } else if (isExisting) {\n const isParenthesized = firstToken !== sourceCode.getFirstToken(target);\n receiver = memberSafeTypes.has(target.type) || isParenthesized ? targetText : `(${targetText})`;\n }\n\n const replacement = `${isWrapped ? 'new EnhancedDate(date)' : 'date'}.${name}()`;\n const returnsDate = /^(?:add|endOf|startOf|sub)[A-Z]/.test(name);\n if (hasLostComments || awaitsLater) {\n return {\n replacement,\n returnsDate,\n };\n }\n\n // The inner rewrite is part of this edit; its own edit would overlap, and when it shares the import insertion it could win.\n if (innerEdit) chainedCalls.add(target as CallNode);\n return {\n edit: {\n provides: innerEdit ? innerEdit.provides : isExisting ? undefined : 'EnhancedDate',\n range: [\n node.range![0],\n rest.length ? sourceCode.getTokenAfter(separator, { includeComments: true })!.range![0] : closeParen.range[1],\n ],\n text: `${receiver}.${name}${rest.length ? '(' : '()'}`,\n },\n replacement,\n returnsDate,\n };\n }\n\n function reportDateFnsCall(node: CallNode, name: string): void {\n const plan = getPlan(node);\n if (!plan) return;\n const edit = chainedCalls.has(node) ? undefined : plan.edit;\n context.report({\n data: {\n name,\n replacement: plan.replacement,\n },\n fix: edit\n ? (fixer) => {\n const fix = fixer.replaceTextRange(edit.range, edit.text);\n return edit.provides ? withProvided(node, fixer, edit.provides, fix) : [fix];\n }\n : null,\n messageId: 'dateFns',\n node,\n });\n }\n\n function checkNativeDateReference(identifier: Rule.Node): void {\n const parent = identifier.parent!;\n const isCallee = (parent.type === 'CallExpression' || parent.type === 'NewExpression') && parent.callee === identifier;\n if (isCallee && parent.type === 'CallExpression') {\n context.report({\n messageId: 'dateCall',\n node: parent,\n });\n\n return;\n }\n\n // `Date.now()` and other statics return numbers; `EnhancedDate` inherits them and would only add an import.\n if (!isCallee) return;\n context.report({\n fix: (fixer) => withProvided(parent, fixer, 'EnhancedDate', fixer.replaceText(identifier, 'EnhancedDate')),\n messageId: 'date',\n node: parent,\n });\n }\n\n function checkNamespaceReference(identifier: Rule.Node): void {\n const parent = identifier.parent!;\n if (\n parent.type !== 'MemberExpression'\n || parent.object !== identifier\n || parent.computed\n || parent.optional\n || parent.property.type !== 'Identifier'\n ) return;\n\n const call = parent.parent;\n if (call.type === 'CallExpression' && call.callee === parent) dateFnsCalls.set(call, getDateFnsName('date-fns', parent.property.name)!);\n }\n\n return {\n 'ImportDeclaration': (node) => {\n const source = node.source.value;\n if (isTypeImport(node) || typeof source !== 'string') return;\n for (const specifier of node.specifiers) {\n if (isTypeImport(specifier)) continue;\n let name: string | undefined;\n if (specifier.type !== 'ImportNamespaceSpecifier') {\n const { imported } = specifier as { imported?: { name?: string; value?: unknown } };\n name = getDateFnsName(source, imported ? imported.name ?? String(imported.value) : 'default');\n if (!name) continue;\n } else if (source !== 'date-fns') continue;\n\n for (const { references } of sourceCode.getDeclaredVariables(specifier)) {\n for (const reference of references) {\n const identifier = reference.identifier as Rule.Node;\n const parent = identifier.parent!;\n if (!name) checkNamespaceReference(identifier);\n else if (parent.type === 'CallExpression' && parent.callee === identifier) dateFnsCalls.set(parent, name);\n }\n }\n }\n },\n 'Program:exit': () => {\n // Every plan exists before reporting, so calls chained into an outer rewrite are known.\n for (const node of dateFnsCalls.keys()) getPlan(node);\n for (const [node, name] of dateFnsCalls) reportDateFnsCall(node, name);\n const { globalScope } = sourceCode.scopeManager;\n const references = globalScope!.set.get('Date')?.references\n ?? globalScope!.through.filter((reference) => reference.identifier.name === 'Date');\n\n for (const reference of references) {\n // typescript-eslint also resolves `: Date` annotations here; only value references create dates.\n if ((reference as { isValueReference?: boolean }).isValueReference === false) continue;\n checkNativeDateReference(reference.identifier as Rule.Node);\n }\n },\n };\n },\n meta: {\n docs: { description: 'Prefer `EnhancedDate` from `@kikiutils/shared` over native `Date` creation and the date-fns functions it wraps.' },\n fixable: 'code',\n messages: {\n date: 'Use `EnhancedDate` instead of `Date`: it is a drop-in subclass with chainable date-fns methods. Disable this line only where a plain `Date` is required.',\n dateCall: '`Date()` returns a string; use `new EnhancedDate().toString()` instead.',\n dateFns: 'Use `{{ replacement }}` instead of date-fns `{{ name }}()` to keep date handling on `EnhancedDate`.',\n },\n schema: [],\n type: 'suggestion',\n },\n};\n"],"mappings":";;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M,CAAC,EAAE,cAC5C,YAAa,QAAQ,QAAQ,cAAc,UAAU,WAAW,SAAS,MAAM;IAEpF,KAAK,MAAM,aAAa,YAAY;KAEhC,IAAK,UAA6C,qBAAqB,OAAO;KAC9E,yBAAyB,UAAU,UAAuB;IAC9D;GACJ;EACJ;CACJ;CACA,MAAM;EACF,MAAM,EAAE,aAAa,kHAAkH;EACvI,SAAS;EACT,UAAU;GACN,MAAM;GACN,UAAU;GACV,SAAS;EACb;EACA,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
|
|
1
|
+
{"version":3,"file":"prefer-enhanced-date.js","names":[],"sources":["../../../src/_internals/rules/prefer-enhanced-date.ts"],"sourcesContent":["import type {\n AST,\n Rule,\n Scope,\n} from 'eslint';\nimport { objectEntries } from 'ts-extras';\n\nimport type { ParserServices } from './utils';\n\ntype CallNode = Extract<Rule.Node, { type: 'CallExpression' }>;\ntype ProvidedName = keyof typeof importSources;\n\ninterface CallPrefixEdit {\n provides?: ProvidedName;\n range: AST.Range;\n text: string;\n}\n\ninterface Plan {\n edit?: CallPrefixEdit;\n replacement: string;\n returnsDate: boolean;\n}\n\nconst importSources = {\n EnhancedDate: '@kikiutils/shared/classes/enhanced-date',\n formatDate: '@kikiutils/shared/datetime',\n} as const;\n\n// EnhancedDate mirrors these date-fns functions with the date as `this` and the remaining arguments, options included.\nconst instanceMethods = new Set([\n ...[\n 'Days',\n 'Hours',\n 'Milliseconds',\n 'Minutes',\n 'Months',\n 'Seconds',\n 'Weeks',\n 'Years',\n ].flatMap((unit) => [\n `add${unit}`,\n `sub${unit}`,\n ]),\n ...[\n 'Day',\n 'Minute',\n 'Month',\n 'Week',\n ].flatMap((unit) => [\n `endOf${unit}`,\n `startOf${unit}`,\n ]),\n 'differenceInCalendarDays',\n 'differenceInCalendarWeeks',\n 'differenceInMinutes',\n 'differenceInSeconds',\n 'format',\n 'formatDistanceToNow',\n 'getUnixTime',\n 'isAfter',\n 'isBefore',\n 'isEqual',\n 'isFuture',\n 'isSameDay',\n 'isSameMinute',\n 'isToday',\n 'isTomorrow',\n 'isValid',\n]);\n\nconst staticMethods = new Map<string, string>(objectEntries({\n endOfToday: 'endOfToday',\n endOfTomorrow: 'endOfTomorrow',\n endOfYesterday: 'endOfYesterday',\n fromUnixTime: 'fromUnixSeconds',\n max: 'max',\n min: 'min',\n parse: 'fromFormat',\n parseISO: 'fromISO',\n startOfToday: 'startOfToday',\n startOfTomorrow: 'startOfTomorrow',\n startOfYesterday: 'startOfYesterday',\n}));\n\nconst unparenthesizedReceiverTypes = new Set([\n 'CallExpression',\n 'Identifier',\n 'MemberExpression',\n 'NewExpression',\n 'ThisExpression',\n]);\n\nfunction findVariable(scope: Scope.Scope, name: string): Scope.Variable | undefined {\n for (let current: null | Scope.Scope = scope; current; current = current.upper) {\n const variable = current.set.get(name);\n if (variable) return variable;\n }\n}\n\n// `date-fns/fp` is curried and `date-fns/locale` has no date functions; `formatDate` is date-fns' alias of `format`.\nfunction getDateFnsName(source: string, importedName: string): string | undefined {\n let name = importedName;\n if (source !== 'date-fns') {\n if (!source.startsWith('date-fns/') || /^date-fns\\/(?:fp|locale)(?:\\/|$)/.test(source)) return;\n if (importedName === 'default') name = source.slice('date-fns/'.length);\n }\n\n return name === 'formatDate' ? 'format' : name;\n}\n\nfunction isTypeImport(node: unknown): boolean {\n return (node as { importKind?: string }).importKind === 'type';\n}\n\nexport const preferEnhancedDate: Rule.RuleModule = {\n create(context) {\n const { sourceCode } = context;\n const services = sourceCode.parserServices as Partial<ParserServices> | undefined;\n // Type information only finds receivers that already are EnhancedDate; files without it are still fixed.\n const checker = services?.program?.getTypeChecker();\n const nodeMap = services?.esTreeNodeToTSNodeMap;\n const dateFnsCalls = new Map<CallNode, string>();\n const plans = new Map<CallNode, Plan | undefined>();\n\n function isEnhancedDate(node: Rule.Node): boolean {\n if (!checker || !nodeMap) return false;\n return checker.getTypeAtLocation(nodeMap.get(node)).getSymbol()?.getName() === 'EnhancedDate';\n }\n\n function isNativeDate(node: Rule.Node): boolean {\n if (node.type !== 'Identifier' || node.name !== 'Date') return false;\n // Value references skip type-only declarations; anything else declared as `Date` is not the global.\n const definitions = findVariable(sourceCode.getScope(node), 'Date')?.defs ?? [];\n return definitions.every((definition) => definition.type === 'ImportBinding' && isTypeImport(definition.parent));\n }\n\n const unresolved: Partial<Record<ProvidedName, boolean>> = {};\n const imports: Partial<Record<ProvidedName, Rule.Fix>> = {};\n\n // Nuxt auto-imports can appear as unresolved references during linting.\n function hasUnresolvedReference(name: ProvidedName): boolean {\n return unresolved[name] ??= sourceCode.scopeManager.globalScope!.through.some((reference) => reference.identifier.name === name);\n }\n\n function createImport(fixer: Rule.RuleFixer, name: ProvidedName): Rule.Fix {\n const { body } = sourceCode.ast;\n const importText = `import { ${name} } from '${importSources[name]}';`;\n const lastImport = body.findLast((statement) => statement.type === 'ImportDeclaration');\n if (lastImport) {\n // A trailing comment, such as `// eslint-disable-line`, stays on the import it belongs to.\n const after = sourceCode.getTokenAfter(lastImport, { includeComments: true });\n const isTrailingComment = (after?.type === 'Block' || after?.type === 'Line') && after.loc!.start.line === lastImport.loc!.end.line;\n return fixer.insertTextAfterRange((isTrailingComment ? after : lastImport).range!, `\\n${importText}`);\n }\n\n const lastDirective = body.findLast((statement) => 'directive' in statement && !!statement.directive);\n if (lastDirective) return fixer.insertTextAfter(lastDirective, `\\n\\n${importText}`);\n // Comments directly above the first statement, such as JSDoc or `eslint-disable-next-line`, stay attached to it.\n const [first] = body;\n let range = first!.range!;\n let line = first!.loc!.start.line;\n for (const comment of sourceCode.getCommentsBefore(first!).toReversed()) {\n if ((comment.type as string) === 'Shebang' || comment.loc!.end.line + 1 < line) break;\n range = comment.range!;\n line = comment.loc!.start.line;\n }\n\n return fixer.insertTextBeforeRange(range, `${importText}\\n\\n`);\n }\n\n // Another local, date-fns, global or auto-imported `formatDate` may take other arguments, so those files keep the wrapper.\n function isSharedFormatDateAvailable(node: Rule.Node): boolean {\n const definitions = findVariable(sourceCode.getScope(node), 'formatDate')?.defs;\n if (!definitions) return !hasUnresolvedReference('formatDate');\n return definitions.length > 0 && definitions.every((definition) => definition.type === 'ImportBinding'\n && (definition.parent as unknown as { source: { value: unknown } }).source.value === importSources.formatDate);\n }\n\n function withProvided(node: Rule.Node, fixer: Rule.RuleFixer, name: ProvidedName, fix: Rule.Fix) {\n const variable = findVariable(sourceCode.getScope(node), name);\n if (variable) {\n // Configured globals have no definitions.\n const isValue = variable.defs.every((definition) => definition.type !== 'ImportBinding' || (!isTypeImport(definition.node) && !isTypeImport(definition.parent)));\n return isValue ? fix : null;\n }\n\n if (hasUnresolvedReference(name)) return fix;\n // Configs often parse CommonJS files as modules, so the extension decides as well.\n if (sourceCode.ast.sourceType !== 'module' || /\\.c[jt]s$/.test(context.filename)) return null;\n return [\n fix,\n imports[name] ??= createImport(fixer, name),\n ];\n }\n\n function getArgumentTokensWithParens(node: Rule.Node, openParen: AST.Token): [AST.Token, AST.Token] {\n let first = sourceCode.getFirstToken(node)!;\n let last = sourceCode.getLastToken(node)!;\n for (;;) {\n const before = sourceCode.getTokenBefore(first)!;\n const after = sourceCode.getTokenAfter(last)!;\n if (before === openParen || before.value !== '(' || after.value !== ')') break;\n first = before;\n last = after;\n }\n\n return [\n first,\n last,\n ];\n }\n\n function getPlan(node: CallNode): Plan | undefined {\n if (plans.has(node)) return plans.get(node);\n const plan = createPlan(node, dateFnsCalls.get(node)!);\n plans.set(node, plan);\n return plan;\n }\n\n function createPlan(node: CallNode, name: string): Plan | undefined {\n if (node.optional || node.arguments.some((argument) => argument.type === 'SpreadElement')) return;\n const openParen = sourceCode.getTokenAfter(node.callee, (token) => token.value === '(')!;\n const staticMethod = staticMethods.get(name);\n if (staticMethod) {\n // `fromUnixSeconds()` takes no options; `fromUnixTime()` options only pick the returned Date class.\n if (name === 'fromUnixTime' && node.arguments.length > 1) return;\n return {\n edit: {\n provides: 'EnhancedDate',\n range: [\n node.range![0],\n openParen.range[0],\n ],\n text: `EnhancedDate.${staticMethod}`,\n },\n replacement: `EnhancedDate.${staticMethod}()`,\n returnsDate: true,\n };\n }\n\n const [target, ...rest] = node.arguments as Rule.Node[];\n if (!target || !instanceMethods.has(name)) return;\n const inner = target.type === 'CallExpression' && dateFnsCalls.has(target) ? getPlan(target) : undefined;\n const innerEdit = inner?.returnsDate ? inner.edit : undefined;\n const isNewDate = target.type === 'NewExpression'\n && target.callee.type === 'Identifier'\n && (target.callee.name === 'EnhancedDate' || isNativeDate(target.callee as Rule.Node));\n\n const isFresh = !!innerEdit || isNewDate;\n const isExisting = !isFresh && isEnhancedDate(target);\n const isWrapped = !isFresh && !isExisting;\n // date-fns `isValid()` is false for anything but a Date or number, which a wrapper would parse instead.\n if (name === 'isValid' && isWrapped) return;\n if (name === 'format' && isWrapped && isSharedFormatDateAvailable(node)) {\n return {\n edit: {\n provides: 'formatDate',\n range: [\n node.range![0],\n openParen.range[0],\n ],\n text: 'formatDate',\n },\n replacement: 'formatDate()',\n returnsDate: false,\n };\n }\n\n const [firstToken, lastToken] = getArgumentTokensWithParens(target, openParen);\n const targetText = sourceCode.text.slice(firstToken.range[0], lastToken.range[1]);\n const closeParen = sourceCode.getLastToken(node)!;\n const separator = rest.length ? sourceCode.getTokenAfter(lastToken)! : closeParen;\n const hasLostComments = sourceCode.commentsExistBetween(openParen, firstToken) || sourceCode.commentsExistBetween(lastToken, separator);\n // A wrapper copies the date before an awaited argument settles, while date-fns reads it afterwards.\n const awaitsLater = isWrapped && rest.some((argument) => sourceCode.getFirstToken(argument, (token) => token.value === 'await' || token.value === 'yield'));\n const replacement = `${isWrapped ? 'new EnhancedDate(date)' : 'date'}.${name}()`;\n const returnsDate = /^(?:add|endOf|startOf|sub)[A-Z]/.test(name);\n if (hasLostComments || awaitsLater) {\n return {\n replacement,\n returnsDate,\n };\n }\n\n let receiver = `new EnhancedDate(${targetText})`;\n if (innerEdit) {\n receiver = sourceCode.text.slice(firstToken.range[0], target.range![0]) + innerEdit.text + sourceCode.text.slice(innerEdit.range[1], lastToken.range[1]);\n // The outer fix now includes the inner edit. Reporting both would let their import insertions overlap.\n delete inner!.edit;\n } else if (isNewDate) {\n const callee = target.callee as Rule.Node;\n receiver = `new EnhancedDate${sourceCode.text.slice(callee.range![1], target.range![1]) || '()'}`;\n } else if (isExisting) {\n const isParenthesized = firstToken !== sourceCode.getFirstToken(target);\n receiver = unparenthesizedReceiverTypes.has(target.type) || isParenthesized ? targetText : `(${targetText})`;\n }\n\n return {\n edit: {\n provides: innerEdit ? innerEdit.provides : isExisting ? undefined : 'EnhancedDate',\n range: [\n node.range![0],\n rest.length ? sourceCode.getTokenAfter(separator, { includeComments: true })!.range![0] : closeParen.range[1],\n ],\n text: `${receiver}.${name}${rest.length ? '(' : '()'}`,\n },\n replacement,\n returnsDate,\n };\n }\n\n function reportDateFnsCall(node: CallNode, name: string): void {\n const plan = plans.get(node);\n if (!plan) return;\n const { edit } = plan;\n context.report({\n data: {\n name,\n replacement: plan.replacement,\n },\n fix: edit\n ? (fixer) => {\n const fix = fixer.replaceTextRange(edit.range, edit.text);\n return edit.provides ? withProvided(node, fixer, edit.provides, fix) : fix;\n }\n : null,\n messageId: 'dateFns',\n node,\n });\n }\n\n function checkNativeDateReference(identifier: Rule.Node): void {\n const parent = identifier.parent!;\n const isCallee = (parent.type === 'CallExpression' || parent.type === 'NewExpression') && parent.callee === identifier;\n if (isCallee && parent.type === 'CallExpression') {\n context.report({\n messageId: 'dateCall',\n node: parent,\n });\n\n return;\n }\n\n // EnhancedDate inherits the static Date methods, so rewriting those calls would only add an import.\n if (!isCallee) return;\n context.report({\n fix: (fixer) => withProvided(parent, fixer, 'EnhancedDate', fixer.replaceText(identifier, 'EnhancedDate')),\n messageId: 'date',\n node: parent,\n });\n }\n\n function checkNamespaceReference(identifier: Rule.Node): void {\n const parent = identifier.parent!;\n if (\n parent.type !== 'MemberExpression'\n || parent.object !== identifier\n || parent.computed\n || parent.optional\n || parent.property.type !== 'Identifier'\n ) return;\n\n const call = parent.parent;\n if (call.type === 'CallExpression' && call.callee === parent) dateFnsCalls.set(call, getDateFnsName('date-fns', parent.property.name)!);\n }\n\n return {\n 'ImportDeclaration': (node) => {\n const source = node.source.value;\n if (isTypeImport(node) || typeof source !== 'string') return;\n for (const specifier of node.specifiers) {\n if (isTypeImport(specifier)) continue;\n let name: string | undefined;\n if (specifier.type !== 'ImportNamespaceSpecifier') {\n const { imported } = specifier as { imported?: { name?: string; value?: unknown } };\n name = getDateFnsName(source, imported ? imported.name ?? String(imported.value) : 'default');\n if (!name) continue;\n } else if (source !== 'date-fns') continue;\n\n for (const { references } of sourceCode.getDeclaredVariables(specifier)) {\n for (const reference of references) {\n const identifier = reference.identifier as Rule.Node;\n const parent = identifier.parent!;\n if (!name) checkNamespaceReference(identifier);\n else if (parent.type === 'CallExpression' && parent.callee === identifier) dateFnsCalls.set(parent, name);\n }\n }\n }\n },\n 'Program:exit': () => {\n // Outer calls can absorb inner edits regardless of the order of the date-fns imports.\n for (const node of dateFnsCalls.keys()) getPlan(node);\n for (const [node, name] of dateFnsCalls) reportDateFnsCall(node, name);\n const { globalScope } = sourceCode.scopeManager;\n const references = globalScope!.set.get('Date')?.references\n ?? globalScope!.through.filter((reference) => reference.identifier.name === 'Date');\n\n for (const reference of references) {\n // typescript-eslint also resolves `: Date` annotations here; only value references create dates.\n if ((reference as { isValueReference?: boolean }).isValueReference === false) continue;\n checkNativeDateReference(reference.identifier as Rule.Node);\n }\n },\n };\n },\n meta: {\n docs: { description: 'Prefer `EnhancedDate` from `@kikiutils/shared` over native `Date` creation and the date-fns functions it wraps.' },\n fixable: 'code',\n messages: {\n date: 'Use `EnhancedDate` instead of `Date`: it is a drop-in subclass with chainable date-fns methods. Disable this line only where a plain `Date` is required.',\n dateCall: '`Date()` returns a string; use `new EnhancedDate().toString()` instead.',\n dateFns: 'Use `{{ replacement }}` instead of date-fns `{{ name }}()` to keep date handling on `EnhancedDate`.',\n },\n schema: [],\n type: 'suggestion',\n },\n};\n"],"mappings":";;AAwBA,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AC;EACT,MAAM;CACV;AACJ"}
|
|
@@ -26,11 +26,11 @@ const statementPadding = {
|
|
|
26
26
|
if (isImportOrReexport(previous) || isImportOrReexport(next)) continue;
|
|
27
27
|
const previousFirstToken = sourceCode.getFirstToken(previous);
|
|
28
28
|
const lastToken = sourceCode.getLastToken(previous);
|
|
29
|
-
const firstToken = sourceCode.getFirstToken(next);
|
|
30
29
|
const isMultiline = previousFirstToken.loc.start.line !== lastToken.loc.end.line;
|
|
31
30
|
const blockNode = previous.type === "ExportDefaultDeclaration" || previous.type === "ExportNamedDeclaration" ? previous.declaration : previous;
|
|
32
31
|
const hasBlockClosing = lastToken.value === "}" && blockNode && blockTypes.has(blockNode.type);
|
|
33
32
|
if (!isMultiline && !hasBlockClosing) continue;
|
|
33
|
+
const firstToken = sourceCode.getFirstToken(next);
|
|
34
34
|
let previousEnd = lastToken.range[1];
|
|
35
35
|
let previousEndLine = lastToken.loc.end.line;
|
|
36
36
|
let nextStart = firstToken.range[0];
|
|
@@ -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\nconst blockTypes = new Set([\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]);\n\nfunction isImportOrReexport(node: StatementNode): boolean {\n return node.type === 'ImportDeclaration'\n || node.type === 'ExportAllDeclaration'\n || (node.type === 'ExportNamedDeclaration' && !!node.source);\n}\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 (isImportOrReexport(previous) || isImportOrReexport(next)) continue;\n const previousFirstToken = sourceCode.getFirstToken(previous)!;\n const lastToken = sourceCode.getLastToken(previous)!;\n const
|
|
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\nconst blockTypes = new Set([\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]);\n\nfunction isImportOrReexport(node: StatementNode): boolean {\n return node.type === 'ImportDeclaration'\n || node.type === 'ExportAllDeclaration'\n || (node.type === 'ExportNamedDeclaration' && !!node.source);\n}\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 (isImportOrReexport(previous) || isImportOrReexport(next)) continue;\n const previousFirstToken = sourceCode.getFirstToken(previous)!;\n const lastToken = sourceCode.getLastToken(previous)!;\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 && blockTypes.has(blockNode.type);\n\n if (!isMultiline && !hasBlockClosing) continue;\n const firstToken = sourceCode.getFirstToken(next)!;\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,MAAM,6BAAa,IAAI,IAAI;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC;AAED,SAAS,mBAAmB,MAA8B;CACtD,OAAO,KAAK,SAAS,uBAChB,KAAK,SAAS,0BACb,KAAK,SAAS,4BAA4B,CAAC,CAAC,KAAK;AAC3D;AAEA,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,IAAI,mBAAmB,QAAQ,KAAK,mBAAmB,IAAI,GAAG;IAC9D,MAAM,qBAAqB,WAAW,cAAc,QAAQ;IAC5D,MAAM,YAAY,WAA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uF;EAC5G,SAAS;EACT,UAAU,EAAE,WAAW,sDAAsD;EAC7E,QAAQ,CAAC;EACT,MAAM;CACV;AACJ"}
|
|
@@ -6,7 +6,7 @@ type Callee = Extract<Rule.Node, {
|
|
|
6
6
|
type MemberNode = Extract<Callee, {
|
|
7
7
|
type: 'MemberExpression';
|
|
8
8
|
}>;
|
|
9
|
-
export type TokenStore = Pick<SourceCode, 'commentsExistBetween' | 'getLastToken' | 'getTokenAfter' | 'getTokenBefore' | 'getTokensBetween'>;
|
|
9
|
+
export type TokenStore = Pick<SourceCode, 'commentsExistBetween' | 'getFirstTokenBetween' | 'getLastToken' | 'getTokenAfter' | 'getTokenBefore' | 'getTokensBetween'>;
|
|
10
10
|
export interface ParserServices {
|
|
11
11
|
esTreeNodeToTSNodeMap: {
|
|
12
12
|
get: (node: unknown) => Node;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/_internals/rules/utils.ts"],"sourcesContent":["import type {\n Rule,\n SourceCode,\n} from 'eslint';\nimport type {\n Node,\n TypeChecker,\n} from 'typescript';\n\ntype Callee = Extract<Rule.Node, { type: 'CallExpression' }>['callee'];\ntype MemberNode = Extract<Callee, { type: 'MemberExpression' }>;\n\nexport type TokenStore = Pick<\n SourceCode,\n 'commentsExistBetween' | 'getLastToken' | 'getTokenAfter' | 'getTokenBefore' | 'getTokensBetween'\n>;\n\nexport interface ParserServices {\n esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };\n program: { getTypeChecker: () => TypeChecker };\n}\n\nexport const composablePattern = /^use[A-Z]/;\n\ninterface TemplateParserServices {\n defineTemplateBodyVisitor?: (\n templateVisitor: Rule.RuleListener,\n scriptVisitor: Rule.RuleListener,\n ) => Rule.RuleListener;\n\n getTemplateBodyTokenStore?: () => TokenStore;\n}\n\nexport function defineScriptAndTemplateVisitors(\n sourceCode: SourceCode,\n createVisitor: (tokenStore: TokenStore, isTemplate: boolean) => Rule.RuleListener,\n): Rule.RuleListener {\n const scriptVisitor = createVisitor(sourceCode, false);\n const parserServices = sourceCode.parserServices as TemplateParserServices;\n if (!parserServices.defineTemplateBodyVisitor || !parserServices.getTemplateBodyTokenStore) return scriptVisitor;\n\n return parserServices.defineTemplateBodyVisitor(\n createVisitor(parserServices.getTemplateBodyTokenStore(), true),\n scriptVisitor,\n );\n}\n\nexport function insertNewlines(offsets: readonly number[]): Rule.ReportFixer {\n return (fixer) => offsets.map((offset) => fixer.insertTextBeforeRange(\n [\n offset,\n offset,\n ],\n '\\n',\n ));\n}\n\nexport function isMemberNamed(node: Callee, name: string): node is MemberNode {\n return node.type === 'MemberExpression'\n && !node.computed\n && node.property.type === 'Identifier'\n && node.property.name === name;\n}\n"],"mappings":";AAsBA,MAAa,oBAAoB;AAWjC,SAAgB,gCACZ,YACA,eACiB;CACjB,MAAM,gBAAgB,cAAc,YAAY,KAAK;CACrD,MAAM,iBAAiB,WAAW;CAClC,IAAI,CAAC,eAAe,6BAA6B,CAAC,eAAe,2BAA2B,OAAO;CAEnG,OAAO,eAAe,0BAClB,cAAc,eAAe,0BAA0B,GAAG,IAAI,GAC9D,aACJ;AACJ;AAEA,SAAgB,eAAe,SAA8C;CACzE,QAAQ,UAAU,QAAQ,KAAK,WAAW,MAAM,sBAC5C,CACI,QACA,MACJ,GACA,IACJ,CAAC;AACL;AAEA,SAAgB,cAAc,MAAc,MAAkC;CAC1E,OAAO,KAAK,SAAS,sBAChB,CAAC,KAAK,YACN,KAAK,SAAS,SAAS,gBACvB,KAAK,SAAS,SAAS;AAChC"}
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/_internals/rules/utils.ts"],"sourcesContent":["import type {\n Rule,\n SourceCode,\n} from 'eslint';\nimport type {\n Node,\n TypeChecker,\n} from 'typescript';\n\ntype Callee = Extract<Rule.Node, { type: 'CallExpression' }>['callee'];\ntype MemberNode = Extract<Callee, { type: 'MemberExpression' }>;\n\nexport type TokenStore = Pick<\n SourceCode,\n 'commentsExistBetween' | 'getFirstTokenBetween' | 'getLastToken' | 'getTokenAfter' | 'getTokenBefore' | 'getTokensBetween'\n>;\n\nexport interface ParserServices {\n esTreeNodeToTSNodeMap: { get: (node: unknown) => Node };\n program: { getTypeChecker: () => TypeChecker };\n}\n\nexport const composablePattern = /^use[A-Z]/;\n\ninterface TemplateParserServices {\n defineTemplateBodyVisitor?: (\n templateVisitor: Rule.RuleListener,\n scriptVisitor: Rule.RuleListener,\n ) => Rule.RuleListener;\n\n getTemplateBodyTokenStore?: () => TokenStore;\n}\n\nexport function defineScriptAndTemplateVisitors(\n sourceCode: SourceCode,\n createVisitor: (tokenStore: TokenStore, isTemplate: boolean) => Rule.RuleListener,\n): Rule.RuleListener {\n const scriptVisitor = createVisitor(sourceCode, false);\n const parserServices = sourceCode.parserServices as TemplateParserServices;\n if (!parserServices.defineTemplateBodyVisitor || !parserServices.getTemplateBodyTokenStore) return scriptVisitor;\n\n return parserServices.defineTemplateBodyVisitor(\n createVisitor(parserServices.getTemplateBodyTokenStore(), true),\n scriptVisitor,\n );\n}\n\nexport function insertNewlines(offsets: readonly number[]): Rule.ReportFixer {\n return (fixer) => offsets.map((offset) => fixer.insertTextBeforeRange(\n [\n offset,\n offset,\n ],\n '\\n',\n ));\n}\n\nexport function isMemberNamed(node: Callee, name: string): node is MemberNode {\n return node.type === 'MemberExpression'\n && !node.computed\n && node.property.type === 'Identifier'\n && node.property.name === name;\n}\n"],"mappings":";AAsBA,MAAa,oBAAoB;AAWjC,SAAgB,gCACZ,YACA,eACiB;CACjB,MAAM,gBAAgB,cAAc,YAAY,KAAK;CACrD,MAAM,iBAAiB,WAAW;CAClC,IAAI,CAAC,eAAe,6BAA6B,CAAC,eAAe,2BAA2B,OAAO;CAEnG,OAAO,eAAe,0BAClB,cAAc,eAAe,0BAA0B,GAAG,IAAI,GAC9D,aACJ;AACJ;AAEA,SAAgB,eAAe,SAA8C;CACzE,QAAQ,UAAU,QAAQ,KAAK,WAAW,MAAM,sBAC5C,CACI,QACA,MACJ,GACA,IACJ,CAAC;AACL;AAEA,SAAgB,cAAc,MAAc,MAAkC;CAC1E,OAAO,KAAK,SAAS,sBAChB,CAAC,KAAK,YACN,KAAK,SAAS,SAAS,gBACvB,KAAK,SAAS,SAAS;AAChC"}
|
package/dist/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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';\nimport promise from 'eslint-plugin-promise';\n\nimport { createBaseRules } from './_internals/configs/base-rules';\nimport { jsdocSettings } from './_internals/configs/jsdoc';\nimport { createTypeAwareConfig } from './_internals/configs/type-aware';\nimport { typescriptConfig } from './_internals/configs/typescript';\nimport { kikiutilsPlugin } from './_internals/rules';\n\nexport { createBaseRules };\n\nconst vscodeOrderSensitiveArrayProperties = [\n 'args',\n 'autoAttachSmartPattern',\n 'dependsOn',\n 'options',\n 'outFiles',\n 'problemMatcher',\n 'resolveSourceMapLocations',\n 'runtimeArgs',\n 'skipFiles',\n].join('|');\n\nconst testSleepMessage = 'A fixed wait makes tests slow and flaky. Use fake timers for timer-driven code, or wait for the event or condition itself, such as with `vi.waitFor()`. To assert that something has not happened yet, await one event loop turn with `setImmediate` from `node:timers/promises`.';\n\nexport function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {\n return [\n {\n name: 'kikiutils/base',\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 {\n name: 'kikiutils/javascript',\n files: [\n GLOB_JS,\n GLOB_JSX,\n GLOB_TS,\n GLOB_TSX,\n ],\n plugins: {\n kikiutils: kikiutilsPlugin,\n promise,\n },\n rules: {\n ...createBaseRules(environment),\n 'node/prefer-global/process': [\n 'error',\n 'always',\n ],\n },\n settings: jsdocSettings,\n },\n {\n ...typescriptConfig,\n name: 'kikiutils/typescript',\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n },\n {\n ...createTypeAwareConfig(),\n name: 'kikiutils/type-aware',\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n ignores: ['**/*.config.?([cm])ts'],\n },\n {\n name: 'kikiutils/tests',\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 'node:timers/promises',\n 'timers/promises',\n ].map((name) => ({\n importNames: ['setTimeout'],\n message: testSleepMessage,\n name,\n })),\n ],\n },\n ],\n 'kikiutils/no-restricted-test-syntax': [\n 'error',\n {\n message: testSleepMessage,\n selector: [\n 'NewExpression[callee.name=\"Promise\"] > :function > CallExpression.body[callee.name=\"setTimeout\"]',\n 'NewExpression[callee.name=\"Promise\"] > :function > BlockStatement > ExpressionStatement > CallExpression[callee.name=\"setTimeout\"]',\n 'CallExpression[callee.object.name=\"Bun\"][callee.property.name=/^sleep(Sync)?$/]',\n ].join(', '),\n },\n
|
|
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';\nimport promise from 'eslint-plugin-promise';\n\nimport { createBaseRules } from './_internals/configs/base-rules';\nimport { jsdocSettings } from './_internals/configs/jsdoc';\nimport { createTypeAwareConfig } from './_internals/configs/type-aware';\nimport { typescriptConfig } from './_internals/configs/typescript';\nimport { kikiutilsPlugin } from './_internals/rules';\n\nexport { createBaseRules };\n\nconst vscodeOrderSensitiveArrayProperties = [\n 'args',\n 'autoAttachSmartPattern',\n 'dependsOn',\n 'options',\n 'outFiles',\n 'problemMatcher',\n 'resolveSourceMapLocations',\n 'runtimeArgs',\n 'skipFiles',\n].join('|');\n\nconst testSleepMessage = 'A fixed wait makes tests slow and flaky. Use fake timers for timer-driven code, or wait for the event or condition itself, such as with `vi.waitFor()`. To assert that something has not happened yet, await one event loop turn with `setImmediate` from `node:timers/promises`.';\n\nexport function createBaseConfigs(environment: 'bun' | 'node' = 'node'): TypedFlatConfigItem[] {\n return [\n {\n name: 'kikiutils/base',\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 {\n name: 'kikiutils/javascript',\n files: [\n GLOB_JS,\n GLOB_JSX,\n GLOB_TS,\n GLOB_TSX,\n ],\n plugins: {\n kikiutils: kikiutilsPlugin,\n promise,\n },\n rules: {\n ...createBaseRules(environment),\n 'node/prefer-global/process': [\n 'error',\n 'always',\n ],\n },\n settings: jsdocSettings,\n },\n {\n ...typescriptConfig,\n name: 'kikiutils/typescript',\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n },\n {\n ...createTypeAwareConfig(),\n name: 'kikiutils/type-aware',\n files: [\n GLOB_TS,\n GLOB_TSX,\n ],\n ignores: ['**/*.config.?([cm])ts'],\n },\n {\n name: 'kikiutils/tests',\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 'node:timers/promises',\n 'timers/promises',\n ].map((name) => ({\n importNames: ['setTimeout'],\n message: testSleepMessage,\n name,\n })),\n ],\n },\n ],\n 'kikiutils/no-restricted-test-syntax': [\n 'error',\n {\n message: testSleepMessage,\n selector: [\n 'NewExpression[callee.name=\"Promise\"] > :function > CallExpression.body[callee.name=\"setTimeout\"]',\n 'NewExpression[callee.name=\"Promise\"] > :function > BlockStatement > ExpressionStatement > CallExpression[callee.name=\"setTimeout\"]',\n 'CallExpression[callee.object.name=\"Bun\"][callee.property.name=/^sleep(Sync)?$/]',\n ].join(', '),\n },\n {\n message: 'An empty `vi.fn()` is typed `(...args: any[]) => any`; pass a type parameter or an implementation.',\n selector: 'CallExpression[callee.object.name=\"vi\"][callee.property.name=\"fn\"][arguments.length=0]:not([typeArguments])',\n },\n ],\n 'test/consistent-each-for': [\n 'error',\n {\n it: 'for',\n test: 'for',\n },\n ],\n // Type tests assert with `expectTypeOf()`, and shared checks are `expect*` helpers.\n 'test/expect-expect': [\n 'error',\n {\n assertFunctionNames: [\n 'assert*',\n 'expect*',\n ],\n },\n ],\n 'test/no-commented-out-tests': 'error',\n 'test/no-conditional-expect': 'error',\n 'test/no-disabled-tests': 'error',\n 'test/no-standalone-expect': 'error',\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/prefer-vi-mocked': 'error',\n 'test/require-to-throw-message': 'error',\n 'test/valid-describe-callback': 'error',\n 'test/valid-expect': 'error',\n 'test/valid-expect-in-promise': 'error',\n 'test/valid-title': 'error',\n // Mocks and partial fixtures often need `any`.\n 'ts/no-explicit-any': 'off',\n },\n },\n {\n name: 'kikiutils/vscode',\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 {\n name: 'kikiutils/ignores/markdown-code-blocks',\n ignores: ['**/*.md/**'],\n },\n // Serena's project files (`project.yml`, memories) are tool-generated and may be tracked.\n {\n name: 'kikiutils/ignores/serena',\n ignores: ['**/.serena/**'],\n },\n ];\n}\n"],"mappings":";;;;;;;;AAkBA,MAAM,sCAAsC;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ,CAAC,CAAC,KAAK,GAAG;AAEV,MAAM,mBAAmB;AAEzB,SAAgB,kBAAkB,cAA8B,QAA+B;CAC3F,OAAO;EACH;GACI,MAAM;GACN,OAAO;IACH,yBAAyB,CACrB,SACA,EAAE,SAAS,CAAC,OAAO,EAAE,CACzB;IACA,4BAA4B;IAC5B,yBAAyB,CACrB,SACA,MACJ;GACJ;EACJ;EACA;GACI,MAAM;GACN,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;EACA;GACI,GAAG;GACH,MAAM;GACN,OAAO,CACH,SACA,QACJ;EACJ;EACA;GACI,GAAG,sBAAsB;GACzB,MAAM;GACN,OAAO,CACH,SACA,QACJ;GACA,SAAS,CAAC,uBAAuB;EACrC;EACA;GACI,MAAM;GACN,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,GACA,GAAG,CACC,wBACA,iBACJ,CAAC,CAAC,KAAK,UAAU;KACb,aAAa,CAAC,YAAY;KAC1B,SAAS;KACT;IACJ,EAAE,CACN,EACJ,CACJ;IACA,uCAAuC;KACnC;KACA;MACI,SAAS;MACT,UAAU;OACN;OACA;OACA;MACJ,CAAC,CAAC,KAAK,IAAI;KACf;KACA;MACI,SAAS;MACT,UAAU;KACd;IACJ;IACA,4BAA4B,CACxB,SACA;KACI,IAAI;KACJ,MAAM;IACV,CACJ;IAEA,sBAAsB,CAClB,SACA,EACI,qBAAqB,CACjB,WACA,SACJ,EACJ,CACJ;IACA,+BAA+B;IAC/B,8BAA8B;IAC9B,0BAA0B;IAC1B,6BAA6B;IAC7B,oBAAoB;IACpB,4BAA4B;IAC5B,+BAA+B,CAC3B,SACA;KACI,wBAAwB;KACxB,6BAA6B;IACjC,CACJ;IACA,qBAAqB;IACrB,yBAAyB;IACzB,iCAAiC;IACjC,gCAAgC;IAChC,qBAAqB;IACrB,gCAAgC;IAChC,oBAAoB;IAEpB,sBAAsB;GAC1B;EACJ;EACA;GACI,MAAM;GACN,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;EACA;GACI,MAAM;GACN,SAAS,CAAC,YAAY;EAC1B;EAEA;GACI,MAAM;GACN,SAAS,CAAC,eAAe;EAC7B;CACJ;AACJ"}
|
package/dist/nuxt.js
CHANGED
|
@@ -111,10 +111,7 @@ function createNuxtConfigs({ ssr = !isSsrDisabled() } = {}) {
|
|
|
111
111
|
function hasSeoUtils() {
|
|
112
112
|
try {
|
|
113
113
|
const { dependencies, devDependencies } = JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf8"));
|
|
114
|
-
return ["@nuxtjs/seo", "nuxt-seo-utils"].some((name) => name
|
|
115
|
-
...dependencies,
|
|
116
|
-
...devDependencies
|
|
117
|
-
});
|
|
114
|
+
return ["@nuxtjs/seo", "nuxt-seo-utils"].some((name) => dependencies?.[name] !== void 0 || devDependencies?.[name] !== void 0);
|
|
118
115
|
} catch {
|
|
119
116
|
return false;
|
|
120
117
|
}
|
package/dist/nuxt.js.map
CHANGED
|
@@ -1 +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';\nimport type { PackageJson } from 'type-fest';\nimport ts from 'typescript';\n\nimport { kikiutilsPlugin } from './_internals/rules';\n\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({ ssr = !isSsrDisabled() }: { ssr?: boolean } = {}): 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 const ssrConfigs: TypedFlatConfigItem[] = ssr\n ? [\n {\n name: 'kikiutils/nuxt/app',\n files: ['**/app/**/*.?([cm])[jt]s'],\n ignores: [\n ...GLOB_TESTS,\n // Nuxt registers `.client` plugins only in the browser; other `.client` modules still load wherever they are imported.\n '**/plugins/**/*.client.?([cm])[jt]s',\n ],\n rules: {\n 'kikiutils/no-restricted-nuxt-app-syntax': [\n 'error',\n {\n message: 'Module-level state in `app/` is shared by every SSR request and leaks between users. Use `useState()` for state the server writes or the client reuses after hydration, or create it inside a composable.',\n selector: [\n 'CallExpression.init',\n ':matches(TSAsExpression, TSSatisfiesExpression) > CallExpression.expression',\n ].map((target) => `:matches(Program, Program > ExportNamedDeclaration) > VariableDeclaration > VariableDeclarator > ${target}[callee.name=/^(computed|reactive|ref|shallowReactive|shallowRef)$/]`).join(', '),\n },\n ],\n },\n },\n ]\n : [];\n\n return [\n {\n name: 'kikiutils/nuxt',\n files: [\n GLOB_SRC,\n GLOB_VUE,\n ],\n plugins: { kikiutils: kikiutilsPlugin },\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 name: 'kikiutils/nuxt/components',\n files: [\n GLOB_VUE,\n '**/composables/**/*.?([cm])[jt]s',\n ],\n ignores: GLOB_TESTS,\n rules: {\n 'kikiutils/no-restricted-nuxt-component-syntax': [\n 'error',\n {\n message: 'Use `useEventListener()` from VueUse; it removes the listener when the component or effect scope is disposed and re-binds when a target ref changes.',\n selector: 'CallExpression[callee.property.name=\"addEventListener\"]',\n },\n ],\n },\n },\n {\n name: 'kikiutils/nuxt/composables',\n files: ['**/composables/**/*.?([cm])[jt]s'],\n ignores: GLOB_TESTS,\n rules: { 'kikiutils/no-reactive-composable-return': 'error' },\n },\n ...ssrConfigs,\n {\n name: 'kikiutils/nuxt/pages',\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 name: 'kikiutils/nuxt/server-routes',\n files: ['**/server/{api,routes}/**/*.?([cm])[jt]s'],\n ignores: GLOB_TESTS,\n rules: { 'kikiutils/nitro-route-method-suffix': 'error' },\n },\n {\n name: 'kikiutils/nuxt/server',\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')) as PackageJson;\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\n// Loading the Nuxt config would run its imports, so only a literal `ssr: false` on the exported config object counts.\nfunction isSsrDisabled(): boolean {\n for (const extension of [\n 'js',\n 'mjs',\n 'mts',\n 'ts',\n ]) {\n const path = join(process.cwd(), `nuxt.config.${extension}`);\n let text: string;\n try {\n text = readFileSync(path, 'utf8');\n } catch {\n continue;\n }\n\n const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest);\n const exported = source.statements.find((statement) => ts.isExportAssignment(statement))?.expression;\n const config = exported && ts.isCallExpression(exported) ? exported.arguments[0] : exported;\n return !!config\n && ts.isObjectLiteralExpression(config)\n && config.properties.some((property) => ts.isPropertyAssignment(property)\n && ts.isIdentifier(property.name)\n && property.name.text === 'ssr'\n && property.initializer.kind === ts.SyntaxKind.FalseKeyword);\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAcA,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,kBAAkB,EAAE,MAAM,CAAC,cAAc,MAAyB,CAAC,GAA0B;CACzG,MAAM,uBAAuB,CACzB;EACI,SAAS;EACT,UAAU;CACd,GACA,GAAG,YAAY,IACT,CACE;EACI,SAAS;EACT,UAAU;CACd,CACJ,IACE,CAAC,CACX;CAEA,MAAM,aAAoC,MACpC,CACE;EACI,MAAM;EACN,OAAO,CAAC,0BAA0B;EAClC,SAAS,CACL,GAAG,YAEH,qCACJ;EACA,OAAO,EACH,2CAA2C,CACvC,SACA;GACI,SAAS;GACT,UAAU,CACN,uBACA,6EACJ,CAAC,CAAC,KAAK,WAAW,oGAAoG,OAAO,qEAAqE,CAAC,CAAC,KAAK,IAAI;EACjN,CACJ,EACJ;CACJ,CACJ,IACE,CAAC;CAEP,OAAO;EACH;GACI,MAAM;GACN,OAAO,CACH,UACA,QACJ;GACA,SAAS,EAAE,WAAW,gBAAgB;GACtC,OAAO;IACH,0CAA0C;IAC1C,uCAAuC,CACnC,SACA,GAAG,oBACP;GACJ;EACJ;EACA;GACI,MAAM;GACN,OAAO,CACH,UACA,kCACJ;GACA,SAAS;GACT,OAAO,EACH,iDAAiD,CAC7C,SACA;IACI,SAAS;IACT,UAAU;GACd,C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C,CAAC,UACJ,GAAG,0BAA0B,MAAM,KACnC,OAAO,WAAW,MAAM,aAAa,GAAG,qBAAqB,QAAQ,KACnE,GAAG,aAAa,SAAS,IAAI,KAC7B,SAAS,KAAK,SAAS,SACvB,SAAS,YAAY,SAAS,GAAG,WAAW,YAAY;CACnE;CAEA,OAAO;AACX"}
|
|
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';\nimport type { PackageJson } from 'type-fest';\nimport ts from 'typescript';\n\nimport { kikiutilsPlugin } from './_internals/rules';\n\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({ ssr = !isSsrDisabled() }: { ssr?: boolean } = {}): 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 const ssrConfigs: TypedFlatConfigItem[] = ssr\n ? [\n {\n name: 'kikiutils/nuxt/app',\n files: ['**/app/**/*.?([cm])[jt]s'],\n ignores: [\n ...GLOB_TESTS,\n // Nuxt registers `.client` plugins only in the browser; other `.client` modules still load wherever they are imported.\n '**/plugins/**/*.client.?([cm])[jt]s',\n ],\n rules: {\n 'kikiutils/no-restricted-nuxt-app-syntax': [\n 'error',\n {\n message: 'Module-level state in `app/` is shared by every SSR request and leaks between users. Use `useState()` for state the server writes or the client reuses after hydration, or create it inside a composable.',\n selector: [\n 'CallExpression.init',\n ':matches(TSAsExpression, TSSatisfiesExpression) > CallExpression.expression',\n ].map((target) => `:matches(Program, Program > ExportNamedDeclaration) > VariableDeclaration > VariableDeclarator > ${target}[callee.name=/^(computed|reactive|ref|shallowReactive|shallowRef)$/]`).join(', '),\n },\n ],\n },\n },\n ]\n : [];\n\n return [\n {\n name: 'kikiutils/nuxt',\n files: [\n GLOB_SRC,\n GLOB_VUE,\n ],\n plugins: { kikiutils: kikiutilsPlugin },\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 name: 'kikiutils/nuxt/components',\n files: [\n GLOB_VUE,\n '**/composables/**/*.?([cm])[jt]s',\n ],\n ignores: GLOB_TESTS,\n rules: {\n 'kikiutils/no-restricted-nuxt-component-syntax': [\n 'error',\n {\n message: 'Use `useEventListener()` from VueUse; it removes the listener when the component or effect scope is disposed and re-binds when a target ref changes.',\n selector: 'CallExpression[callee.property.name=\"addEventListener\"]',\n },\n ],\n },\n },\n {\n name: 'kikiutils/nuxt/composables',\n files: ['**/composables/**/*.?([cm])[jt]s'],\n ignores: GLOB_TESTS,\n rules: { 'kikiutils/no-reactive-composable-return': 'error' },\n },\n ...ssrConfigs,\n {\n name: 'kikiutils/nuxt/pages',\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 name: 'kikiutils/nuxt/server-routes',\n files: ['**/server/{api,routes}/**/*.?([cm])[jt]s'],\n ignores: GLOB_TESTS,\n rules: { 'kikiutils/nitro-route-method-suffix': 'error' },\n },\n {\n name: 'kikiutils/nuxt/server',\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')) as PackageJson;\n return [\n '@nuxtjs/seo',\n 'nuxt-seo-utils',\n ].some((name) => dependencies?.[name] !== undefined || devDependencies?.[name] !== undefined);\n } catch {\n return false;\n }\n}\n\n// Importing the project's Nuxt config would execute application code during ESLint startup.\nfunction isSsrDisabled(): boolean {\n for (const extension of [\n 'js',\n 'mjs',\n 'mts',\n 'ts',\n ]) {\n const path = join(process.cwd(), `nuxt.config.${extension}`);\n let text: string;\n try {\n text = readFileSync(path, 'utf8');\n } catch {\n continue;\n }\n\n const source = ts.createSourceFile(path, text, ts.ScriptTarget.Latest);\n const exported = source.statements.find((statement) => ts.isExportAssignment(statement))?.expression;\n const config = exported && ts.isCallExpression(exported) ? exported.arguments[0] : exported;\n return !!config\n && ts.isObjectLiteralExpression(config)\n && config.properties.some((property) => ts.isPropertyAssignment(property)\n && ts.isIdentifier(property.name)\n && property.name.text === 'ssr'\n && property.initializer.kind === ts.SyntaxKind.FalseKeyword);\n }\n\n return false;\n}\n"],"mappings":";;;;;;AAcA,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,kBAAkB,EAAE,MAAM,CAAC,cAAc,MAAyB,CAAC,GAA0B;CACzG,MAAM,uBAAuB,CACzB;EACI,SAAS;EACT,UAAU;CACd,GACA,GAAG,YAAY,IACT,CACE;EACI,SAAS;EACT,UAAU;CACd,CACJ,IACE,CAAC,CACX;CAEA,MAAM,aAAoC,MACpC,CACE;EACI,MAAM;EACN,OAAO,CAAC,0BAA0B;EAClC,SAAS,CACL,GAAG,YAEH,qCACJ;EACA,OAAO,EACH,2CAA2C,CACvC,SACA;GACI,SAAS;GACT,UAAU,CACN,uBACA,6EACJ,CAAC,CAAC,KAAK,WAAW,oGAAoG,OAAO,qEAAqE,CAAC,CAAC,KAAK,IAAI;EACjN,CACJ,EACJ;CACJ,CACJ,IACE,CAAC;CAEP,OAAO;EACH;GACI,MAAM;GACN,OAAO,CACH,UACA,QACJ;GACA,SAAS,EAAE,WAAW,gBAAgB;GACtC,OAAO;IACH,0CAA0C;IAC1C,uCAAuC,CACnC,SACA,GAAG,oBACP;GACJ;EACJ;EACA;GACI,MAAM;GACN,OAAO,CACH,UACA,kCACJ;GACA,SAAS;GACT,OAAO,EACH,iDA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BAAiB,QAAQ,IAAI,SAAS,UAAU,KAAK;EACnF,OAAO,CAAC,CAAC,UACJ,GAAG,0BAA0B,MAAM,KACnC,OAAO,WAAW,MAAM,aAAa,GAAG,qBAAqB,QAAQ,KACnE,GAAG,aAAa,SAAS,IAAI,KAC7B,SAAS,KAAK,SAAS,SACvB,SAAS,YAAY,SAAS,GAAG,WAAW,YAAY;CACnE;CAEA,OAAO;AACX"}
|
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":";wBAesB,gBAAgB,+BAAuC,QAAQ"}
|
package/dist/vue.js
CHANGED
|
@@ -2,7 +2,6 @@ import { jsdoc, node, unicorn } from "@antfu/eslint-config";
|
|
|
2
2
|
import kikiutilsEslintPluginVue from "@kikiutils/eslint-plugin-vue";
|
|
3
3
|
import betterTailwindcss from "eslint-plugin-better-tailwindcss";
|
|
4
4
|
import promise from "eslint-plugin-promise";
|
|
5
|
-
import { objectEntries } from "ts-extras";
|
|
6
5
|
import { createBaseRules } from "./_internals/configs/base-rules.js";
|
|
7
6
|
import { createTypeAwareConfig } from "./_internals/configs/type-aware.js";
|
|
8
7
|
import { typescriptConfig } from "./_internals/configs/typescript.js";
|
|
@@ -14,6 +13,8 @@ async function createVueConfig(environment = "node") {
|
|
|
14
13
|
node(),
|
|
15
14
|
unicorn()
|
|
16
15
|
]);
|
|
16
|
+
const scriptRules = {};
|
|
17
|
+
for (const config of scriptConfigs.flat()) Object.assign(scriptRules, config.rules);
|
|
17
18
|
const typeAwareConfig = createTypeAwareConfig();
|
|
18
19
|
return {
|
|
19
20
|
name: "kikiutils/vue",
|
|
@@ -27,7 +28,7 @@ async function createVueConfig(environment = "node") {
|
|
|
27
28
|
promise
|
|
28
29
|
},
|
|
29
30
|
rules: {
|
|
30
|
-
...
|
|
31
|
+
...scriptRules,
|
|
31
32
|
...createBaseRules(environment),
|
|
32
33
|
...typescriptConfig.rules,
|
|
33
34
|
...typeAwareConfig.rules,
|
|
@@ -45,6 +46,11 @@ async function createVueConfig(environment = "node") {
|
|
|
45
46
|
"better-tailwindcss/no-duplicate-classes": "error",
|
|
46
47
|
"better-tailwindcss/no-unnecessary-whitespace": "error",
|
|
47
48
|
"node/prefer-global/process": "off",
|
|
49
|
+
"ts/no-unsafe-argument": "off",
|
|
50
|
+
"ts/no-unsafe-assignment": "off",
|
|
51
|
+
"ts/no-unsafe-call": "off",
|
|
52
|
+
"ts/no-unsafe-member-access": "off",
|
|
53
|
+
"ts/no-unsafe-return": "off",
|
|
48
54
|
"vue/attribute-hyphenation": "error",
|
|
49
55
|
"vue/attributes-order": "off",
|
|
50
56
|
"vue/block-order": ["error", { order: [
|
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 {\n jsdoc,\n node,\n unicorn,\n} from '@antfu/eslint-config';\nimport kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss';\nimport promise from 'eslint-plugin-promise';\
|
|
1
|
+
{"version":3,"file":"vue.js","names":[],"sources":["../src/vue.ts"],"sourcesContent":["import type { TypedFlatConfigItem } from '@antfu/eslint-config';\nimport {\n jsdoc,\n node,\n unicorn,\n} from '@antfu/eslint-config';\nimport kikiutilsEslintPluginVue from '@kikiutils/eslint-plugin-vue';\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss';\nimport promise from 'eslint-plugin-promise';\n\nimport { createBaseRules } from './_internals/configs/base-rules';\nimport { createTypeAwareConfig } from './_internals/configs/type-aware';\nimport { typescriptConfig } from './_internals/configs/typescript';\nimport { kikiutilsPlugin } from './_internals/rules';\n\nexport async function createVueConfig(environment: 'bun' | 'node' = 'node'): Promise<TypedFlatConfigItem> {\n // antfu scopes these rule sets to JS and TS files; `<script>` blocks need them too.\n const scriptConfigs = await Promise.all([\n jsdoc(),\n node(),\n unicorn(),\n ]);\n\n const scriptRules: NonNullable<TypedFlatConfigItem['rules']> = {};\n for (const config of scriptConfigs.flat()) Object.assign(scriptRules, config.rules);\n const typeAwareConfig = createTypeAwareConfig();\n return {\n name: 'kikiutils/vue',\n files: ['**/*.vue'],\n languageOptions: typeAwareConfig.languageOptions,\n plugins: {\n ...typeAwareConfig.plugins,\n '@kikiutils/vue': kikiutilsEslintPluginVue,\n 'better-tailwindcss': betterTailwindcss,\n 'kikiutils': kikiutilsPlugin,\n promise,\n },\n rules: {\n ...scriptRules,\n ...createBaseRules(environment),\n ...typescriptConfig.rules,\n ...typeAwareConfig.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 // Keeps antfu's Vue setting, which the spread node rules above would re-enable.\n 'node/prefer-global/process': 'off',\n // vue-tsc resolves template refs and .vue imports that typescript-eslint sees as unsafe.\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-member-access': 'off',\n 'ts/no-unsafe-return': 'off',\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/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: typescriptConfig.settings,\n };\n}\n"],"mappings":";;;;;;;;;AAeA,eAAsB,gBAAgB,cAA8B,QAAsC;CAEtG,MAAM,gBAAgB,MAAM,QAAQ,IAAI;EACpC,MAAM;EACN,KAAK;EACL,QAAQ;CACZ,CAAC;CAED,MAAM,cAAyD,CAAC;CAChE,KAAK,MAAM,UAAU,cAAc,KAAK,GAAG,OAAO,OAAO,aAAa,OAAO,KAAK;CAClF,MAAM,kBAAkB,sBAAsB;CAC9C,OAAO;EACH,MAAM;EACN,OAAO,CAAC,UAAU;EAClB,iBAAiB,gBAAgB;EACjC,SAAS;GACL,GAAG,gBAAgB;GACnB,kBAAkB;GAClB,sBAAsB;GACtB,aAAa;GACb;EACJ;EACA,OAAO;GACH,GAAG;GACH,GAAG,gBAAgB,WAAW;GAC9B,GAAG,iBAAiB;GACpB,GAAG,gBAAgB;GACnB,mCAAmC,CAC/B,SACA;IACI,cAAc;IACd,s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