@taiga-ui/eslint-plugin-experience-next 0.525.0 → 0.527.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.
package/index.esm.js
CHANGED
|
@@ -465,8 +465,106 @@ const TUI_MEMBER_ORDERING_CONVENTION = [
|
|
|
465
465
|
'#private-instance-method',
|
|
466
466
|
];
|
|
467
467
|
|
|
468
|
+
function isSingleLineNode(node) {
|
|
469
|
+
return node.loc.start.line === node.loc.end.line;
|
|
470
|
+
}
|
|
471
|
+
function isLineBreakCharacter(char) {
|
|
472
|
+
return char === '\n' || char === '\r';
|
|
473
|
+
}
|
|
474
|
+
function hasCommentLikeText(text) {
|
|
475
|
+
return text.includes('//') || text.includes('/*');
|
|
476
|
+
}
|
|
477
|
+
function hasBlankLine(text) {
|
|
478
|
+
let lineBreaks = 0;
|
|
479
|
+
for (let index = 0; index < text.length; index++) {
|
|
480
|
+
const char = text[index];
|
|
481
|
+
if (char === '\n') {
|
|
482
|
+
lineBreaks++;
|
|
483
|
+
}
|
|
484
|
+
else if (char === '\r') {
|
|
485
|
+
lineBreaks++;
|
|
486
|
+
if (text[index + 1] === '\n') {
|
|
487
|
+
index++;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
if (lineBreaks > 1) {
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
function getLineBreak(text) {
|
|
497
|
+
if (text.includes('\r\n')) {
|
|
498
|
+
return '\r\n';
|
|
499
|
+
}
|
|
500
|
+
return text.includes('\r') ? '\r' : '\n';
|
|
501
|
+
}
|
|
502
|
+
function hasLineBreak(text) {
|
|
503
|
+
for (const char of text) {
|
|
504
|
+
if (isLineBreakCharacter(char)) {
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
function getLeadingIndentation(text) {
|
|
511
|
+
let index = 0;
|
|
512
|
+
while (index < text.length && (text[index] === ' ' || text[index] === '\t')) {
|
|
513
|
+
index++;
|
|
514
|
+
}
|
|
515
|
+
return text.slice(0, index);
|
|
516
|
+
}
|
|
517
|
+
function getLineStartOffset(text, offset) {
|
|
518
|
+
let index = offset - 1;
|
|
519
|
+
while (index >= 0) {
|
|
520
|
+
const char = text[index];
|
|
521
|
+
if (isLineBreakCharacter(char)) {
|
|
522
|
+
return index + 1;
|
|
523
|
+
}
|
|
524
|
+
index--;
|
|
525
|
+
}
|
|
526
|
+
return 0;
|
|
527
|
+
}
|
|
528
|
+
function getLineEndOffset(text, lineStartOffset) {
|
|
529
|
+
let index = lineStartOffset;
|
|
530
|
+
while (index < text.length) {
|
|
531
|
+
const char = text[index];
|
|
532
|
+
if (isLineBreakCharacter(char)) {
|
|
533
|
+
return index;
|
|
534
|
+
}
|
|
535
|
+
index++;
|
|
536
|
+
}
|
|
537
|
+
return text.length;
|
|
538
|
+
}
|
|
539
|
+
function getNextLineStartOffset(text, offset) {
|
|
540
|
+
let index = offset;
|
|
541
|
+
while (index < text.length) {
|
|
542
|
+
const char = text[index];
|
|
543
|
+
if (char === '\r') {
|
|
544
|
+
return text[index + 1] === '\n' ? index + 2 : index + 1;
|
|
545
|
+
}
|
|
546
|
+
if (char === '\n') {
|
|
547
|
+
return index + 1;
|
|
548
|
+
}
|
|
549
|
+
index++;
|
|
550
|
+
}
|
|
551
|
+
return offset;
|
|
552
|
+
}
|
|
553
|
+
function splitLines(text) {
|
|
554
|
+
return text.split(/\r\n|\n|\r/);
|
|
555
|
+
}
|
|
556
|
+
function getIndentAtOffset(text, offset) {
|
|
557
|
+
const lineStart = getLineStartOffset(text, offset);
|
|
558
|
+
const indent = text.slice(lineStart, offset);
|
|
559
|
+
return indent.trim() === '' ? indent : '';
|
|
560
|
+
}
|
|
561
|
+
function getSpacingReplacement(sourceCode, betweenText, nextLine, blankLineCount) {
|
|
562
|
+
const indentation = getLeadingIndentation(sourceCode.lines[nextLine - 1] ?? '');
|
|
563
|
+
return `${getLineBreak(betweenText).repeat(blankLineCount + 1)}${indentation}`;
|
|
564
|
+
}
|
|
565
|
+
|
|
468
566
|
function buildAST(text) {
|
|
469
|
-
const lines = text
|
|
567
|
+
const lines = splitLines(text);
|
|
470
568
|
const lastLine = lines[lines.length - 1] ?? '';
|
|
471
569
|
return {
|
|
472
570
|
body: [],
|
|
@@ -15096,57 +15194,6 @@ function getClassMemberName(member) {
|
|
|
15096
15194
|
: getStaticPropertyName(member.key);
|
|
15097
15195
|
}
|
|
15098
15196
|
|
|
15099
|
-
function isSingleLineNode(node) {
|
|
15100
|
-
return node.loc.start.line === node.loc.end.line;
|
|
15101
|
-
}
|
|
15102
|
-
function hasCommentLikeText(text) {
|
|
15103
|
-
return text.includes('//') || text.includes('/*');
|
|
15104
|
-
}
|
|
15105
|
-
function hasBlankLine(text) {
|
|
15106
|
-
let lineBreaks = 0;
|
|
15107
|
-
for (let index = 0; index < text.length; index++) {
|
|
15108
|
-
const char = text[index];
|
|
15109
|
-
if (char === '\n') {
|
|
15110
|
-
lineBreaks++;
|
|
15111
|
-
}
|
|
15112
|
-
else if (char === '\r') {
|
|
15113
|
-
lineBreaks++;
|
|
15114
|
-
if (text[index + 1] === '\n') {
|
|
15115
|
-
index++;
|
|
15116
|
-
}
|
|
15117
|
-
}
|
|
15118
|
-
if (lineBreaks > 1) {
|
|
15119
|
-
return true;
|
|
15120
|
-
}
|
|
15121
|
-
}
|
|
15122
|
-
return false;
|
|
15123
|
-
}
|
|
15124
|
-
function getLineBreak(text) {
|
|
15125
|
-
if (text.includes('\r\n')) {
|
|
15126
|
-
return '\r\n';
|
|
15127
|
-
}
|
|
15128
|
-
return text.includes('\r') ? '\r' : '\n';
|
|
15129
|
-
}
|
|
15130
|
-
function getLeadingIndentation(text) {
|
|
15131
|
-
let index = 0;
|
|
15132
|
-
while (index < text.length && (text[index] === ' ' || text[index] === '\t')) {
|
|
15133
|
-
index++;
|
|
15134
|
-
}
|
|
15135
|
-
return text.slice(0, index);
|
|
15136
|
-
}
|
|
15137
|
-
function getLineStartOffset(text, offset) {
|
|
15138
|
-
return text.lastIndexOf('\n', offset - 1) + 1;
|
|
15139
|
-
}
|
|
15140
|
-
function getIndentAtOffset(text, offset) {
|
|
15141
|
-
const lineStart = getLineStartOffset(text, offset);
|
|
15142
|
-
const indent = text.slice(lineStart, offset);
|
|
15143
|
-
return indent.trim() === '' ? indent : '';
|
|
15144
|
-
}
|
|
15145
|
-
function getSpacingReplacement(sourceCode, betweenText, nextLine, blankLineCount) {
|
|
15146
|
-
const indentation = getLeadingIndentation(sourceCode.lines[nextLine - 1] ?? '');
|
|
15147
|
-
return `${getLineBreak(betweenText).repeat(blankLineCount + 1)}${indentation}`;
|
|
15148
|
-
}
|
|
15149
|
-
|
|
15150
15197
|
const RULE_DOCS_BASE_URL = 'https://github.com/taiga-family/toolkit/tree/main/projects/eslint-plugin-experience-next/docs';
|
|
15151
15198
|
const ruleCreator = dist$4.ESLintUtils.RuleCreator((name) => `${RULE_DOCS_BASE_URL}/${name}.md`);
|
|
15152
15199
|
function createRule(options) {
|
|
@@ -248017,13 +248064,14 @@ function buildMultilineStartTag(node, sourceText) {
|
|
|
248017
248064
|
const closing = sourceText
|
|
248018
248065
|
.slice(lastAttr ? lastAttr.sourceSpan.end.offset : startTag.end.offset, startTag.end.offset)
|
|
248019
248066
|
.trimStart();
|
|
248067
|
+
const lineBreak = getLineBreak(sourceText);
|
|
248020
248068
|
return [
|
|
248021
248069
|
tagStart.trimEnd(),
|
|
248022
248070
|
...attrs.map((attr) => sourceText
|
|
248023
248071
|
.slice(attr.sourceSpan.start.offset, attr.sourceSpan.end.offset)
|
|
248024
248072
|
.trim()),
|
|
248025
248073
|
closing,
|
|
248026
|
-
].join(
|
|
248074
|
+
].join(lineBreak);
|
|
248027
248075
|
}
|
|
248028
248076
|
const rule$W = createRule({
|
|
248029
248077
|
name: 'attrs-newline',
|
|
@@ -248301,6 +248349,7 @@ const rule$U = createRule({
|
|
|
248301
248349
|
name: 'element-newline',
|
|
248302
248350
|
rule: {
|
|
248303
248351
|
create(context) {
|
|
248352
|
+
const lineBreak = getLineBreak(context.sourceCode.getText());
|
|
248304
248353
|
return {
|
|
248305
248354
|
Element(rawNode) {
|
|
248306
248355
|
const node = rawNode;
|
|
@@ -248321,7 +248370,7 @@ const rule$U = createRule({
|
|
|
248321
248370
|
fix: (fixer) => fixer.insertTextBeforeRange([
|
|
248322
248371
|
firstChild.sourceSpan.start.offset,
|
|
248323
248372
|
firstChild.sourceSpan.start.offset,
|
|
248324
|
-
],
|
|
248373
|
+
], lineBreak),
|
|
248325
248374
|
loc: sourceSpanToLoc(firstChild.sourceSpan),
|
|
248326
248375
|
messageId: MESSAGE_ID$i,
|
|
248327
248376
|
});
|
|
@@ -248339,7 +248388,7 @@ const rule$U = createRule({
|
|
|
248339
248388
|
fix: (fixer) => fixer.insertTextAfterRange([
|
|
248340
248389
|
child.sourceSpan.end.offset,
|
|
248341
248390
|
child.sourceSpan.end.offset,
|
|
248342
|
-
],
|
|
248391
|
+
], lineBreak),
|
|
248343
248392
|
loc: sourceSpanToLoc(next.sourceSpan),
|
|
248344
248393
|
messageId: MESSAGE_ID$i,
|
|
248345
248394
|
});
|
|
@@ -248353,7 +248402,7 @@ const rule$U = createRule({
|
|
|
248353
248402
|
fix: (fixer) => fixer.insertTextAfterRange([
|
|
248354
248403
|
lastChild.sourceSpan.end.offset,
|
|
248355
248404
|
lastChild.sourceSpan.end.offset,
|
|
248356
|
-
],
|
|
248405
|
+
], lineBreak),
|
|
248357
248406
|
loc: sourceSpanToLoc(lastChild.sourceSpan),
|
|
248358
248407
|
messageId: MESSAGE_ID$i,
|
|
248359
248408
|
});
|
|
@@ -248644,19 +248693,21 @@ function getAttachedComments(hostObject, properties, sourceCode, comments) {
|
|
|
248644
248693
|
return usedComments.size === comments.length ? attached : null;
|
|
248645
248694
|
}
|
|
248646
248695
|
function renderFixWithComments(hostObject, sortedProperties, sourceCode, attachedComments) {
|
|
248696
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
248647
248697
|
const objectIndentation = getLineIndentation(sourceCode.text, hostObject.range[0]);
|
|
248648
248698
|
const propertyIndentation = getPropertyIndentation(hostObject, sortedProperties, sourceCode.text, attachedComments);
|
|
248649
|
-
return `{
|
|
248699
|
+
return `{${lineBreak}${sortedProperties
|
|
248650
248700
|
.map(({ node }, index) => renderPropertyWithComments(node, attachedComments.get(node), sourceCode, propertyIndentation, index === sortedProperties.length - 1))
|
|
248651
|
-
.join(
|
|
248701
|
+
.join(lineBreak)}${lineBreak}${objectIndentation}}`;
|
|
248652
248702
|
}
|
|
248653
248703
|
function renderPropertyWithComments(property, attachedComments, sourceCode, propertyIndentation, isLast) {
|
|
248704
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
248654
248705
|
const lines = attachedComments?.leading.map((comment) => `${propertyIndentation}${sourceCode.text.slice(...comment.range)}`) ?? [];
|
|
248655
248706
|
const trailingComment = attachedComments?.trailing
|
|
248656
248707
|
? ` ${sourceCode.text.slice(...attachedComments.trailing.range)}`
|
|
248657
248708
|
: '';
|
|
248658
248709
|
lines.push(`${propertyIndentation}${sourceCode.getText(property)}${isLast ? '' : ','}${trailingComment}`);
|
|
248659
|
-
return lines.join(
|
|
248710
|
+
return lines.join(lineBreak);
|
|
248660
248711
|
}
|
|
248661
248712
|
function getPropertyIndentation(hostObject, properties, sourceText, attachedComments) {
|
|
248662
248713
|
for (const { node } of properties) {
|
|
@@ -248670,9 +248721,7 @@ function getPropertyIndentation(hostObject, properties, sourceText, attachedComm
|
|
|
248670
248721
|
}
|
|
248671
248722
|
function getLineIndentation(sourceText, offset) {
|
|
248672
248723
|
let lineStart = offset;
|
|
248673
|
-
while (lineStart > 0 &&
|
|
248674
|
-
sourceText[lineStart - 1] !== '\n' &&
|
|
248675
|
-
sourceText[lineStart - 1] !== '\r') {
|
|
248724
|
+
while (lineStart > 0 && !isLineBreakCharacter(sourceText[lineStart - 1])) {
|
|
248676
248725
|
lineStart--;
|
|
248677
248726
|
}
|
|
248678
248727
|
let indentationEnd = lineStart;
|
|
@@ -249382,11 +249431,15 @@ const rule$R = createRule({
|
|
|
249382
249431
|
}
|
|
249383
249432
|
function buildImportRemovalFix(fixer, node) {
|
|
249384
249433
|
const [start, end] = node.range;
|
|
249385
|
-
const lineStart = sourceCode.text
|
|
249434
|
+
const lineStart = getLineStartOffset(sourceCode.text, start);
|
|
249386
249435
|
const removeStart = /^\s*$/.test(sourceCode.text.slice(lineStart, start))
|
|
249387
249436
|
? lineStart
|
|
249388
249437
|
: start;
|
|
249389
|
-
const
|
|
249438
|
+
const lineEnd = getLineEndOffset(sourceCode.text, end);
|
|
249439
|
+
const isImportLastStatementOnLine = sourceCode.text.slice(end, lineEnd).trim() === '';
|
|
249440
|
+
const removeEnd = isImportLastStatementOnLine
|
|
249441
|
+
? getNextLineStartOffset(sourceCode.text, end)
|
|
249442
|
+
: end;
|
|
249390
249443
|
return [fixer.removeRange([removeStart, removeEnd])];
|
|
249391
249444
|
}
|
|
249392
249445
|
function buildDuplicateImportFix(fixer, first, rest) {
|
|
@@ -249700,7 +249753,7 @@ const rule$R = createRule({
|
|
|
249700
249753
|
const relPath = computeRelativeImportPath(context.filename, sourceFilePath);
|
|
249701
249754
|
newImports.push(`${importPrefix} {${names.join(', ')}} from ${quote}${relPath}${quote}${semi}`);
|
|
249702
249755
|
}
|
|
249703
|
-
return newImports.join(
|
|
249756
|
+
return newImports.join(getLineBreak(sourceCode.text));
|
|
249704
249757
|
}
|
|
249705
249758
|
function checkDefaultImport(node) {
|
|
249706
249759
|
if ((!checkDefaultImports &&
|
|
@@ -250050,17 +250103,18 @@ function getDescriptionNode(node) {
|
|
|
250050
250103
|
function prependTokenName(text, name) {
|
|
250051
250104
|
return `${text.slice(0, 1)}[${name}]: ${text.slice(1)}`;
|
|
250052
250105
|
}
|
|
250053
|
-
function getNgDevModeDeclarationFix(program, fixer) {
|
|
250106
|
+
function getNgDevModeDeclarationFix(program, fixer, sourceCode) {
|
|
250054
250107
|
const lastImport = [...program.body]
|
|
250055
250108
|
.reverse()
|
|
250056
250109
|
.find((statement) => statement.type === dist$3.AST_NODE_TYPES.ImportDeclaration);
|
|
250110
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
250057
250111
|
if (lastImport) {
|
|
250058
|
-
return fixer.insertTextAfter(lastImport,
|
|
250112
|
+
return fixer.insertTextAfter(lastImport, `${lineBreak}${lineBreak}declare const ngDevMode: boolean;`);
|
|
250059
250113
|
}
|
|
250060
250114
|
const [firstStatement] = program.body;
|
|
250061
250115
|
return firstStatement
|
|
250062
|
-
? fixer.insertTextBefore(firstStatement,
|
|
250063
|
-
: fixer.insertTextBeforeRange([0, 0],
|
|
250116
|
+
? fixer.insertTextBefore(firstStatement, `declare const ngDevMode: boolean;${lineBreak}${lineBreak}`)
|
|
250117
|
+
: fixer.insertTextBeforeRange([0, 0], `declare const ngDevMode: boolean;${lineBreak}`);
|
|
250064
250118
|
}
|
|
250065
250119
|
const rule$Q = createRule({
|
|
250066
250120
|
create(context) {
|
|
@@ -250090,7 +250144,7 @@ const rule$Q = createRule({
|
|
|
250090
250144
|
shouldAddNgDevModeDeclaration &&
|
|
250091
250145
|
!hasVariableInScope(sourceCode, description, NG_DEV_MODE)) {
|
|
250092
250146
|
shouldAddNgDevModeDeclaration = false;
|
|
250093
|
-
fixes.unshift(getNgDevModeDeclarationFix(program, fixer));
|
|
250147
|
+
fixes.unshift(getNgDevModeDeclarationFix(program, fixer, sourceCode));
|
|
250094
250148
|
}
|
|
250095
250149
|
return fixes;
|
|
250096
250150
|
},
|
|
@@ -250708,11 +250762,10 @@ function getSinglePropertyRange(text, property) {
|
|
|
250708
250762
|
: [property.range[0], property.range[1]];
|
|
250709
250763
|
}
|
|
250710
250764
|
function getLineStart(text, index) {
|
|
250711
|
-
return text
|
|
250765
|
+
return getLineStartOffset(text, index);
|
|
250712
250766
|
}
|
|
250713
250767
|
function getNextLineStart(text, index) {
|
|
250714
|
-
|
|
250715
|
-
return lineEnd === -1 ? index : lineEnd + 1;
|
|
250768
|
+
return getNextLineStartOffset(text, index);
|
|
250716
250769
|
}
|
|
250717
250770
|
function hasCommentsInRange(sourceCode, [start, end]) {
|
|
250718
250771
|
return sourceCode
|
|
@@ -251322,7 +251375,7 @@ const rule$D = createRule({
|
|
|
251322
251375
|
return {
|
|
251323
251376
|
Program(node) {
|
|
251324
251377
|
const text = context.sourceCode.getText(node);
|
|
251325
|
-
const lines = text
|
|
251378
|
+
const lines = splitLines(text);
|
|
251326
251379
|
for (const [index, line] of lines.entries()) {
|
|
251327
251380
|
const trimmed = line.trim();
|
|
251328
251381
|
if (!trimmed || trimmed.startsWith('#') || trimmed.startsWith(';')) {
|
|
@@ -251664,11 +251717,12 @@ const rule$B = createRule({
|
|
|
251664
251717
|
return null;
|
|
251665
251718
|
}
|
|
251666
251719
|
const indent = getIndentAtOffset(sourceCode.text, insertOffset);
|
|
251720
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
251667
251721
|
const declarations = result.lets
|
|
251668
251722
|
.map(({ expression, name }, index) => `${index === 0 ? '' : indent}@let ${name} = ${expression};`)
|
|
251669
|
-
.join(
|
|
251723
|
+
.join(lineBreak);
|
|
251670
251724
|
return [
|
|
251671
|
-
fixer.insertTextBeforeRange([insertOffset, insertOffset], `${declarations}
|
|
251725
|
+
fixer.insertTextBeforeRange([insertOffset, insertOffset], `${declarations}${lineBreak}${indent}`),
|
|
251672
251726
|
fixer.replaceTextRange([node.sourceSpan.start, node.sourceSpan.end], result.reference),
|
|
251673
251727
|
];
|
|
251674
251728
|
},
|
|
@@ -252664,10 +252718,11 @@ const rule$v = createRule({
|
|
|
252664
252718
|
fix(fixer) {
|
|
252665
252719
|
const varName = getCalleeName(firstCall);
|
|
252666
252720
|
const parentStatement = findParentStatement(node);
|
|
252721
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
252667
252722
|
if (parentStatement) {
|
|
252668
252723
|
const indent = getStatementIndent$1(parentStatement, sourceCode.text);
|
|
252669
252724
|
const fixes = [
|
|
252670
|
-
fixer.insertTextBefore(parentStatement, `const ${varName} = ${callText}
|
|
252725
|
+
fixer.insertTextBefore(parentStatement, `const ${varName} = ${callText};${lineBreak}${lineBreak}${indent}`),
|
|
252671
252726
|
];
|
|
252672
252727
|
for (const call of calls) {
|
|
252673
252728
|
fixes.push(fixer.replaceText(getTargetNode(call), varName));
|
|
@@ -252694,7 +252749,7 @@ const rule$v = createRule({
|
|
|
252694
252749
|
lastIndex = end;
|
|
252695
252750
|
}
|
|
252696
252751
|
replacedBody += bodyText.slice(lastIndex);
|
|
252697
|
-
const newBody = `{
|
|
252752
|
+
const newBody = `{${lineBreak}${innerIndent}const ${varName} = ${callText};${lineBreak}${lineBreak}${innerIndent}return ${replacedBody};${lineBreak}${outerIndent}}`;
|
|
252698
252753
|
const bodyRangeStart = arrowBody.range[0];
|
|
252699
252754
|
const textBeforeBody = sourceCode.text.slice(0, bodyRangeStart);
|
|
252700
252755
|
const whitespaceBeforeBody = /\s*$/.exec(textBeforeBody)?.[0] ?? '';
|
|
@@ -253146,6 +253201,10 @@ const rule$s = createUntrackedRule({
|
|
|
253146
253201
|
name: 'no-signal-reads-after-await-in-reactive-context',
|
|
253147
253202
|
});
|
|
253148
253203
|
|
|
253204
|
+
const CARRIAGE_RETURN = String.fromCharCode(13);
|
|
253205
|
+
const LINE_FEED = String.fromCharCode(10);
|
|
253206
|
+
const ESCAPED_CARRIAGE_RETURN = String.fromCharCode(92, 114);
|
|
253207
|
+
const ESCAPED_LINE_FEED = String.fromCharCode(92, 110);
|
|
253149
253208
|
function collectParts(node) {
|
|
253150
253209
|
return node.type === dist$4.AST_NODE_TYPES.BinaryExpression && node.operator === '+'
|
|
253151
253210
|
? [...collectParts(node.left), ...collectParts(node.right)]
|
|
@@ -253165,8 +253224,8 @@ function buildMergedString(parts) {
|
|
|
253165
253224
|
const quote = combined.includes("'") && !combined.includes('"') ? '"' : "'";
|
|
253166
253225
|
const escaped = combined
|
|
253167
253226
|
.replaceAll('\\', '\\\\')
|
|
253168
|
-
.replaceAll(
|
|
253169
|
-
.replaceAll(
|
|
253227
|
+
.replaceAll(CARRIAGE_RETURN, ESCAPED_CARRIAGE_RETURN)
|
|
253228
|
+
.replaceAll(LINE_FEED, ESCAPED_LINE_FEED)
|
|
253170
253229
|
.replaceAll('\t', String.raw `\t`)
|
|
253171
253230
|
.replaceAll(new RegExp(quote, 'g'), `\\${quote}`);
|
|
253172
253231
|
return `${quote}${escaped}${quote}`;
|
|
@@ -253300,13 +253359,14 @@ function findUntrackedAlias(program) {
|
|
|
253300
253359
|
* Builds fixer actions that add `untracked` to an existing `@angular/core` import,
|
|
253301
253360
|
* or insert a new import declaration when none exists.
|
|
253302
253361
|
*/
|
|
253303
|
-
function buildUntrackedImportFixes(program, fixer) {
|
|
253362
|
+
function buildUntrackedImportFixes(program, fixer, sourceCode) {
|
|
253304
253363
|
const coreImport = findRuntimeAngularCoreImport(program);
|
|
253364
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
253305
253365
|
if (!coreImport) {
|
|
253306
253366
|
const firstStatement = program.body[0];
|
|
253307
253367
|
return firstStatement
|
|
253308
253368
|
? [
|
|
253309
|
-
fixer.insertTextBefore(firstStatement,
|
|
253369
|
+
fixer.insertTextBefore(firstStatement, `import { untracked } from '@angular/core';${lineBreak}`),
|
|
253310
253370
|
]
|
|
253311
253371
|
: [];
|
|
253312
253372
|
}
|
|
@@ -253321,7 +253381,7 @@ function buildUntrackedImportFixes(program, fixer) {
|
|
|
253321
253381
|
return defaultImport
|
|
253322
253382
|
? [fixer.insertTextAfter(defaultImport, ', { untracked }')]
|
|
253323
253383
|
: [
|
|
253324
|
-
fixer.insertTextAfter(coreImport,
|
|
253384
|
+
fixer.insertTextAfter(coreImport, `${lineBreak}import { untracked } from '@angular/core';`),
|
|
253325
253385
|
];
|
|
253326
253386
|
}
|
|
253327
253387
|
/**
|
|
@@ -253411,10 +253471,9 @@ function dedent(text, extraSpaces) {
|
|
|
253411
253471
|
return text;
|
|
253412
253472
|
}
|
|
253413
253473
|
const prefix = ' '.repeat(extraSpaces);
|
|
253414
|
-
return text
|
|
253415
|
-
.split('\n')
|
|
253474
|
+
return splitLines(text)
|
|
253416
253475
|
.map((line) => (line.startsWith(prefix) ? line.slice(extraSpaces) : line))
|
|
253417
|
-
.join(
|
|
253476
|
+
.join(getLineBreak(text));
|
|
253418
253477
|
}
|
|
253419
253478
|
|
|
253420
253479
|
function isDirectCallOrNewArgument(node) {
|
|
@@ -253617,7 +253676,8 @@ function buildReplacement(untrackedCall, parentStatement, sourceCode) {
|
|
|
253617
253676
|
const firstStmtColumn = firstStmt.loc.start.column;
|
|
253618
253677
|
const extra = firstStmtColumn - parentColumn;
|
|
253619
253678
|
const indented = stmts.map((s) => dedent(sourceCode.getText(s), extra));
|
|
253620
|
-
|
|
253679
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
253680
|
+
return indented.join(`${lineBreak}${''.padStart(parentColumn)}`);
|
|
253621
253681
|
}
|
|
253622
253682
|
// Expression body: arrow `() => expr` — just emit `expr;`
|
|
253623
253683
|
return `${sourceCode.getText(body)};`;
|
|
@@ -253728,14 +253788,7 @@ const rule$p = createUntrackedRule({
|
|
|
253728
253788
|
const rule$o = createRule({
|
|
253729
253789
|
create(context, [{ printWidth }]) {
|
|
253730
253790
|
const sourceCode = context.sourceCode;
|
|
253731
|
-
const getLineEndIndex = (lineStartIndex) =>
|
|
253732
|
-
const text = sourceCode.text;
|
|
253733
|
-
const newLineIndex = text.indexOf('\n', lineStartIndex);
|
|
253734
|
-
const rawEndIndex = newLineIndex === -1 ? text.length : newLineIndex;
|
|
253735
|
-
return rawEndIndex > lineStartIndex && text[rawEndIndex - 1] === '\r'
|
|
253736
|
-
? rawEndIndex - 1
|
|
253737
|
-
: rawEndIndex;
|
|
253738
|
-
};
|
|
253791
|
+
const getLineEndIndex = (lineStartIndex) => getLineEndOffset(sourceCode.text, lineStartIndex);
|
|
253739
253792
|
const hasAnyCommentsInside = (node) => sourceCode.getCommentsInside(node).length > 0;
|
|
253740
253793
|
const isTemplateLikeExpression = (expression) => expression.type === dist$3.AST_NODE_TYPES.TemplateLiteral ||
|
|
253741
253794
|
expression.type === dist$3.AST_NODE_TYPES.TaggedTemplateExpression;
|
|
@@ -253847,7 +253900,7 @@ const rule$o = createRule({
|
|
|
253847
253900
|
if (inner.type === dist$3.AST_NODE_TYPES.ObjectExpression &&
|
|
253848
253901
|
canInlineObjectExpression(inner)) {
|
|
253849
253902
|
const innerText = sourceCode.getText(inner);
|
|
253850
|
-
return innerText
|
|
253903
|
+
return hasLineBreak(innerText);
|
|
253851
253904
|
}
|
|
253852
253905
|
}
|
|
253853
253906
|
if (value.type === dist$3.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
@@ -253859,7 +253912,7 @@ const rule$o = createRule({
|
|
|
253859
253912
|
if (inner.type === dist$3.AST_NODE_TYPES.ObjectExpression &&
|
|
253860
253913
|
canInlineObjectExpression(inner)) {
|
|
253861
253914
|
const innerText = sourceCode.getText(inner);
|
|
253862
|
-
return innerText
|
|
253915
|
+
return hasLineBreak(innerText);
|
|
253863
253916
|
}
|
|
253864
253917
|
}
|
|
253865
253918
|
}
|
|
@@ -253868,7 +253921,7 @@ const rule$o = createRule({
|
|
|
253868
253921
|
if (bodyExpr.type === dist$3.AST_NODE_TYPES.ObjectExpression &&
|
|
253869
253922
|
canInlineObjectExpression(bodyExpr)) {
|
|
253870
253923
|
const innerText = sourceCode.getText(bodyExpr);
|
|
253871
|
-
return innerText
|
|
253924
|
+
return hasLineBreak(innerText);
|
|
253872
253925
|
}
|
|
253873
253926
|
}
|
|
253874
253927
|
}
|
|
@@ -253932,7 +253985,7 @@ const rule$o = createRule({
|
|
|
253932
253985
|
ObjectExpression(node) {
|
|
253933
253986
|
const originalText = sourceCode.getText(node);
|
|
253934
253987
|
if (!canInlineObjectExpression(node) ||
|
|
253935
|
-
!originalText
|
|
253988
|
+
!hasLineBreak(originalText) ||
|
|
253936
253989
|
hasPendingInnerInlineCandidate(node) ||
|
|
253937
253990
|
hasArrowReturningMultiPropObject(node)) {
|
|
253938
253991
|
return;
|
|
@@ -254306,35 +254359,37 @@ function renderConditionalReturn(ifStatement, consequentExpression, alternateExp
|
|
|
254306
254359
|
return inlineReturn;
|
|
254307
254360
|
}
|
|
254308
254361
|
const branchIndent = `${indent} `;
|
|
254309
|
-
|
|
254362
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
254363
|
+
return `return ${test}${lineBreak}${branchIndent}? ${consequent}${lineBreak}${branchIndent}: ${alternate};`;
|
|
254310
254364
|
}
|
|
254311
254365
|
function renderBooleanTestReturn(ifStatement, sourceCode, strategy) {
|
|
254312
254366
|
const test = sourceCode.getText(ifStatement.test);
|
|
254367
|
+
const lineBreak = getLineBreak(sourceCode.text);
|
|
254313
254368
|
if (strategy === 'negate') {
|
|
254314
|
-
if (!test
|
|
254369
|
+
if (!hasLineBreak(test)) {
|
|
254315
254370
|
const renderedTest = needsParenthesesInBooleanCoercion(ifStatement.test)
|
|
254316
254371
|
? `(${test})`
|
|
254317
254372
|
: test;
|
|
254318
254373
|
return `return !${renderedTest};`;
|
|
254319
254374
|
}
|
|
254320
254375
|
const indent = getStatementIndent(ifStatement, sourceCode);
|
|
254321
|
-
return `return !(
|
|
254376
|
+
return `return !(${lineBreak}${indent} ${test}${lineBreak}${indent});`;
|
|
254322
254377
|
}
|
|
254323
254378
|
if (strategy === 'coerce') {
|
|
254324
|
-
if (!test
|
|
254379
|
+
if (!hasLineBreak(test)) {
|
|
254325
254380
|
const renderedTest = needsParenthesesInBooleanCoercion(ifStatement.test)
|
|
254326
254381
|
? `(${test})`
|
|
254327
254382
|
: test;
|
|
254328
254383
|
return `return !!${renderedTest};`;
|
|
254329
254384
|
}
|
|
254330
254385
|
const indent = getStatementIndent(ifStatement, sourceCode);
|
|
254331
|
-
return `return !!(
|
|
254386
|
+
return `return !!(${lineBreak}${indent} ${test}${lineBreak}${indent});`;
|
|
254332
254387
|
}
|
|
254333
|
-
if (!test
|
|
254388
|
+
if (!hasLineBreak(test)) {
|
|
254334
254389
|
return `return ${test};`;
|
|
254335
254390
|
}
|
|
254336
254391
|
const indent = getStatementIndent(ifStatement, sourceCode);
|
|
254337
|
-
return `return (
|
|
254392
|
+
return `return (${lineBreak}${indent} ${test}${lineBreak}${indent});`;
|
|
254338
254393
|
}
|
|
254339
254394
|
const rule$m = createRule({
|
|
254340
254395
|
create(context) {
|
|
@@ -254912,7 +254967,7 @@ const rule$i = createUntrackedRule({
|
|
|
254912
254967
|
? (fixer) => [fixer.replaceText(read, wrapped)]
|
|
254913
254968
|
: (fixer) => [
|
|
254914
254969
|
fixer.replaceText(read, wrapped),
|
|
254915
|
-
...buildUntrackedImportFixes(program, fixer),
|
|
254970
|
+
...buildUntrackedImportFixes(program, fixer, sourceCode),
|
|
254916
254971
|
];
|
|
254917
254972
|
}
|
|
254918
254973
|
return {
|
|
@@ -255051,8 +255106,7 @@ const rule$g = createRule({
|
|
|
255051
255106
|
let openQuoteOffset = valueSpan.start.offset - 1;
|
|
255052
255107
|
while (openQuoteOffset >= 0 &&
|
|
255053
255108
|
(sourceText[openQuoteOffset] === ' ' ||
|
|
255054
|
-
sourceText[openQuoteOffset]
|
|
255055
|
-
sourceText[openQuoteOffset] === '\r' ||
|
|
255109
|
+
isLineBreakCharacter(sourceText[openQuoteOffset]) ||
|
|
255056
255110
|
sourceText[openQuoteOffset] === '\t')) {
|
|
255057
255111
|
openQuoteOffset--;
|
|
255058
255112
|
}
|
|
@@ -255063,8 +255117,7 @@ const rule$g = createRule({
|
|
|
255063
255117
|
if (isQuotedAttribute) {
|
|
255064
255118
|
while (closeQuoteOffset < sourceText.length &&
|
|
255065
255119
|
(sourceText[closeQuoteOffset] === ' ' ||
|
|
255066
|
-
sourceText[closeQuoteOffset]
|
|
255067
|
-
sourceText[closeQuoteOffset] === '\r' ||
|
|
255120
|
+
isLineBreakCharacter(sourceText[closeQuoteOffset]) ||
|
|
255068
255121
|
sourceText[closeQuoteOffset] === '\t')) {
|
|
255069
255122
|
closeQuoteOffset++;
|
|
255070
255123
|
}
|
|
@@ -255121,6 +255174,7 @@ const rule$f = createRule({
|
|
|
255121
255174
|
rule: {
|
|
255122
255175
|
create(context) {
|
|
255123
255176
|
const sourceText = context.sourceCode.getText();
|
|
255177
|
+
const lineBreak = getLineBreak(sourceText);
|
|
255124
255178
|
let reported = false;
|
|
255125
255179
|
return {
|
|
255126
255180
|
Element(rawNode) {
|
|
@@ -255132,7 +255186,7 @@ const rule$f = createRule({
|
|
|
255132
255186
|
}
|
|
255133
255187
|
reported = true;
|
|
255134
255188
|
context.report({
|
|
255135
|
-
fix: (fixer) => fixer.insertTextBeforeRange([0, 0],
|
|
255189
|
+
fix: (fixer) => fixer.insertTextBeforeRange([0, 0], `<!DOCTYPE html>${lineBreak}`),
|
|
255136
255190
|
loc: sourceSpanToLoc(node.startSourceSpan),
|
|
255137
255191
|
messageId: MESSAGE_ID$6,
|
|
255138
255192
|
});
|
|
@@ -256766,7 +256820,7 @@ function buildRewrittenImports({ baseImportPath, node, state, symbolToEntryPoint
|
|
|
256766
256820
|
if (remainingImportStatement) {
|
|
256767
256821
|
importStatements.push(remainingImportStatement);
|
|
256768
256822
|
}
|
|
256769
|
-
return importStatements.join(
|
|
256823
|
+
return importStatements.join(getLineBreak(state.sourceCode.text));
|
|
256770
256824
|
}
|
|
256771
256825
|
function buildNamedImportStatement({ importKind, importPath, specifiers, state, }) {
|
|
256772
256826
|
const importKeyword = importKind === 'type' ? 'import type' : 'import';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taiga-ui/eslint-plugin-experience-next",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.527.0",
|
|
4
4
|
"description": "An ESLint plugin to enforce a consistent code styles across taiga-ui projects",
|
|
5
5
|
"homepage": "https://github.com/taiga-family/toolkit#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
"eslint-plugin-unicorn": "64.0.0",
|
|
55
55
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
56
56
|
"globals": "17.6.0",
|
|
57
|
-
"typescript-eslint": "8.59.
|
|
57
|
+
"typescript-eslint": "8.59.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@typescript-eslint/rule-tester": "8.59.
|
|
60
|
+
"@typescript-eslint/rule-tester": "8.59.2"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"eslint": "^9.39.4"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const rule: TSESLint.RuleModule<"invalid-injection-token-description", readonly unknown[], unknown, TSESLint.RuleListener> & {
|
|
2
3
|
name: string;
|
|
3
4
|
};
|
|
4
5
|
export default rule;
|
|
@@ -6,7 +6,7 @@ export declare function findUntrackedAlias(program: TSESTree.Program): string |
|
|
|
6
6
|
* Builds fixer actions that add `untracked` to an existing `@angular/core` import,
|
|
7
7
|
* or insert a new import declaration when none exists.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildUntrackedImportFixes(program: TSESTree.Program, fixer: RuleFixer): Array<ReturnType<RuleFixer['insertTextBefore']>>;
|
|
9
|
+
export declare function buildUntrackedImportFixes(program: TSESTree.Program, fixer: RuleFixer, sourceCode: SourceCode): Array<ReturnType<RuleFixer['insertTextBefore']>>;
|
|
10
10
|
/**
|
|
11
11
|
* Removes the `untracked` import specifier from `@angular/core`.
|
|
12
12
|
* When it is the last specifier, removes the entire declaration.
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { type TSESLint, type TSESTree } from '@typescript-eslint/utils';
|
|
2
2
|
export declare function isSingleLineNode(node: TSESTree.Node): boolean;
|
|
3
|
+
export declare function isLineBreakCharacter(char: string | undefined): boolean;
|
|
3
4
|
export declare function hasCommentLikeText(text: string): boolean;
|
|
4
5
|
export declare function hasBlankLine(text: string): boolean;
|
|
5
6
|
export declare function getLineBreak(text: string): string;
|
|
7
|
+
export declare function hasLineBreak(text: string): boolean;
|
|
6
8
|
export declare function getLeadingIndentation(text: string): string;
|
|
7
9
|
export declare function getLineStartOffset(text: string, offset: number): number;
|
|
10
|
+
export declare function getLineEndOffset(text: string, lineStartOffset: number): number;
|
|
11
|
+
export declare function getNextLineStartOffset(text: string, offset: number): number;
|
|
12
|
+
export declare function splitLines(text: string): string[];
|
|
8
13
|
export declare function getIndentAtOffset(text: string, offset: number): string;
|
|
9
14
|
export declare function getSpacingReplacement(sourceCode: Readonly<TSESLint.SourceCode>, betweenText: string, nextLine: number, blankLineCount: number): string;
|