eslint-plugin-sorting
Advanced tools
Comparing version 0.1.0 to 0.2.0
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" | ||
} | ||
} |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
5771
8
82
1
0
4