@blumintinc/eslint-plugin-blumint 1.20.62 → 1.20.63
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/lib/index.js
CHANGED
|
@@ -757,6 +757,18 @@ exports.parallelizeAsyncOperations = (0, createRule_1.createRule)({
|
|
|
757
757
|
}
|
|
758
758
|
return false;
|
|
759
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* Returns the leading whitespace of the source line a node starts on.
|
|
762
|
+
*
|
|
763
|
+
* A statement that shares its line with earlier code yields that line's
|
|
764
|
+
* indentation rather than the node's own column, which keeps the generated
|
|
765
|
+
* block aligned with the enclosing statement instead of with an arbitrary
|
|
766
|
+
* mid-line offset.
|
|
767
|
+
*/
|
|
768
|
+
function getIndentationOf(node) {
|
|
769
|
+
const line = sourceCode.lines[node.loc.start.line - 1] ?? '';
|
|
770
|
+
return /^[ \t]*/.exec(line)?.[0] ?? '';
|
|
771
|
+
}
|
|
760
772
|
/**
|
|
761
773
|
* Generates a fix for sequential awaits
|
|
762
774
|
*
|
|
@@ -788,6 +800,24 @@ exports.parallelizeAsyncOperations = (0, createRule_1.createRule)({
|
|
|
788
800
|
idsText.push('');
|
|
789
801
|
}
|
|
790
802
|
}
|
|
803
|
+
// The replacement range starts at the first await's own start offset, so
|
|
804
|
+
// ESLint leaves that line's leading whitespace in place and only the
|
|
805
|
+
// FIRST line inherits the surrounding indentation. Every continuation
|
|
806
|
+
// line the fixer emits has to carry that indentation itself, otherwise
|
|
807
|
+
// the array elements and closing bracket land at column 2 and column 0
|
|
808
|
+
// no matter how deeply the original awaits were nested.
|
|
809
|
+
const baseIndent = getIndentationOf(awaitNodes[0]);
|
|
810
|
+
// Match the file's own indentation character instead of assuming spaces,
|
|
811
|
+
// so a tab-indented file does not end up with mixed tabs and spaces. The
|
|
812
|
+
// space fallback is two wide to match the repo's prettier config.
|
|
813
|
+
const indentUnit = baseIndent.includes('\t') ? '\t' : ' ';
|
|
814
|
+
const elementIndent = `${baseIndent}${indentUnit}`;
|
|
815
|
+
// Arguments are spliced in verbatim: an argument spanning multiple lines
|
|
816
|
+
// keeps its original interior indentation because that interior can be
|
|
817
|
+
// the contents of a template literal, where whitespace is significant
|
|
818
|
+
// data rather than formatting and re-indenting would silently change the
|
|
819
|
+
// produced string.
|
|
820
|
+
const elementsText = awaitArguments.join(`,\n${elementIndent}`);
|
|
791
821
|
let promiseAllText;
|
|
792
822
|
if (hasVariableDeclarations) {
|
|
793
823
|
if (declKinds.size !== 1) {
|
|
@@ -798,11 +828,11 @@ exports.parallelizeAsyncOperations = (0, createRule_1.createRule)({
|
|
|
798
828
|
}
|
|
799
829
|
const destructuringPattern = idsText.join(', ');
|
|
800
830
|
const declKind = Array.from(declKinds)[0];
|
|
801
|
-
promiseAllText = `${declKind} [${destructuringPattern}] = await Promise.all([\n
|
|
831
|
+
promiseAllText = `${declKind} [${destructuringPattern}] = await Promise.all([\n${elementIndent}${elementsText}\n${baseIndent}]);`;
|
|
802
832
|
}
|
|
803
833
|
else {
|
|
804
834
|
// Simple Promise.all without variable assignments
|
|
805
|
-
promiseAllText = `await Promise.all([\n
|
|
835
|
+
promiseAllText = `await Promise.all([\n${elementIndent}${elementsText}\n${baseIndent}]);`;
|
|
806
836
|
}
|
|
807
837
|
const startPos = awaitNodes[0].range[0];
|
|
808
838
|
const endPos = awaitNodes[awaitNodes.length - 1].range[1];
|
package/package.json
CHANGED
package/release-manifest.json
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "1.20.63",
|
|
4
|
+
"date": "2026-08-01T09:37:04.617Z",
|
|
5
|
+
"rules": [
|
|
6
|
+
{
|
|
7
|
+
"name": "parallelize-async-operations",
|
|
8
|
+
"changeType": "fix",
|
|
9
|
+
"issues": [
|
|
10
|
+
1557
|
|
11
|
+
],
|
|
12
|
+
"summary": "indent Promise.all output relative to the replaced statements (closes #1557)"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
2
16
|
{
|
|
3
17
|
"version": "1.20.62",
|
|
4
18
|
"date": "2026-08-01T09:01:13.989Z",
|