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 8.0.0 to 10.0.0

46

exports.js

@@ -17,17 +17,35 @@ "use strict";

},
create: (context) => ({
Program: (programNode) => {
const sourceCode = context.getSourceCode();
for (const chunk of shared.extractChunks(programNode, (node, lastNode) =>
isPartOfChunk(node, lastNode, sourceCode)
)) {
maybeReportChunkSorting(chunk, context);
create: (context) => {
const parents = new Set();
const addParent = (node) => {
if (isExportFrom(node)) {
parents.add(node.parent);
}
},
ExportNamedDeclaration: (node) => {
if (node.source == null && node.declaration == null) {
maybeReportExportSpecifierSorting(node, context);
}
},
}),
};
return {
ExportNamedDeclaration: (node) => {
if (node.source == null && node.declaration == null) {
maybeReportExportSpecifierSorting(node, context);
} else {
addParent(node);
}
},
ExportAllDeclaration: addParent,
"Program:exit": () => {
const sourceCode = context.getSourceCode();
for (const parent of parents) {
for (const chunk of shared.extractChunks(parent, (node, lastNode) =>
isPartOfChunk(node, lastNode, sourceCode)
)) {
maybeReportChunkSorting(chunk, context);
}
}
parents.clear();
},
};
},
};

@@ -34,0 +52,0 @@

@@ -51,12 +51,23 @@ "use strict";

const { groups: rawGroups = defaultGroups } = context.options[0] || {};
const outerGroups = rawGroups.map((groups) =>
groups.map((item) => RegExp(item, "u"))
);
const parents = new Set();
return {
Program: (programNode) => {
for (const chunk of shared.extractChunks(programNode, (node) =>
isImport(node) ? "PartOfChunk" : "NotPartOfChunk"
)) {
maybeReportChunkSorting(chunk, context, outerGroups);
ImportDeclaration: (node) => {
parents.add(node.parent);
},
"Program:exit": () => {
for (const parent of parents) {
for (const chunk of shared.extractChunks(parent, (node) =>
isImport(node) ? "PartOfChunk" : "NotPartOfChunk"
)) {
maybeReportChunkSorting(chunk, context, outerGroups);
}
}
parents.clear();
},

@@ -63,0 +74,0 @@ };

{
"name": "eslint-plugin-simple-import-sort",
"version": "8.0.0",
"version": "10.0.0",
"license": "MIT",

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

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

// and whitespace between.
function extractChunks(programNode, isPartOfChunk) {
function extractChunks(parentNode, isPartOfChunk) {
const chunks = [];

@@ -11,3 +11,3 @@ let chunk = [];

for (const node of programNode.body) {
for (const node of parentNode.body) {
const result = isPartOfChunk(node, lastNode);

@@ -735,8 +735,3 @@ switch (result) {

(itemA, itemB) =>
// Put type imports/exports before regular ones.
compare(
getImportExportKind(itemA.node),
getImportExportKind(itemB.node)
) ||
// Then compare by imported or exported name (external interface name).
// Compare by imported or exported name (external interface name).
// import { a as b } from "a"

@@ -756,2 +751,7 @@ // ^

compare(itemA.node.local.name, itemB.node.local.name) ||
// Then put type specifiers before regular ones.
compare(
getImportExportKind(itemA.node),
getImportExportKind(itemB.node)
) ||
// Keep the original order if the names are the same. It’s not worth

@@ -758,0 +758,0 @@ // trying to compare anything else, `import {a, a} from "mod"` is a syntax

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc