Socket
Socket
Sign inDemoInstall

eslint-plugin-simple-import-sort

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-simple-import-sort - npm Package Compare versions

Comparing version 12.0.0 to 12.1.0

index.d.ts

8

exports.js

@@ -41,3 +41,3 @@ "use strict";

for (const chunk of shared.extractChunks(parent, (node, lastNode) =>
isPartOfChunk(node, lastNode, sourceCode)
isPartOfChunk(node, lastNode, sourceCode),
)) {

@@ -59,3 +59,3 @@ maybeReportChunkSorting(chunk, context);

() => false, // isSideEffectImport
getSpecifiers
getSpecifiers,
);

@@ -73,3 +73,3 @@ const sortedItems = [[shared.sortImportExportItems(items)]];

shared.getSourceCode(context),
getSpecifiers
getSpecifiers,
);

@@ -95,3 +95,3 @@ const [start, end] = node.range;

(lastNode == null || comment.loc.start.line > lastNode.loc.end.line) &&
comment.loc.end.line < node.loc.start.line
comment.loc.end.line < node.loc.start.line,
);

@@ -98,0 +98,0 @@

@@ -53,3 +53,3 @@ "use strict";

const outerGroups = rawGroups.map((groups) =>
groups.map((item) => RegExp(item, "u"))
groups.map((item) => RegExp(item, "u")),
);

@@ -67,3 +67,3 @@

for (const chunk of shared.extractChunks(parent, (node) =>
isImport(node) ? "PartOfChunk" : "NotPartOfChunk"
isImport(node) ? "PartOfChunk" : "NotPartOfChunk",
)) {

@@ -85,3 +85,3 @@ maybeReportChunkSorting(chunk, context, outerGroups);

isSideEffectImport,
getSpecifiers
getSpecifiers,
);

@@ -97,3 +97,3 @@ const sortedItems = makeSortedItems(items, outerGroups);

const itemGroups = outerGroups.map((groups) =>
groups.map((regex) => ({ regex, items: [] }))
groups.map((regex) => ({ regex, items: [] })),
);

@@ -107,7 +107,7 @@ const rest = [];

: item.source.kind !== "value"
? `${originalSource}\0`
: originalSource;
? `${originalSource}\0`
: originalSource;
const [matchedGroup] = shared
.flatMap(itemGroups, (groups) =>
groups.map((group) => [group, group.regex.exec(source)])
groups.map((group) => [group, group.regex.exec(source)]),
)

@@ -120,3 +120,3 @@ .reduce(

: [group, longestMatch],
[undefined, undefined]
[undefined, undefined],
);

@@ -135,3 +135,3 @@ if (matchedGroup == null) {

.map((groups) =>
groups.map((group) => shared.sortImportExportItems(group.items))
groups.map((group) => shared.sortImportExportItems(group.items)),
);

@@ -138,0 +138,0 @@ }

@@ -9,3 +9,3 @@ "use strict";

name: "eslint-plugin-simple-import-sort",
version: "12.0.0",
version: "12.1.0",
},

@@ -12,0 +12,0 @@ rules: {

{
"name": "eslint-plugin-simple-import-sort",
"version": "12.0.0",
"version": "12.1.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "author": "Simon Lydell",

@@ -31,5 +31,6 @@ "use strict";

// istanbul ignore next
/* v8 ignore start */
default:
throw new Error(`Unknown chunk result: ${result}`);
/* v8 ignore stop */
}

@@ -69,3 +70,3 @@

.map((groupItems) => groupItems.map((item) => item.code).join(newline))
.join(newline)
.join(newline),
)

@@ -108,3 +109,3 @@ .join(newline + newline);

isSideEffectImport,
getSpecifiers
getSpecifiers,
) {

@@ -131,3 +132,3 @@ const chunk = handleLastSemicolon(passedChunk, sourceCode);

comment.loc.end.line > lastLine &&
(nodeIndex > 0 || comment.loc.start.line > lastLine)
(nodeIndex > 0 || comment.loc.start.line > lastLine),
);

@@ -149,3 +150,3 @@

commentsBefore.length > 0 ? commentsBefore[0] : node,
sourceCode
sourceCode,
);

@@ -158,3 +159,3 @@

commentsAfter.length > 0 ? commentsAfter[commentsAfter.length - 1] : node,
sourceCode
sourceCode,
);

@@ -239,6 +240,6 @@

const openBraceIndex = allTokens.findIndex((token) =>
isPunctuator(token, "{")
isPunctuator(token, "{"),
);
const closeBraceIndex = allTokens.findIndex((token) =>
isPunctuator(token, "}")
isPunctuator(token, "}"),
);

@@ -272,3 +273,3 @@

sourceCode.getTokenBefore(allTokens[closeBraceIndex]),
","
",",
);

@@ -303,3 +304,3 @@

const nonBlankIndex = item.after.findIndex(
(token) => !isNewline(token) && !isSpaces(token)
(token) => !isNewline(token) && !isSpaces(token),
);

@@ -313,4 +314,4 @@

: nonBlankIndex === -1
? []
: item.after.slice(nonBlankIndex);
? []
: item.after.slice(nonBlankIndex);

@@ -403,9 +404,10 @@ return [...maybeNewline, ...item.before, ...item.specifier, ...after];

// There can only be comma punctuators, but future-proof by checking.
// istanbul ignore else
if (isPunctuator(token, ",")) {
current.hadComma = true;
current.state = "after";
/* v8 ignore start */
} else {
current.specifier.push(token);
}
/* v8 ignore stop */
break;

@@ -455,5 +457,6 @@

// istanbul ignore next
/* v8 ignore start */
default:
throw new Error(`Unknown state: ${current.state}`);
/* v8 ignore stop */
}

@@ -481,3 +484,3 @@ }

current.specifier,
(token2) => isIdentifier(token2) || isKeyword(token2)
(token2) => isIdentifier(token2) || isKeyword(token2),
);

@@ -496,3 +499,3 @@

const multilineBlockCommentIndex = after.findIndex(
(token2) => isBlockComment(token2) && hasNewline(token2.code)
(token2) => isBlockComment(token2) && hasNewline(token2.code),
);

@@ -506,9 +509,9 @@

: newlineIndex >= 0
? newlineIndex
: multilineBlockCommentIndex >= 0
? multilineBlockCommentIndex
: // If there are no newlines, move the last whitespace into `result.after`.
endsWithSpaces(after)
? after.length - 1
: -1;
? newlineIndex
: multilineBlockCommentIndex >= 0
? multilineBlockCommentIndex
: // If there are no newlines, move the last whitespace into `result.after`.
endsWithSpaces(after)
? after.length - 1
: -1;

@@ -534,5 +537,6 @@ current.specifier = specifier;

// istanbul ignore next
/* v8 ignore start */
default:
throw new Error(`Unknown state: ${current.state}`);
/* v8 ignore stop */
}

@@ -612,3 +616,3 @@

? { type: "Spaces", code: spacesOrNewline }
: { type: "Newline", code: spacesOrNewline }
: { type: "Newline", code: spacesOrNewline },
)

@@ -647,3 +651,3 @@ // Remove empty spaces since it makes debugging easier.

...parseWhitespace(
sourceCode.text.slice(previous.range[1], comment.range[0])
sourceCode.text.slice(previous.range[1], comment.range[0]),
),

@@ -654,3 +658,3 @@ { ...comment, code: sourceCode.getText(comment) },

...parseWhitespace(
sourceCode.text.slice(last.range[1], nextToken.range[0])
sourceCode.text.slice(last.range[1], nextToken.range[0]),
),

@@ -690,3 +694,3 @@ ];

removeBlankLines(
sourceCode.text.slice(previous.range[1], comment.range[0])
sourceCode.text.slice(previous.range[1], comment.range[0]),
) + sourceCode.getText(comment)

@@ -732,17 +736,17 @@ );

: // If one of the items is a side effect import, move it first.
itemA.isSideEffectImport
? -1
: itemB.isSideEffectImport
? 1
: // Compare the `from` part.
compare(itemA.source.source, itemB.source.source) ||
// The `.source` has been slightly tweaked. To stay fully deterministic,
// also sort on the original value.
compare(itemA.source.originalSource, itemB.source.originalSource) ||
// Then put type imports/exports before regular ones.
compare(itemA.source.kind, itemB.source.kind) ||
// Keep the original order if the sources are the same. It’s not worth
// trying to compare anything else, and you can use `import/no-duplicates`
// to get rid of the problem anyway.
itemA.index - itemB.index
itemA.isSideEffectImport
? -1
: itemB.isSideEffectImport
? 1
: // Compare the `from` part.
compare(itemA.source.source, itemB.source.source) ||
// The `.source` has been slightly tweaked. To stay fully deterministic,
// also sort on the original value.
compare(itemA.source.originalSource, itemB.source.originalSource) ||
// Then put type imports/exports before regular ones.
compare(itemA.source.kind, itemB.source.kind) ||
// Keep the original order if the sources are the same. It’s not worth
// trying to compare anything else, and you can use `import/no-duplicates`
// to get rid of the problem anyway.
itemA.index - itemB.index,
);

@@ -761,3 +765,3 @@ }

(itemA.node.imported || itemA.node.exported).name,
(itemB.node.imported || itemB.node.exported).name
(itemB.node.imported || itemB.node.exported).name,
) ||

@@ -773,3 +777,4 @@ // Then compare by the file-local name.

getImportExportKind(itemA.node),
getImportExportKind(itemB.node)
getImportExportKind(itemB.node),
/* v8 ignore start */
) ||

@@ -779,4 +784,4 @@ // Keep the original order if the names are the same. It’s not worth

// error anyway (but @babel/eslint-parser kind of supports it).
// istanbul ignore next
itemA.index - itemB.index
itemA.index - itemB.index,
/* v8 ignore stop */
);

@@ -846,5 +851,6 @@ }

return "/";
// istanbul ignore next
/* v8 ignore start */
default:
throw new Error(`Unknown source substitution character: ${char}`);
/* v8 ignore stop */
}

@@ -870,5 +876,6 @@ }),

}
/* v8 ignore start */
// There are currently no usages of `findLastIndex` where nothing is found.
// istanbul ignore next
return -1;
/* v8 ignore stop */
}

@@ -884,3 +891,3 @@

// We support both for now.
// istanbul ignore next
/* v8 ignore next */
return context.sourceCode || context.getSourceCode();

@@ -887,0 +894,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc