feat: lint suggestions for properties for js/confusingLanguage
MODIFY
internal/compiler/lint/rules/js/confusingLanguage.test.rjson
internal/compiler/lint/rules/js/confusingLanguage.test.rjson
@@ -7,4 +7,7 @@ blacklist */"
"BLACKLIST;"
"someBlacklist;"
"SOME_BLACKLIST;"
+ "const payload = {blacklist: []};"
+ "payload.blacklist = [];"
+ "payload.blacklist();"
]

MODIFY
internal/compiler/lint/rules/js/confusingLanguage.ts
internal/compiler/lint/rules/js/confusingLanguage.ts
@@ -135,7 +135,7 @@ function check(
export default createVisitor({
name: "js/inconsiderateLanguage",
enter(path) {
- const {node, context} = path;
+ const {node, context, parent} = path;
const {loc} = node;
if (loc !== undefined) {
@@ -148,6 +148,10 @@ export default createVisitor({
value = node.name;
}
+ const isSafeFix =
+ parent.type !== "JSStaticPropertyKey" &&
+ parent.type !== "JSStaticMemberProperty";
+
if (value !== undefined) {
// Produce diagnostics
const {results, fixed} = check(loc, value);
@@ -160,7 +164,7 @@ export default createVisitor({
suggestion,
advice,
),
- {tags: {fixable: true}},
+ {tags: {fixable: isSafeFix}},
));
if (suppressed) {
@@ -169,7 +173,7 @@ export default createVisitor({
}
// Autofix if not suppressed
- if (results.length > 0 && !suppressed) {
+ if (results.length > 0 && isSafeFix && !suppressed) {
if (node.type === "CommentBlock" || node.type === "CommentLine") {
return signals.replace({
...node,

feat: lint suggestions for properties for js/confusingLanguage (#934)