@typescript-eslint/eslint-plugin 8.21.1-alpha.9 → 8.22.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,200 +62,284 @@ exports.default = (0, util_1.createRule)({
62
62
  defaultOptions: [],
63
63
  create(context) {
64
64
  const services = (0, util_1.getParserServices)(context);
65
- function isUnderlyingTypeString(expression) {
66
- const checker = services.program.getTypeChecker();
67
- const { constraintType } = (0, util_1.getConstraintInfo)(checker, services.getTypeAtLocation(expression));
68
- if (constraintType == null) {
69
- return false;
70
- }
71
- const isString = (t) => {
72
- return (0, util_1.isTypeFlagSet)(t, ts.TypeFlags.StringLike);
73
- };
74
- if (constraintType.isUnion()) {
75
- return constraintType.types.every(isString);
65
+ const checker = services.program.getTypeChecker();
66
+ function isStringLike(type) {
67
+ return (0, util_1.isTypeFlagSet)(type, ts.TypeFlags.StringLike);
68
+ }
69
+ function isUnderlyingTypeString(type) {
70
+ if (type.isUnion()) {
71
+ return type.types.every(isStringLike);
76
72
  }
77
- if (constraintType.isIntersection()) {
78
- return constraintType.types.some(isString);
73
+ if (type.isIntersection()) {
74
+ return type.types.some(isStringLike);
79
75
  }
80
- return isString(constraintType);
76
+ return isStringLike(type);
81
77
  }
82
- function isLiteral(expression) {
83
- return expression.type === utils_1.AST_NODE_TYPES.Literal;
78
+ /**
79
+ * Checks for whole enum types, i.e. `MyEnum`, and not their values, i.e. `MyEnum.A`
80
+ */
81
+ function isEnumType(type) {
82
+ const symbol = type.getSymbol();
83
+ return !!(symbol?.valueDeclaration &&
84
+ ts.isEnumDeclaration(symbol.valueDeclaration));
84
85
  }
85
- function isTemplateLiteral(expression) {
86
- return expression.type === utils_1.AST_NODE_TYPES.TemplateLiteral;
86
+ const isLiteral = (0, util_1.isNodeOfType)(utils_1.TSESTree.AST_NODE_TYPES.Literal);
87
+ function isTemplateLiteral(node) {
88
+ return node.type === utils_1.AST_NODE_TYPES.TemplateLiteral;
87
89
  }
88
- function isInfinityIdentifier(expression) {
89
- return (expression.type === utils_1.AST_NODE_TYPES.Identifier &&
90
- expression.name === 'Infinity');
90
+ function isInfinityIdentifier(node) {
91
+ return (node.type === utils_1.AST_NODE_TYPES.Identifier && node.name === 'Infinity');
91
92
  }
92
- function isNaNIdentifier(expression) {
93
- return (expression.type === utils_1.AST_NODE_TYPES.Identifier &&
94
- expression.name === 'NaN');
93
+ function isNaNIdentifier(node) {
94
+ return node.type === utils_1.AST_NODE_TYPES.Identifier && node.name === 'NaN';
95
+ }
96
+ function isFixableIdentifier(node) {
97
+ return ((0, util_1.isUndefinedIdentifier)(node) ||
98
+ isInfinityIdentifier(node) ||
99
+ isNaNIdentifier(node));
95
100
  }
96
101
  function hasCommentsBetweenQuasi(startQuasi, endQuasi) {
97
102
  const startToken = (0, util_1.nullThrows)(context.sourceCode.getTokenByRangeStart(startQuasi.range[0]), util_1.NullThrowsReasons.MissingToken('`${', 'opening template literal'));
98
103
  const endToken = (0, util_1.nullThrows)(context.sourceCode.getTokenByRangeStart(endQuasi.range[0]), util_1.NullThrowsReasons.MissingToken('}', 'closing template literal'));
99
104
  return context.sourceCode.commentsExistBetween(startToken, endToken);
100
105
  }
101
- return {
102
- TemplateLiteral(node) {
103
- if (node.parent.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression) {
104
- return;
105
- }
106
- const hasSingleStringVariable = node.quasis.length === 2 &&
107
- node.quasis[0].value.raw === '' &&
108
- node.quasis[1].value.raw === '' &&
109
- node.expressions.length === 1 &&
110
- isUnderlyingTypeString(node.expressions[0]);
111
- if (hasSingleStringVariable) {
112
- if (hasCommentsBetweenQuasi(node.quasis[0], node.quasis[1])) {
113
- return;
114
- }
115
- context.report({
116
- loc: (0, rangeToLoc_1.rangeToLoc)(context.sourceCode, [
117
- node.expressions[0].range[0] - 2,
118
- node.expressions[0].range[1] + 1,
119
- ]),
120
- messageId: 'noUnnecessaryTemplateExpression',
121
- fix(fixer) {
122
- const wrappingCode = (0, util_1.getMovedNodeCode)({
123
- destinationNode: node,
124
- nodeToMove: node.expressions[0],
125
- sourceCode: context.sourceCode,
126
- });
127
- return fixer.replaceText(node, wrappingCode);
128
- },
106
+ function isTrivialInterpolation(node) {
107
+ return (node.quasis.length === 2 &&
108
+ node.quasis[0].value.raw === '' &&
109
+ node.quasis[1].value.raw === '');
110
+ }
111
+ function getInterpolations(node) {
112
+ if (node.type === utils_1.AST_NODE_TYPES.TemplateLiteral) {
113
+ return node.expressions;
114
+ }
115
+ return node.types;
116
+ }
117
+ function getInterpolationInfos(node) {
118
+ return getInterpolations(node).map((interpolation, index) => ({
119
+ interpolation,
120
+ nextQuasi: node.quasis[index + 1],
121
+ prevQuasi: node.quasis[index],
122
+ }));
123
+ }
124
+ function getLiteral(node) {
125
+ const maybeLiteral = node.type === utils_1.AST_NODE_TYPES.TSLiteralType ? node.literal : node;
126
+ return isLiteral(maybeLiteral) ? maybeLiteral : null;
127
+ }
128
+ function getTemplateLiteral(node) {
129
+ const maybeTemplateLiteral = node.type === utils_1.AST_NODE_TYPES.TSLiteralType ? node.literal : node;
130
+ return isTemplateLiteral(maybeTemplateLiteral)
131
+ ? maybeTemplateLiteral
132
+ : null;
133
+ }
134
+ function reportSingleInterpolation(node) {
135
+ const interpolations = getInterpolations(node);
136
+ context.report({
137
+ loc: (0, rangeToLoc_1.rangeToLoc)(context.sourceCode, [
138
+ interpolations[0].range[0] - 2,
139
+ interpolations[0].range[1] + 1,
140
+ ]),
141
+ messageId: 'noUnnecessaryTemplateExpression',
142
+ fix(fixer) {
143
+ const wrappingCode = (0, util_1.getMovedNodeCode)({
144
+ destinationNode: node,
145
+ nodeToMove: interpolations[0],
146
+ sourceCode: context.sourceCode,
129
147
  });
130
- return;
148
+ return fixer.replaceText(node, wrappingCode);
149
+ },
150
+ });
151
+ }
152
+ function isUnncessaryValueInterpolation({ interpolation, nextQuasi, prevQuasi, }) {
153
+ if (hasCommentsBetweenQuasi(prevQuasi, nextQuasi)) {
154
+ return false;
155
+ }
156
+ if (isFixableIdentifier(interpolation)) {
157
+ return true;
158
+ }
159
+ if (isLiteral(interpolation)) {
160
+ // allow trailing whitespace literal
161
+ if (startsWithNewLine(nextQuasi.value.raw)) {
162
+ return !(typeof interpolation.value === 'string' &&
163
+ isWhitespace(interpolation.value));
131
164
  }
132
- const fixableExpressionsReversed = node.expressions
133
- .map((expression, index) => ({
134
- expression,
135
- nextQuasi: node.quasis[index + 1],
136
- prevQuasi: node.quasis[index],
137
- }))
138
- .filter(({ expression, nextQuasi, prevQuasi }) => {
139
- if ((0, util_1.isUndefinedIdentifier)(expression) ||
140
- isInfinityIdentifier(expression) ||
141
- isNaNIdentifier(expression)) {
142
- return true;
143
- }
144
- // allow expressions that include comments
145
- if (hasCommentsBetweenQuasi(prevQuasi, nextQuasi)) {
146
- return false;
147
- }
148
- if (isLiteral(expression)) {
149
- // allow trailing whitespace literal
150
- if (startsWithNewLine(nextQuasi.value.raw)) {
151
- return !(typeof expression.value === 'string' &&
152
- isWhitespace(expression.value));
153
- }
154
- return true;
155
- }
156
- if (isTemplateLiteral(expression)) {
157
- // allow trailing whitespace literal
158
- if (startsWithNewLine(nextQuasi.value.raw)) {
159
- return !(expression.quasis.length === 1 &&
160
- isWhitespace(expression.quasis[0].value.raw));
161
- }
162
- return true;
163
- }
164
- return false;
165
- })
166
- .reverse();
167
- let nextCharacterIsOpeningCurlyBrace = false;
168
- for (const { expression, nextQuasi, prevQuasi, } of fixableExpressionsReversed) {
169
- const fixers = [];
170
- if (nextQuasi.value.raw !== '') {
171
- nextCharacterIsOpeningCurlyBrace =
172
- nextQuasi.value.raw.startsWith('{');
173
- }
174
- if (isLiteral(expression)) {
175
- let escapedValue = (typeof expression.value === 'string'
176
- ? // The value is already a string, so we're removing quotes:
177
- // "'va`lue'" -> "va`lue"
178
- expression.raw.slice(1, -1)
179
- : // The value may be one of number | bigint | boolean | RegExp | null.
180
- // In regular expressions, we escape every backslash
181
- String(expression.value).replaceAll('\\', '\\\\'))
182
- // The string or RegExp may contain ` or ${.
183
- // We want both of these to be escaped in the final template expression.
184
- //
185
- // A pair of backslashes means "escaped backslash", so backslashes
186
- // from this pair won't escape ` or ${. Therefore, to escape these
187
- // sequences in the resulting template expression, we need to escape
188
- // all sequences that are preceded by an even number of backslashes.
189
- //
190
- // This RegExp does the following transformations:
191
- // \` -> \`
192
- // \\` -> \\\`
193
- // \${ -> \${
194
- // \\${ -> \\\${
195
- .replaceAll(new RegExp(`${String(evenNumOfBackslashesRegExp.source)}(\`|\\\${)`, 'g'), '\\$1');
196
- // `...${'...$'}{...`
197
- // ^^^^
198
- if (nextCharacterIsOpeningCurlyBrace &&
199
- endsWithUnescapedDollarSign(escapedValue)) {
200
- escapedValue = escapedValue.replaceAll(/\$$/g, '\\$');
201
- }
202
- if (escapedValue.length !== 0) {
203
- nextCharacterIsOpeningCurlyBrace = escapedValue.startsWith('{');
204
- }
205
- fixers.push(fixer => [fixer.replaceText(expression, escapedValue)]);
206
- }
207
- else if (isTemplateLiteral(expression)) {
208
- // Since we iterate from the last expression to the first,
209
- // a subsequent expression can tell the current expression
210
- // that it starts with {.
165
+ return true;
166
+ }
167
+ if (isTemplateLiteral(interpolation)) {
168
+ // allow trailing whitespace literal
169
+ if (startsWithNewLine(nextQuasi.value.raw)) {
170
+ return !(interpolation.quasis.length === 1 &&
171
+ isWhitespace(interpolation.quasis[0].value.raw));
172
+ }
173
+ return true;
174
+ }
175
+ return false;
176
+ }
177
+ function isUnncessaryTypeInterpolation({ interpolation, nextQuasi, prevQuasi, }) {
178
+ if (hasCommentsBetweenQuasi(prevQuasi, nextQuasi)) {
179
+ return false;
180
+ }
181
+ const literal = getLiteral(interpolation);
182
+ if (literal) {
183
+ // allow trailing whitespace literal
184
+ if (startsWithNewLine(nextQuasi.value.raw)) {
185
+ return !(typeof literal.value === 'string' && isWhitespace(literal.value));
186
+ }
187
+ return true;
188
+ }
189
+ if (interpolation.type === utils_1.AST_NODE_TYPES.TSNullKeyword ||
190
+ interpolation.type === utils_1.AST_NODE_TYPES.TSUndefinedKeyword) {
191
+ return true;
192
+ }
193
+ const templateLiteral = getTemplateLiteral(interpolation);
194
+ if (templateLiteral) {
195
+ // allow trailing whitespace literal
196
+ if (startsWithNewLine(nextQuasi.value.raw)) {
197
+ return !(templateLiteral.quasis.length === 1 &&
198
+ isWhitespace(templateLiteral.quasis[0].value.raw));
199
+ }
200
+ return true;
201
+ }
202
+ return false;
203
+ }
204
+ function getReportDescriptors(infos) {
205
+ let nextCharacterIsOpeningCurlyBrace = false;
206
+ const reportDescriptors = [];
207
+ const reversedInfos = [...infos].reverse();
208
+ for (const { interpolation, nextQuasi, prevQuasi } of reversedInfos) {
209
+ const fixers = [];
210
+ if (nextQuasi.value.raw !== '') {
211
+ nextCharacterIsOpeningCurlyBrace =
212
+ nextQuasi.value.raw.startsWith('{');
213
+ }
214
+ const literal = getLiteral(interpolation);
215
+ const templateLiteral = getTemplateLiteral(interpolation);
216
+ if (literal) {
217
+ let escapedValue = (typeof literal.value === 'string'
218
+ ? // The value is already a string, so we're removing quotes:
219
+ // "'va`lue'" -> "va`lue"
220
+ literal.raw.slice(1, -1)
221
+ : // The value may be one of number | bigint | boolean | RegExp | null.
222
+ // In regular expressions, we escape every backslash
223
+ String(literal.value).replaceAll('\\', '\\\\'))
224
+ // The string or RegExp may contain ` or ${.
225
+ // We want both of these to be escaped in the final template expression.
211
226
  //
212
- // `... ${`... $`}${'{...'} ...`
213
- // ^ ^ subsequent expression starts with {
214
- // current expression ends with a dollar sign,
215
- // so '$' + '{' === '${' (bad news for us).
216
- // Let's escape the dollar sign at the end.
217
- if (nextCharacterIsOpeningCurlyBrace &&
218
- endsWithUnescapedDollarSign(expression.quasis[expression.quasis.length - 1].value.raw)) {
219
- fixers.push(fixer => [
220
- fixer.replaceTextRange([expression.range[1] - 2, expression.range[1] - 2], '\\'),
221
- ]);
222
- }
223
- if (expression.quasis.length === 1 &&
224
- expression.quasis[0].value.raw.length !== 0) {
225
- nextCharacterIsOpeningCurlyBrace =
226
- expression.quasis[0].value.raw.startsWith('{');
227
- }
228
- // Remove the beginning and trailing backtick characters.
229
- fixers.push(fixer => [
230
- fixer.removeRange([expression.range[0], expression.range[0] + 1]),
231
- fixer.removeRange([expression.range[1] - 1, expression.range[1]]),
232
- ]);
227
+ // A pair of backslashes means "escaped backslash", so backslashes
228
+ // from this pair won't escape ` or ${. Therefore, to escape these
229
+ // sequences in the resulting template expression, we need to escape
230
+ // all sequences that are preceded by an even number of backslashes.
231
+ //
232
+ // This RegExp does the following transformations:
233
+ // \` -> \`
234
+ // \\` -> \\\`
235
+ // \${ -> \${
236
+ // \\${ -> \\\${
237
+ .replaceAll(new RegExp(`${String(evenNumOfBackslashesRegExp.source)}(\`|\\\${)`, 'g'), '\\$1');
238
+ // `...${'...$'}{...`
239
+ // ^^^^
240
+ if (nextCharacterIsOpeningCurlyBrace &&
241
+ endsWithUnescapedDollarSign(escapedValue)) {
242
+ escapedValue = escapedValue.replaceAll(/\$$/g, '\\$');
233
243
  }
234
- else {
235
- nextCharacterIsOpeningCurlyBrace = false;
244
+ if (escapedValue.length !== 0) {
245
+ nextCharacterIsOpeningCurlyBrace = escapedValue.startsWith('{');
236
246
  }
237
- // `... $${'{...'} ...`
238
- // ^^^^^
247
+ fixers.push(fixer => [fixer.replaceText(literal, escapedValue)]);
248
+ }
249
+ else if (templateLiteral) {
250
+ // Since we iterate from the last expression to the first,
251
+ // a subsequent expression can tell the current expression
252
+ // that it starts with {.
253
+ //
254
+ // `... ${`... $`}${'{...'} ...`
255
+ // ^ ^ subsequent expression starts with {
256
+ // current expression ends with a dollar sign,
257
+ // so '$' + '{' === '${' (bad news for us).
258
+ // Let's escape the dollar sign at the end.
239
259
  if (nextCharacterIsOpeningCurlyBrace &&
240
- endsWithUnescapedDollarSign(prevQuasi.value.raw)) {
260
+ endsWithUnescapedDollarSign(templateLiteral.quasis[templateLiteral.quasis.length - 1].value
261
+ .raw)) {
241
262
  fixers.push(fixer => [
242
- fixer.replaceTextRange([prevQuasi.range[1] - 3, prevQuasi.range[1] - 2], '\\$'),
263
+ fixer.replaceTextRange([templateLiteral.range[1] - 2, templateLiteral.range[1] - 2], '\\'),
243
264
  ]);
244
265
  }
245
- const warnLocStart = prevQuasi.range[1] - 2;
246
- const warnLocEnd = nextQuasi.range[0] + 1;
247
- context.report({
248
- loc: (0, rangeToLoc_1.rangeToLoc)(context.sourceCode, [warnLocStart, warnLocEnd]),
249
- messageId: 'noUnnecessaryTemplateExpression',
250
- fix(fixer) {
251
- return [
252
- // Remove the quasis' parts that are related to the current expression.
253
- fixer.removeRange([warnLocStart, expression.range[0]]),
254
- fixer.removeRange([expression.range[1], warnLocEnd]),
255
- ...fixers.flatMap(cb => cb(fixer)),
256
- ];
257
- },
258
- });
266
+ if (templateLiteral.quasis.length === 1 &&
267
+ templateLiteral.quasis[0].value.raw.length !== 0) {
268
+ nextCharacterIsOpeningCurlyBrace =
269
+ templateLiteral.quasis[0].value.raw.startsWith('{');
270
+ }
271
+ // Remove the beginning and trailing backtick characters.
272
+ fixers.push(fixer => [
273
+ fixer.removeRange([
274
+ templateLiteral.range[0],
275
+ templateLiteral.range[0] + 1,
276
+ ]),
277
+ fixer.removeRange([
278
+ templateLiteral.range[1] - 1,
279
+ templateLiteral.range[1],
280
+ ]),
281
+ ]);
282
+ }
283
+ else {
284
+ nextCharacterIsOpeningCurlyBrace = false;
285
+ }
286
+ // `... $${'{...'} ...`
287
+ // ^^^^^
288
+ if (nextCharacterIsOpeningCurlyBrace &&
289
+ endsWithUnescapedDollarSign(prevQuasi.value.raw)) {
290
+ fixers.push(fixer => [
291
+ fixer.replaceTextRange([prevQuasi.range[1] - 3, prevQuasi.range[1] - 2], '\\$'),
292
+ ]);
293
+ }
294
+ const warnLocStart = prevQuasi.range[1] - 2;
295
+ const warnLocEnd = nextQuasi.range[0] + 1;
296
+ reportDescriptors.push({
297
+ loc: (0, rangeToLoc_1.rangeToLoc)(context.sourceCode, [warnLocStart, warnLocEnd]),
298
+ messageId: 'noUnnecessaryTemplateExpression',
299
+ fix(fixer) {
300
+ return [
301
+ // Remove the quasis' parts that are related to the current expression.
302
+ fixer.removeRange([warnLocStart, interpolation.range[0]]),
303
+ fixer.removeRange([interpolation.range[1], warnLocEnd]),
304
+ ...fixers.flatMap(cb => cb(fixer)),
305
+ ];
306
+ },
307
+ });
308
+ }
309
+ return reportDescriptors;
310
+ }
311
+ return {
312
+ TemplateLiteral(node) {
313
+ if (node.parent.type === utils_1.AST_NODE_TYPES.TaggedTemplateExpression) {
314
+ return;
315
+ }
316
+ if (isTrivialInterpolation(node) &&
317
+ !hasCommentsBetweenQuasi(node.quasis[0], node.quasis[1])) {
318
+ const { constraintType } = (0, util_1.getConstraintInfo)(checker, services.getTypeAtLocation(node.expressions[0]));
319
+ if (constraintType && isUnderlyingTypeString(constraintType)) {
320
+ reportSingleInterpolation(node);
321
+ return;
322
+ }
323
+ }
324
+ const infos = getInterpolationInfos(node).filter(isUnncessaryValueInterpolation);
325
+ for (const reportDescriptor of getReportDescriptors(infos)) {
326
+ context.report(reportDescriptor);
327
+ }
328
+ },
329
+ TSTemplateLiteralType(node) {
330
+ if (isTrivialInterpolation(node) &&
331
+ !hasCommentsBetweenQuasi(node.quasis[0], node.quasis[1])) {
332
+ const { constraintType } = (0, util_1.getConstraintInfo)(checker, services.getTypeAtLocation(node.types[0]));
333
+ if (constraintType &&
334
+ isUnderlyingTypeString(constraintType) &&
335
+ !isEnumType(constraintType)) {
336
+ reportSingleInterpolation(node);
337
+ return;
338
+ }
339
+ }
340
+ const infos = getInterpolationInfos(node).filter(isUnncessaryTypeInterpolation);
341
+ for (const reportDescriptor of getReportDescriptors(infos)) {
342
+ context.report(reportDescriptor);
259
343
  }
260
344
  },
261
345
  };
@@ -1 +1 @@
1
- {"version":3,"file":"no-unnecessary-template-expression.js","sourceRoot":"","sources":["../../src/rules/no-unnecessary-template-expression.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;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AE,IAAA,uBAAU,EAAC,OAAO,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;wBAC/D,SAAS,EAAE,iCAAiC;wBAC5C,GAAG,CAAC,KAAK;4BACP,OAAO;gCACL,uEAAuE;gCACvE,KAAK,CAAC,WAAW,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gCACtD,KAAK,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gCAEpD,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;6BACnC,CAAC;wBACJ,CAAC;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,YAAY,CAAC,CAAS;IAC7B,gDAAgD;IAChD,eAAe;IACf,KAAK;IACL,EAAE;IACF,iBAAiB;IACjB,iBAAiB;IACjB,KAAK;IACL,EAAE;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC"}
1
+ {"version":3,"file":"no-unnecessary-template-expression.js","sourceRoot":"","sources":["../../src/rules/no-unnecessary-template-expression.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,oDAAoE;AACpE,+CAAiC;AAEjC,kCAUiB;AACjB,mDAAgD;AAchD,MAAM,0BAA0B,GAAG,6BAA6B,CAAC;AAEjE,iBAAiB;AACjB,kBAAkB;AAClB,qBAAqB;AACrB,SAAS,2BAA2B,CAAC,GAAW;IAC9C,OAAO,IAAI,MAAM,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C,CAAC;AAEH,SAAS,YAAY,CAAC,CAAS;IAC7B,gDAAgD;IAChD,eAAe;IACf,KAAK;IACL,EAAE;IACF,iBAAiB;IACjB,iBAAiB;IACjB,KAAK;IACL,EAAE;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,iBAAiB,CAAC,CAAS;IAClC,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACpD,CAAC"}
@@ -107,8 +107,8 @@ The rule will **_not_** report any errors in files _that contain decorators_ whe
107
107
 
108
108
  > See [Blog > Changes to consistent-type-imports when used with legacy decorators and decorator metadata](/blog/changes-to-consistent-type-imports-with-decorators) for more details.
109
109
 
110
- If you are using [type-aware linting](https://typescript-eslint.io/linting/typed-linting) then we will automatically infer your setup from your tsconfig and you should not need to configure anything.
111
- Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on by setting both [`parserOptions.emitDecoratorMetadata = true`](https://typescript-eslint.io/packages/parser/#emitdecoratormetadata) and [`parserOptions.experimentalDecorators = true`](https://typescript-eslint.io/packages/parser/#experimentaldecorators).
110
+ If you are using [type-aware linting](/getting-started/typed-linting) then we will automatically infer your setup from your tsconfig and you should not need to configure anything.
111
+ Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on by setting both [`parserOptions.emitDecoratorMetadata = true`](/packages/parser/#emitdecoratormetadata) and [`parserOptions.experimentalDecorators = true`](/packages/parser/#experimentaldecorators).
112
112
 
113
113
  ## Comparison with `importsNotUsedAsValues` / `verbatimModuleSyntax`
114
114
 
@@ -135,8 +135,15 @@ declare module 'foo' {}
135
135
 
136
136
  ## When Not To Use It
137
137
 
138
- If your project was architected before modern modules and namespaces, it may be difficult to migrate off of namespaces.
138
+ If your project uses TypeScript's CommonJS export syntax (`export = ...`), you may need to use namespaces in order to export types from your module.
139
+ You can learn more about this at:
140
+
141
+ - [TypeScript#52203](https://github.com/microsoft/TypeScript/pull/52203), the pull request introducing [`verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax)
142
+ - [TypeScript#60852](https://github.com/microsoft/TypeScript/issues/60852), an issue requesting syntax to export types from a CommonJS module.
143
+
144
+ If your project uses this syntax, either because it was architected before modern modules and namespaces, or because a module option such as `verbatimModuleSyntax` requires it, it may be difficult to migrate off of namespaces.
139
145
  In that case you may not be able to use this rule for parts of your project.
146
+
140
147
  You might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
141
148
 
142
149
  ## Further Reading
@@ -144,6 +151,7 @@ You might consider using [ESLint disable comments](https://eslint.org/docs/lates
144
151
  {/* cspell:disable-next-line */}
145
152
 
146
153
  - [FAQ: I get errors from the `@typescript-eslint/no-namespace` and/or `no-var` rules about declaring global variables](/troubleshooting/faqs/eslint#i-get-errors-from-the-typescript-eslintno-namespace-andor-no-var-rules-about-declaring-global-variables)
147
- - [Modules](https://www.typescriptlang.org/docs/handbook/modules.html)
148
- - [Namespaces](https://www.typescriptlang.org/docs/handbook/namespaces.html)
149
- - [Namespaces and Modules](https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html)
154
+ - [FAQ: How should I handle reports that conflict with verbatimModuleSyntax?](/troubleshooting/faqs/typescript#how-should-i-handle-reports-that-conflict-with-verbatimmodulesyntax)
155
+ - [TypeScript handbook entry on Modules](https://www.typescriptlang.org/docs/handbook/modules.html)
156
+ - [TypeScript handbook entry on Namespaces](https://www.typescriptlang.org/docs/handbook/namespaces.html)
157
+ - [TypeScript handbook entry on Namespaces and Modules](https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html)
@@ -9,7 +9,9 @@ import TabItem from '@theme/TabItem';
9
9
  >
10
10
  > See **https://typescript-eslint.io/rules/no-require-imports** for documentation.
11
11
 
12
- Prefer the newer ES6-style imports over `require()`.
12
+ Depending on your TSConfig settings and whether you're authoring ES Modules or CommonJS, TS may allow both `import` and `require()` to be used, even within a single file.
13
+
14
+ This rule enforces that you use the newer ES Module `import` syntax over CommonJS `require()`.
13
15
 
14
16
  ## Examples
15
17
 
@@ -42,7 +44,7 @@ import * as lib3 from 'lib3';
42
44
 
43
45
  These strings will be compiled into regular expressions with the `u` flag and be used to test against the imported path. A common use case is to allow importing `package.json`. This is because `package.json` commonly lives outside of the TS root directory, so statically importing it would lead to root directory conflicts, especially with `resolveJsonModule` enabled. You can also use it to allow importing any JSON if your environment doesn't support JSON modules, or use it for other cases where `import` statements cannot work.
44
46
 
45
- With `{allow: ['/package\\.json$']}`:
47
+ With `{ allow: ['/package\\.json$'] }`:
46
48
 
47
49
  <Tabs>
48
50
  <TabItem value="❌ Incorrect">
@@ -66,9 +68,9 @@ console.log(require('../package.json').version);
66
68
  {/* insert option description */}
67
69
 
68
70
  When set to `true`, `import ... = require(...)` declarations won't be reported.
69
- This is useful if you use certain module options that require strict CommonJS interop semantics.
71
+ This is beneficial if you use certain module options that require strict CommonJS interop semantics, such as [verbatimModuleSyntax](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax).
70
72
 
71
- With `{allowAsImport: true}`:
73
+ With `{ allowAsImport: true }`:
72
74
 
73
75
  <Tabs>
74
76
  <TabItem value="❌ Incorrect">
@@ -90,10 +92,22 @@ import foo from 'foo';
90
92
  </TabItem>
91
93
  </Tabs>
92
94
 
95
+ ## Usage with CommonJS
96
+
97
+ While this rule is primarily intended to promote ES Module syntax, it still makes sense to enable this rule when authoring CommonJS modules.
98
+
99
+ If you prefer to use TypeScript's built-in `import ... from ...` ES Module syntax, which is transformed to `require()` calls during transpilation when outputting CommonJS, you can use the rule's default behavior.
100
+
101
+ If, instead, you prefer to use `require()` syntax, we recommend you use this rule with [`allowAsImport`](#allowAsImport) enabled.
102
+ That way, you still enforce usage of `import ... = require(...)` rather than bare `require()` calls, which are not statically analyzed by TypeScript.
103
+ We don't directly a way to _prohibit_ ES Module syntax from being used; consider instead using TypeScript's [`verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax) option if you find yourself in a situation where you would want this.
104
+
93
105
  ## When Not To Use It
94
106
 
95
- If your project frequently uses older CommonJS `require`s, then this rule might not be applicable to you.
96
- If only a subset of your project uses `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
107
+ If you are authoring CommonJS modules _and_ your project frequently uses dynamic `require`s, then this rule might not be applicable to you.
108
+ Otherwise the `allowAsImport` option probably suits your needs.
109
+
110
+ If only a subset of your project uses dynamic `require`s then you might consider using [ESLint disable comments](https://eslint.org/docs/latest/use/configure/rules#using-configuration-comments-1) for those specific situations instead of completely disabling this rule.
97
111
 
98
112
  ## Related To
99
113
 
@@ -28,6 +28,8 @@ The new name is a drop-in replacement with identical functionality.
28
28
 
29
29
  const ab1 = `${'a'}${'b'}`;
30
30
  const ab2 = `a${'b'}`;
31
+ type AB1 = `${'A'}${'B'}`;
32
+ type AB2 = `A${'B'}`;
31
33
 
32
34
  const stringWithNumber = `${'1 + 1 = '}${2}`;
33
35
 
@@ -38,9 +40,13 @@ const stringWithBoolean = `${'true is '}${true}`;
38
40
 
39
41
  const text = 'a';
40
42
  const wrappedText = `${text}`;
43
+ type Text = 'A';
44
+ type WrappedText = `${Text}`;
41
45
 
42
46
  declare const intersectionWithString: string & { _brand: 'test-brand' };
43
47
  const wrappedIntersection = `${intersectionWithString}`;
48
+ type IntersectionWithString = string & { _brand: 'test-brand' };
49
+ type WrappedIntersection = `${IntersectionWithString}`;
44
50
  ```
45
51
 
46
52
  </TabItem>
@@ -51,6 +57,15 @@ const wrappedIntersection = `${intersectionWithString}`;
51
57
 
52
58
  const ab1 = `ab`;
53
59
  const ab2 = `ab`;
60
+ type AB = `AB`;
61
+
62
+ // Transforming enum members into string unions using template literals is allowed.
63
+ enum ABC {
64
+ A = 'A',
65
+ B = 'B',
66
+ C = 'C',
67
+ }
68
+ type ABCUnion = `${ABC}`;
54
69
 
55
70
  const stringWithNumber = `1 + 1 = 2`;
56
71
 
@@ -61,9 +76,13 @@ const stringWithBoolean = `true is true`;
61
76
 
62
77
  const text = 'a';
63
78
  const wrappedText = text;
79
+ type Text = 'A';
80
+ type WrappedText = Text;
64
81
 
65
82
  declare const intersectionWithString: string & { _brand: 'test-brand' };
66
83
  const wrappedIntersection = intersectionWithString;
84
+ type IntersectionWithString = string & { _brand: 'test-brand' };
85
+ type WrappedIntersection = IntersectionWithString;
67
86
  ```
68
87
 
69
88
  </TabItem>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/eslint-plugin",
3
- "version": "8.21.1-alpha.9",
3
+ "version": "8.22.1-alpha.0",
4
4
  "description": "TypeScript plugin for ESLint",
5
5
  "files": [
6
6
  "dist",
@@ -61,10 +61,10 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@eslint-community/regexpp": "^4.10.0",
64
- "@typescript-eslint/scope-manager": "8.21.1-alpha.9",
65
- "@typescript-eslint/type-utils": "8.21.1-alpha.9",
66
- "@typescript-eslint/utils": "8.21.1-alpha.9",
67
- "@typescript-eslint/visitor-keys": "8.21.1-alpha.9",
64
+ "@typescript-eslint/scope-manager": "8.22.1-alpha.0",
65
+ "@typescript-eslint/type-utils": "8.22.1-alpha.0",
66
+ "@typescript-eslint/utils": "8.22.1-alpha.0",
67
+ "@typescript-eslint/visitor-keys": "8.22.1-alpha.0",
68
68
  "graphemer": "^1.4.0",
69
69
  "ignore": "^5.3.1",
70
70
  "natural-compare": "^1.4.0",
@@ -75,8 +75,8 @@
75
75
  "@types/marked": "^5.0.2",
76
76
  "@types/mdast": "^4.0.3",
77
77
  "@types/natural-compare": "*",
78
- "@typescript-eslint/rule-schema-to-typescript-types": "8.21.1-alpha.9",
79
- "@typescript-eslint/rule-tester": "8.21.1-alpha.9",
78
+ "@typescript-eslint/rule-schema-to-typescript-types": "8.22.1-alpha.0",
79
+ "@typescript-eslint/rule-tester": "8.22.1-alpha.0",
80
80
  "ajv": "^6.12.6",
81
81
  "cross-env": "^7.0.3",
82
82
  "cross-fetch": "*",