New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-sorting

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-sorting - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.eslintrc.yml

47

index.js

@@ -5,44 +5,11 @@ "use strict";

rules: {
"sort-object-props": function(context) {
var caseSensitive = context.options[0].caseSensitive;
var ignoreMethods = context.options[0].ignoreMethods;
var ignorePrivate = context.options[0].ignorePrivate;
var MSG = "Property names in object literals should be sorted";
return {
"ObjectExpression": function(node) {
node.properties.reduce(function(lastProp, prop) {
if (ignoreMethods &&
prop.value.type === "FunctionExpression") {
return prop;
}
var lastPropId, propId;
if (prop.key.type === "Identifier") {
lastPropId = lastProp.key.name;
propId = prop.key.name;
} else if (prop.key.type === "Literal") {
lastPropId = lastProp.key.value;
propId = prop.key.value;
}
if ((caseSensitive) && (lastPropId !== undefined)) {
lastPropId = lastPropId.toLowerCase();
propId = propId.toLowerCase();
}
if (ignorePrivate && /^_/.test(propId)) {
return prop;
}
if (propId < lastPropId) {
context.report(prop, MSG);
}
return prop;
}, node.properties[0]);
}
};
"sort-object-props": require("./lib/rules/sort-object-props")
},
configs: {
recommended: {
rules: {
"sort-object-props": [1, { ignoreCase: true, ignoreMethods: false }]
}
}
},
rulesConfig: {
"sort-object-props": [ 1, { caseSensitive: false, ignoreMethods: false } ]
}
};
{
"name": "eslint-plugin-sorting",
"version": "0.1.0",
"description": "Require property names in object literals to be sorted alphabetically.",
"version": "0.2.0",
"description": "Sorting rules for eslint",
"keywords": [

@@ -9,6 +9,22 @@ "eslint",

],
"author": "Jacob Rask",
"scripts": {
"lint": "eslint lib/ tests/",
"test": "npm run lint && npm run unit-test",
"unit-test": "mocha tests/**/*.js",
"unit-test:watch": "npm run unit-test -- --watch"
},
"author": "Jacob Rask <jacob@jacobrask.net>",
"license": "MIT",
"main": "index.js",
"repository": "jacobrask/eslint-plugin-sorting"
"repository": {
"type": "git",
"url": "https://github.com/jacobrask/eslint-plugin-sorting"
},
"homepage": "https://github.com/jacobrask/eslint-plugin-sorting",
"devDependencies": {
"babel-eslint": "^6.0.4",
"eslint": "^2.12.0",
"eslint-config-eslint": "^3.0.0",
"mocha": "^2.5.3"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc