@saasmakers/eslint 1.0.23 → 1.0.25
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/eslint.config.cjs +1 -1
- package/dist/eslint.config.d.cts +1 -1
- package/dist/eslint.config.d.mts +1 -1
- package/dist/eslint.config.d.ts +1 -1
- package/dist/eslint.config.mjs +1 -1
- package/dist/index.cjs +25 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +25 -12
- package/package.json +1 -1
package/dist/eslint.config.cjs
CHANGED
|
@@ -10764,7 +10764,7 @@ const eslint_config = antfu__default(
|
|
|
10764
10764
|
test: false,
|
|
10765
10765
|
typescript: true,
|
|
10766
10766
|
unocss: true,
|
|
10767
|
-
vue:
|
|
10767
|
+
vue: true
|
|
10768
10768
|
},
|
|
10769
10769
|
// Antfu changes (keep them minimal)
|
|
10770
10770
|
{
|
package/dist/eslint.config.d.cts
CHANGED
package/dist/eslint.config.d.mts
CHANGED
package/dist/eslint.config.d.ts
CHANGED
package/dist/eslint.config.mjs
CHANGED
|
@@ -10738,7 +10738,7 @@ const eslint_config = antfu(
|
|
|
10738
10738
|
test: false,
|
|
10739
10739
|
typescript: true,
|
|
10740
10740
|
unocss: true,
|
|
10741
|
-
vue:
|
|
10741
|
+
vue: true
|
|
10742
10742
|
},
|
|
10743
10743
|
// Antfu changes (keep them minimal)
|
|
10744
10744
|
{
|
package/dist/index.cjs
CHANGED
|
@@ -809,8 +809,8 @@ const templateTagLength = "<template>".length;
|
|
|
809
809
|
const propsPrefixRegex = /\$?props\.(\w+)/g;
|
|
810
810
|
const trueAttributeRegex = /(?<![\w-]):?(?!aria-)([a-z0-9-]+)="true"/gi;
|
|
811
811
|
const eventHandlerRegex = /(?:@|v-on:)[^\s="'<>/]+\s*=\s*"([^"]*)"/g;
|
|
812
|
-
const bareIdentifierRegex = /^[
|
|
813
|
-
const singleCallRegex = /^([
|
|
812
|
+
const bareIdentifierRegex = /^[a-z_$][\w$]*$/i;
|
|
813
|
+
const singleCallRegex = /^([a-z_$][\w$]*)\s*\(.*\)$/is;
|
|
814
814
|
const onPrefixRegex = /^on[A-Z]/;
|
|
815
815
|
const exemptCallees = /* @__PURE__ */ new Set(["$emit", "emit"]);
|
|
816
816
|
const dollarTPatterns = [
|
|
@@ -838,9 +838,10 @@ const dollarTPatterns = [
|
|
|
838
838
|
const rule = {
|
|
839
839
|
defaultOptions: [],
|
|
840
840
|
meta: {
|
|
841
|
-
docs: { description: 'Format Vue templates: strip unnecessary props/$props prefixes, redundant ="true" attributes (except aria- attributes), enforce t() over $t(),
|
|
841
|
+
docs: { description: 'Format Vue templates: strip unnecessary props/$props prefixes, redundant ="true" attributes (except aria- attributes), enforce t() over $t(), require "on" prefix on named event listener handlers, and disallow inline event handler expressions' },
|
|
842
842
|
fixable: "code",
|
|
843
843
|
messages: {
|
|
844
|
+
eventHandlerMustBeFunction: 'Event listener must reference a named handler function (e.g. @click="onClose") or call one (e.g. @click="onClose($event)"). Inline expressions are not allowed.',
|
|
844
845
|
noPropsPrefix: "Unnecessary props/$props prefix in template. Props are automatically available in template scope.",
|
|
845
846
|
prefixEventHandlerWithOn: 'Event listener handler "{{name}}" must be prefixed with "on" (e.g. @click="onClick").',
|
|
846
847
|
removeTrueAttribute: 'Unnecessary ="true" attribute. Use the attribute name directly instead.',
|
|
@@ -922,24 +923,36 @@ const rule = {
|
|
|
922
923
|
while (eventHandlerMatch !== null) {
|
|
923
924
|
const handlerValue = eventHandlerMatch[1].trim();
|
|
924
925
|
let handlerName;
|
|
926
|
+
let isBareIdentifier = false;
|
|
927
|
+
let isSingleCall = false;
|
|
925
928
|
if (bareIdentifierRegex.test(handlerValue)) {
|
|
926
929
|
handlerName = handlerValue;
|
|
930
|
+
isBareIdentifier = true;
|
|
927
931
|
} else {
|
|
928
932
|
const singleCallMatch = singleCallRegex.exec(handlerValue);
|
|
929
933
|
if (singleCallMatch) {
|
|
930
934
|
handlerName = singleCallMatch[1];
|
|
935
|
+
isSingleCall = true;
|
|
931
936
|
}
|
|
932
937
|
}
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
938
|
+
const valueStart = templateStartIndex + eventHandlerMatch.index + eventHandlerMatch[0].length - 1 - eventHandlerMatch[1].length;
|
|
939
|
+
const valueEnd = valueStart + eventHandlerMatch[1].length;
|
|
940
|
+
const handlerLoc = {
|
|
941
|
+
end: sourceCode.getLocFromIndex(valueEnd),
|
|
942
|
+
start: sourceCode.getLocFromIndex(valueStart)
|
|
943
|
+
};
|
|
944
|
+
if (isBareIdentifier || isSingleCall) {
|
|
945
|
+
if (handlerName && !exemptCallees.has(handlerName) && !onPrefixRegex.test(handlerName)) {
|
|
946
|
+
context.report({
|
|
947
|
+
data: { name: handlerName },
|
|
948
|
+
loc: handlerLoc,
|
|
949
|
+
messageId: "prefixEventHandlerWithOn"
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
} else {
|
|
936
953
|
context.report({
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
end: sourceCode.getLocFromIndex(valueEnd),
|
|
940
|
-
start: sourceCode.getLocFromIndex(valueStart)
|
|
941
|
-
},
|
|
942
|
-
messageId: "prefixEventHandlerWithOn"
|
|
954
|
+
loc: handlerLoc,
|
|
955
|
+
messageId: "eventHandlerMustBeFunction"
|
|
943
956
|
});
|
|
944
957
|
}
|
|
945
958
|
eventHandlerMatch = eventHandlerRegex.exec(templateContent);
|
package/dist/index.d.cts
CHANGED
|
@@ -5203,7 +5203,7 @@ declare const _default: {
|
|
|
5203
5203
|
locales?: string[];
|
|
5204
5204
|
} | undefined)?], unknown, RuleListener>;
|
|
5205
5205
|
'vue-format-script': RuleModule<"multilineComputed" | "untypedEmits", [], unknown, RuleListener>;
|
|
5206
|
-
'vue-format-template': RuleModule<"noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5206
|
+
'vue-format-template': RuleModule<"eventHandlerMustBeFunction" | "noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5207
5207
|
};
|
|
5208
5208
|
};
|
|
5209
5209
|
|
package/dist/index.d.mts
CHANGED
|
@@ -5203,7 +5203,7 @@ declare const _default: {
|
|
|
5203
5203
|
locales?: string[];
|
|
5204
5204
|
} | undefined)?], unknown, RuleListener>;
|
|
5205
5205
|
'vue-format-script': RuleModule<"multilineComputed" | "untypedEmits", [], unknown, RuleListener>;
|
|
5206
|
-
'vue-format-template': RuleModule<"noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5206
|
+
'vue-format-template': RuleModule<"eventHandlerMustBeFunction" | "noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5207
5207
|
};
|
|
5208
5208
|
};
|
|
5209
5209
|
|
package/dist/index.d.ts
CHANGED
|
@@ -5203,7 +5203,7 @@ declare const _default: {
|
|
|
5203
5203
|
locales?: string[];
|
|
5204
5204
|
} | undefined)?], unknown, RuleListener>;
|
|
5205
5205
|
'vue-format-script': RuleModule<"multilineComputed" | "untypedEmits", [], unknown, RuleListener>;
|
|
5206
|
-
'vue-format-template': RuleModule<"noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5206
|
+
'vue-format-template': RuleModule<"eventHandlerMustBeFunction" | "noPropsPrefix" | "prefixEventHandlerWithOn" | "removeTrueAttribute" | "useT", [], unknown, RuleListener>;
|
|
5207
5207
|
};
|
|
5208
5208
|
};
|
|
5209
5209
|
|
package/dist/index.mjs
CHANGED
|
@@ -807,8 +807,8 @@ const templateTagLength = "<template>".length;
|
|
|
807
807
|
const propsPrefixRegex = /\$?props\.(\w+)/g;
|
|
808
808
|
const trueAttributeRegex = /(?<![\w-]):?(?!aria-)([a-z0-9-]+)="true"/gi;
|
|
809
809
|
const eventHandlerRegex = /(?:@|v-on:)[^\s="'<>/]+\s*=\s*"([^"]*)"/g;
|
|
810
|
-
const bareIdentifierRegex = /^[
|
|
811
|
-
const singleCallRegex = /^([
|
|
810
|
+
const bareIdentifierRegex = /^[a-z_$][\w$]*$/i;
|
|
811
|
+
const singleCallRegex = /^([a-z_$][\w$]*)\s*\(.*\)$/is;
|
|
812
812
|
const onPrefixRegex = /^on[A-Z]/;
|
|
813
813
|
const exemptCallees = /* @__PURE__ */ new Set(["$emit", "emit"]);
|
|
814
814
|
const dollarTPatterns = [
|
|
@@ -836,9 +836,10 @@ const dollarTPatterns = [
|
|
|
836
836
|
const rule = {
|
|
837
837
|
defaultOptions: [],
|
|
838
838
|
meta: {
|
|
839
|
-
docs: { description: 'Format Vue templates: strip unnecessary props/$props prefixes, redundant ="true" attributes (except aria- attributes), enforce t() over $t(),
|
|
839
|
+
docs: { description: 'Format Vue templates: strip unnecessary props/$props prefixes, redundant ="true" attributes (except aria- attributes), enforce t() over $t(), require "on" prefix on named event listener handlers, and disallow inline event handler expressions' },
|
|
840
840
|
fixable: "code",
|
|
841
841
|
messages: {
|
|
842
|
+
eventHandlerMustBeFunction: 'Event listener must reference a named handler function (e.g. @click="onClose") or call one (e.g. @click="onClose($event)"). Inline expressions are not allowed.',
|
|
842
843
|
noPropsPrefix: "Unnecessary props/$props prefix in template. Props are automatically available in template scope.",
|
|
843
844
|
prefixEventHandlerWithOn: 'Event listener handler "{{name}}" must be prefixed with "on" (e.g. @click="onClick").',
|
|
844
845
|
removeTrueAttribute: 'Unnecessary ="true" attribute. Use the attribute name directly instead.',
|
|
@@ -920,24 +921,36 @@ const rule = {
|
|
|
920
921
|
while (eventHandlerMatch !== null) {
|
|
921
922
|
const handlerValue = eventHandlerMatch[1].trim();
|
|
922
923
|
let handlerName;
|
|
924
|
+
let isBareIdentifier = false;
|
|
925
|
+
let isSingleCall = false;
|
|
923
926
|
if (bareIdentifierRegex.test(handlerValue)) {
|
|
924
927
|
handlerName = handlerValue;
|
|
928
|
+
isBareIdentifier = true;
|
|
925
929
|
} else {
|
|
926
930
|
const singleCallMatch = singleCallRegex.exec(handlerValue);
|
|
927
931
|
if (singleCallMatch) {
|
|
928
932
|
handlerName = singleCallMatch[1];
|
|
933
|
+
isSingleCall = true;
|
|
929
934
|
}
|
|
930
935
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
936
|
+
const valueStart = templateStartIndex + eventHandlerMatch.index + eventHandlerMatch[0].length - 1 - eventHandlerMatch[1].length;
|
|
937
|
+
const valueEnd = valueStart + eventHandlerMatch[1].length;
|
|
938
|
+
const handlerLoc = {
|
|
939
|
+
end: sourceCode.getLocFromIndex(valueEnd),
|
|
940
|
+
start: sourceCode.getLocFromIndex(valueStart)
|
|
941
|
+
};
|
|
942
|
+
if (isBareIdentifier || isSingleCall) {
|
|
943
|
+
if (handlerName && !exemptCallees.has(handlerName) && !onPrefixRegex.test(handlerName)) {
|
|
944
|
+
context.report({
|
|
945
|
+
data: { name: handlerName },
|
|
946
|
+
loc: handlerLoc,
|
|
947
|
+
messageId: "prefixEventHandlerWithOn"
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
} else {
|
|
934
951
|
context.report({
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
end: sourceCode.getLocFromIndex(valueEnd),
|
|
938
|
-
start: sourceCode.getLocFromIndex(valueStart)
|
|
939
|
-
},
|
|
940
|
-
messageId: "prefixEventHandlerWithOn"
|
|
952
|
+
loc: handlerLoc,
|
|
953
|
+
messageId: "eventHandlerMustBeFunction"
|
|
941
954
|
});
|
|
942
955
|
}
|
|
943
956
|
eventHandlerMatch = eventHandlerRegex.exec(templateContent);
|