Gathering detailed insights and metrics for eslint-plugin-sort-keys-custom-order
Gathering detailed insights and metrics for eslint-plugin-sort-keys-custom-order
Gathering detailed insights and metrics for eslint-plugin-sort-keys-custom-order
Gathering detailed insights and metrics for eslint-plugin-sort-keys-custom-order
npm install eslint-plugin-sort-keys-custom-order
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
18 Stars
31 Commits
1 Forks
3 Watching
1 Branches
3 Contributors
Updated on 19 Nov 2024
TypeScript (95.48%)
JavaScript (4.52%)
Cumulative downloads
Total Downloads
Last day
15.8%
951
Compared to previous day
Last week
-54.8%
5,040
Compared to previous week
Last month
75.7%
26,756
Compared to previous month
Last year
176.5%
165,850
Compared to previous year
2
This plugin enforces alphabetically sorting keys in objects and typescript types with auto-fix. You can add a list of priority sorted keys for custom sorting (ex: if you want "id" to be the first property).
You'll first need to install ESLint:
$ npm install -D eslint
Next, install eslint-plugin-sort-keys-custom-order
:
$ npm install -D eslint-plugin-sort-keys-custom-order
Add sort-keys-custom-order
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
1// eslint.config.js 2import sortKeysCustomOrder from "eslint-plugin-sort-keys-custom-order"; 3 4export default [{ 5 /* ... */ 6 plugins: { 7 "sort-keys-custom-order": sortKeysCustomOrder 8 } 9 /* ... */ 10}]
Then configure the rules you want to use under the rules section.
1// .eslintrc.js 2export default [{ 3 /* ... */ 4 "rules": { 5 // For JS objects sorting 6 "sort-keys-custom-order/object-keys": [ 7 "error", { "orderedKeys": ["id", "name", "title"] } 8 ], 9 // For TS types sorting 10 "sort-keys-custom-order/type-keys": [ 11 "error", { "orderedKeys": ["id", "name", "title"] } 12 ] 13 } 14 /* ... */ 15}]
Or you can use the recommended configuration:
1// eslint.config.js 2import sortKeysCustomOrder from "eslint-plugin-sort-keys-custom-order"; 3 4export default [ 5 /* ... */ 6 sortKeysCustomOrder.configs["flat/recommended"], 7 /* ... */ 8]
orderedKeys: Array<string>
: You can pass an array of ordered keys to the rule configuration. The rule will sort the keys in the order you provided.
sorting: "asc" | "desc" | "none"
: You can pass the sorting order for the keys not in orderedKeys. Default is "asc".
Example:
1{ 2 "sort-keys-custom-order/object-keys": [ 3 "error", 4 { 5 "orderedKeys": ["id","name","title"], 6 "sorting": "asc" 7 } 8 ] 9}
Allow you to sort properties inside JS objects
Allow you to sort properties inside TS types
Allow you to sort properties inside JS import objects
Allow you to sort properties inside JS export objects
1// Bad 2const module = { 3 isValid: true, 4 id: 1234, 5 create: () => { doThing() }, 6 isRunning: false, 7 name: "test", 8 url: "https://google.com", 9 isAvailable: true 10}
1// Good 2const module = { 3 id: 1234, 4 name: "test", 5 create: () => { doThing() }, 6 isAvailable: true, 7 isRunning: false, 8 isValid: true, 9 url: "https://google.com" 10}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
4 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 4
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More