Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
eslint-plugin-sort-keys-fix
Advanced tools
Fork of eslint rule that sorts keys in objects (https://eslint.org/docs/rules/sort-keys) with autofix enabled
The eslint-plugin-sort-keys-fix package is an ESLint plugin that automatically sorts the keys of objects in your JavaScript code. It helps maintain a consistent key order in objects, which can improve readability and reduce merge conflicts.
Sort Object Keys
This feature enforces a rule that automatically sorts the keys of objects in your code. When the rule is set to 'error', ESLint will throw an error if the keys are not sorted, and it will automatically fix the order when possible.
{
"rules": {
"sort-keys-fix/sort-keys-fix": "error"
}
}
Custom Order
This feature allows you to customize the sorting order. In this example, keys are sorted in ascending order, case-sensitive, and without natural sorting. You can adjust these options to fit your project's needs.
{
"rules": {
"sort-keys-fix/sort-keys-fix": ["error", "asc", { "caseSensitive": true, "natural": false }]
}
}
eslint-plugin-sort-keys is another ESLint plugin that enforces key sorting in objects. Unlike eslint-plugin-sort-keys-fix, it does not automatically fix the order of keys but only reports errors when the keys are not sorted.
eslint-plugin-json is an ESLint plugin that provides linting rules for JSON files. While it does not specifically focus on sorting object keys, it includes rules for ensuring consistency and correctness in JSON files, which can indirectly help with key order.
Fork of eslint rule that sorts keys in objects (https://eslint.org/docs/rules/sort-keys) with autofix enabled
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-sort-keys-fix
:
$ npm install eslint-plugin-sort-keys-fix --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-sort-keys-fix
globally.
Add sort-keys-fix
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"sort-keys-fix"
]
}
Then add sort-keys-fix rule under the rules section.
{
"rules": {
"sort-keys-fix/sort-keys-fix": "warn"
}
}
Often it makes sense to enable sort-keys-fix
only for certain files/directories. For cases like that, use override key of eslint config:
{
"rules": {
// ...
},
"overrides": [
{
"files": ["src/alphabetical.js", "bin/*.js", "lib/*.js"],
"rules": {
"sort-keys-fix/sort-keys-fix": "warn"
}
}
]
}
For available config options, see official sort-keys reference. All options supported by sort-keys
, besides minKeys
, are supported by sort-keys-fix
.
FAQs
Fork of eslint rule that sorts keys in objects (https://eslint.org/docs/rules/sort-keys) with autofix enabled
The npm package eslint-plugin-sort-keys-fix receives a total of 313,130 weekly downloads. As such, eslint-plugin-sort-keys-fix popularity was classified as popular.
We found that eslint-plugin-sort-keys-fix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.