eslint-plugin-sort
Advanced tools
Comparing version 3.1.1 to 4.0.0
@@ -150,3 +150,3 @@ // src/utils.ts | ||
return true; | ||
} catch (e) { | ||
} catch { | ||
resolveCache.set(source, false); | ||
@@ -292,3 +292,5 @@ return false; | ||
} | ||
const sorted = nodes.slice().sort((nodeA, nodeB) => sorter(nodeA.local.name, nodeB.local.name)); | ||
const sorted = nodes.slice().sort( | ||
(nodeA, nodeB) => sorter(getName(nodeA.local), getName(nodeB.local)) | ||
); | ||
report(context, nodes, sorted); | ||
@@ -330,3 +332,3 @@ } | ||
AST_NODE_TYPES | ||
} from "@typescript-eslint/experimental-utils"; | ||
} from "@typescript-eslint/utils"; | ||
function getName2(node) { | ||
@@ -564,3 +566,3 @@ switch (node?.type) { | ||
const sorted = nodes.slice().sort( | ||
(nodeA, nodeB) => sorter(nodeA.imported.name, nodeB.imported.name) | ||
(nodeA, nodeB) => sorter(getName(nodeA.imported), getName(nodeB.imported)) | ||
); | ||
@@ -660,3 +662,3 @@ report(context, nodes, sorted); | ||
ESLintUtils | ||
} from "@typescript-eslint/experimental-utils"; | ||
} from "@typescript-eslint/utils"; | ||
function getWeight(node) { | ||
@@ -684,8 +686,7 @@ const weights = { | ||
create(context) { | ||
const source = context.getSourceCode(); | ||
const options = context.options[0]; | ||
const sorter = getSorter(options); | ||
function getRangeWithoutDelimiter(node) { | ||
const range2 = getNodeRange2(source, node); | ||
return isDelimiter(source.getLastToken(node)) ? [range2[0], range2[1] - 1] : range2; | ||
const range2 = getNodeRange2(context.sourceCode, node); | ||
return isDelimiter(context.sourceCode.getLastToken(node)) ? [range2[0], range2[1] - 1] : range2; | ||
} | ||
@@ -712,3 +713,3 @@ function sort(nodes) { | ||
getRangeWithoutDelimiter(node), | ||
getNodeText2(source, complement).replace(/[;,]$/, "") | ||
getNodeText2(context.sourceCode, complement).replace(/[;,]$/, "") | ||
); | ||
@@ -731,3 +732,2 @@ } | ||
docs: { | ||
recommended: false, | ||
url: docsURL("type-properties"), | ||
@@ -763,6 +763,3 @@ description: `Sorts TypeScript type properties alphabetically and case insensitive in ascending order.` | ||
// src/rules/string-unions.ts | ||
import { | ||
ESLintUtils as ESLintUtils2, | ||
TSESTree as TSESTree3 | ||
} from "@typescript-eslint/experimental-utils"; | ||
import { ESLintUtils as ESLintUtils2, TSESTree as TSESTree3 } from "@typescript-eslint/utils"; | ||
function getSortValue4(node) { | ||
@@ -773,3 +770,2 @@ return node.type === TSESTree3.AST_NODE_TYPES.TSLiteralType && node.literal.type === TSESTree3.AST_NODE_TYPES.Literal && typeof node.literal.value === "string" ? node.literal.value : null; | ||
create(context) { | ||
const source = context.getSourceCode(); | ||
const options = context.options[0]; | ||
@@ -792,3 +788,6 @@ const sorter = getSorter(options); | ||
for (const [node2, complement] of enumerate(nodes, sorted)) { | ||
yield fixer.replaceText(node2, getNodeText2(source, complement)); | ||
yield fixer.replaceText( | ||
node2, | ||
getNodeText2(context.sourceCode, complement) | ||
); | ||
} | ||
@@ -803,3 +802,2 @@ } | ||
docs: { | ||
recommended: false, | ||
url: docsURL("string-unions"), | ||
@@ -835,6 +833,3 @@ description: `Sorts TypeScript string unions alphabetically and case insensitive in ascending order.` | ||
// src/rules/string-enums.ts | ||
import { | ||
ESLintUtils as ESLintUtils3, | ||
TSESTree as TSESTree4 | ||
} from "@typescript-eslint/experimental-utils"; | ||
import { ESLintUtils as ESLintUtils3, TSESTree as TSESTree4 } from "@typescript-eslint/utils"; | ||
function getSortValue5(node) { | ||
@@ -845,3 +840,2 @@ return node.initializer?.type === TSESTree4.AST_NODE_TYPES.Literal && typeof node.initializer.value === "string" ? node.initializer.value : null; | ||
create(context) { | ||
const source = context.getSourceCode(); | ||
const options = context.options[0]; | ||
@@ -851,3 +845,3 @@ const sorter = getSorter(options); | ||
TSEnumDeclaration(node) { | ||
const nodes = node.members; | ||
const nodes = node.body.members ?? node.members; | ||
if (nodes.length < 2) | ||
@@ -865,3 +859,6 @@ return; | ||
for (const [node2, complement] of enumerate(nodes, sorted)) { | ||
yield fixer.replaceText(node2, getNodeText2(source, complement)); | ||
yield fixer.replaceText( | ||
node2, | ||
getNodeText2(context.sourceCode, complement) | ||
); | ||
} | ||
@@ -876,3 +873,2 @@ } | ||
docs: { | ||
recommended: false, | ||
url: docsURL("string-enums"), | ||
@@ -879,0 +875,0 @@ description: `Sorts TypeScript string enums alphabetically and case insensitive in ascending order.` |
{ | ||
"name": "eslint-plugin-sort", | ||
"description": "Auto-fixable sort rules for ESLint.", | ||
"version": "3.1.1", | ||
"version": "4.0.0", | ||
"author": "Mark Skelton", | ||
@@ -21,3 +21,3 @@ "repository": "github:mskelton/eslint-plugin-sort", | ||
"format": "prettier --write .", | ||
"lint": "eslint . --ext .ts", | ||
"lint": "eslint .", | ||
"test": "vitest", | ||
@@ -42,6 +42,6 @@ "test:watch": "vitest --reporter=dot", | ||
"peerDependencies": { | ||
"eslint": ">=8" | ||
"eslint": ">=8.56.0" | ||
}, | ||
"dependencies": { | ||
"@typescript-eslint/experimental-utils": "^5.54.1", | ||
"@typescript-eslint/utils": "^8.11.0", | ||
"isomorphic-resolve": "^1.0.0", | ||
@@ -51,21 +51,19 @@ "natural-compare": "^1.4.0" | ||
"devDependencies": { | ||
"@babel/core": "^7.21.0", | ||
"@mskelton/semantic-release-config": "^1.0.1", | ||
"@mskelton/tsconfig": "^2.0.0", | ||
"@types/dedent": "^0.7.0", | ||
"@types/eslint": "^8.21.1", | ||
"@types/estree": "^1.0.0", | ||
"@types/estree": "^1.0.6", | ||
"@types/natural-compare": "^1.4.1", | ||
"@typescript-eslint/eslint-plugin": "^5.54.1", | ||
"@typescript-eslint/parser": "^5.54.1", | ||
"@typescript-eslint/rule-tester": "^8.11.0", | ||
"bun-types": "^1.0.1", | ||
"dedent": "^0.7.0", | ||
"eslint": "^8.36.0", | ||
"eslint-config-prettier": "^8.7.0", | ||
"prettier": "^2.8.4", | ||
"eslint": "^9.13.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"prettier": "^3.3.3", | ||
"semantic-release": "^23.0.2", | ||
"tsup": "^6.6.3", | ||
"typescript": "^4.9.5", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.11.0", | ||
"vitest": "^0.29.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
16
60628
1893
+ Added@typescript-eslint/scope-manager@8.20.0(transitive)
+ Added@typescript-eslint/types@8.20.0(transitive)
+ Added@typescript-eslint/typescript-estree@8.20.0(transitive)
+ Added@typescript-eslint/utils@8.20.0(transitive)
+ Added@typescript-eslint/visitor-keys@8.20.0(transitive)
+ Addedbrace-expansion@2.0.1(transitive)
+ Addedminimatch@9.0.5(transitive)
+ Addedts-api-utils@2.0.0(transitive)
- Removed@eslint/eslintrc@2.1.4(transitive)
- Removed@eslint/js@8.57.1(transitive)
- Removed@humanwhocodes/config-array@0.13.0(transitive)
- Removed@humanwhocodes/object-schema@2.0.3(transitive)
- Removed@types/semver@7.5.8(transitive)
- Removed@typescript-eslint/experimental-utils@5.62.0(transitive)
- Removed@typescript-eslint/scope-manager@5.62.0(transitive)
- Removed@typescript-eslint/types@5.62.0(transitive)
- Removed@typescript-eslint/typescript-estree@5.62.0(transitive)
- Removed@typescript-eslint/utils@5.62.0(transitive)
- Removed@typescript-eslint/visitor-keys@5.62.0(transitive)
- Removed@ungap/structured-clone@1.2.1(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedarray-union@2.1.0(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removeddoctrine@3.0.0(transitive)
- Removedeslint@8.57.1(transitive)
- Removedeslint-scope@5.1.17.2.2(transitive)
- Removedespree@9.6.1(transitive)
- Removedestraverse@4.3.0(transitive)
- Removedfile-entry-cache@6.0.1(transitive)
- Removedflat-cache@3.2.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedglobals@13.24.0(transitive)
- Removedglobby@11.1.0(transitive)
- Removedgraphemer@1.4.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-path-inside@3.0.3(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedslash@3.0.0(transitive)
- Removedstrip-ansi@6.0.1(transitive)
- Removedtext-table@0.2.0(transitive)
- Removedtslib@1.14.1(transitive)
- Removedtsutils@3.21.0(transitive)
- Removedtype-fest@0.20.2(transitive)
- Removedwrappy@1.0.2(transitive)