eslint-plugin-simple-import-sort
Advanced tools
Comparing version 8.0.0 to 9.0.0-beta.1
@@ -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": "9.0.0-beta.1", | ||
"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); | ||
@@ -14,0 +14,0 @@ switch (result) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37296
1005
2