@typescript-eslint/eslint-plugin 8.65.1-alpha.17 → 8.65.1-alpha.18
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.
|
@@ -113,22 +113,29 @@ exports.default = (0, util_1.createRule)({
|
|
|
113
113
|
if (hasDuplicateKeySetter) {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
+
const getterBody = node.value.body;
|
|
116
117
|
context.report({
|
|
117
118
|
node: node.key,
|
|
118
119
|
messageId: 'preferFieldStyle',
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
...(0, util_1.getFixOrSuggest)({
|
|
121
|
+
fixOrSuggest: node.decorators.length === 0 ? 'suggest' : 'none',
|
|
122
|
+
suggestion: {
|
|
121
123
|
messageId: 'preferFieldStyleSuggestion',
|
|
122
124
|
fix(fixer) {
|
|
123
125
|
const name = context.sourceCode.getText(node.key);
|
|
126
|
+
const closingParen = (0, util_1.nullThrows)(context.sourceCode.getTokenBefore(node.value.returnType ?? getterBody), 'Getter should have a closing parenthesis.');
|
|
127
|
+
const betweenParensAndBody = context.sourceCode
|
|
128
|
+
.getText()
|
|
129
|
+
.slice(closingParen.range[1], getterBody.range[0]);
|
|
124
130
|
let text = '';
|
|
125
131
|
text += printNodeModifiers(node, 'readonly');
|
|
126
132
|
text += node.computed ? `[${name}]` : name;
|
|
127
|
-
text +=
|
|
133
|
+
text += betweenParensAndBody;
|
|
134
|
+
text += `= ${context.sourceCode.getText(argument)};`;
|
|
128
135
|
return fixer.replaceText(node, text);
|
|
129
136
|
},
|
|
130
137
|
},
|
|
131
|
-
|
|
138
|
+
}),
|
|
132
139
|
});
|
|
133
140
|
},
|
|
134
141
|
}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typescript-eslint/eslint-plugin",
|
|
3
|
-
"version": "8.65.1-alpha.
|
|
3
|
+
"version": "8.65.1-alpha.18",
|
|
4
4
|
"description": "TypeScript plugin for ESLint",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"ignore": "^7.0.5",
|
|
50
50
|
"natural-compare": "^1.4.0",
|
|
51
51
|
"ts-api-utils": "^2.5.0",
|
|
52
|
-
"@typescript-eslint/
|
|
53
|
-
"@typescript-eslint/
|
|
54
|
-
"@typescript-eslint/
|
|
55
|
-
"@typescript-eslint/visitor-keys": "8.65.1-alpha.
|
|
52
|
+
"@typescript-eslint/type-utils": "8.65.1-alpha.18",
|
|
53
|
+
"@typescript-eslint/scope-manager": "8.65.1-alpha.18",
|
|
54
|
+
"@typescript-eslint/utils": "8.65.1-alpha.18",
|
|
55
|
+
"@typescript-eslint/visitor-keys": "8.65.1-alpha.18"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/json-schema": "^7.0.15",
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"typescript": ">=4.8.4 <6.1.0",
|
|
77
77
|
"unist-util-visit": "^5.0.0",
|
|
78
78
|
"vitest": "^4.0.18",
|
|
79
|
-
"@typescript-eslint/rule-
|
|
80
|
-
"@typescript-eslint/rule-
|
|
79
|
+
"@typescript-eslint/rule-schema-to-typescript-types": "8.65.1-alpha.18",
|
|
80
|
+
"@typescript-eslint/rule-tester": "8.65.1-alpha.18"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
|
|
84
84
|
"typescript": ">=4.8.4 <6.1.0",
|
|
85
|
-
"@typescript-eslint/parser": "^8.65.1-alpha.
|
|
85
|
+
"@typescript-eslint/parser": "^8.65.1-alpha.18"
|
|
86
86
|
},
|
|
87
87
|
"funding": {
|
|
88
88
|
"type": "opencollective",
|