Sha256: 3634d0bf48de744434bfbc7491403b907ef0ec1fa1defac27b5b01d08f7ee0cc
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
/** * @fileoverview Rule to require sorting of variables within a single Variable Declaration block * @author Ilya Volodin */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { var configuration = context.options[0] || {}, ignoreCase = configuration.ignoreCase || false; return { "VariableDeclaration": function(node) { node.declarations.reduce(function(memo, decl) { if (decl.id.type === "ObjectPattern" || decl.id.type === "ArrayPattern") { return memo; } var lastVariableName = memo.id.name, currenVariableName = decl.id.name; if (ignoreCase) { lastVariableName = lastVariableName.toLowerCase(); currenVariableName = currenVariableName.toLowerCase(); } if (currenVariableName < lastVariableName) { context.report(decl, "Variables within the same declaration block should be sorted alphabetically"); return memo; } else { return decl; } }, node.declarations[0]); } }; }; module.exports.schema = [ { "type": "object", "properties": { "ignoreCase": { "type": "boolean" } }, "additionalProperties": false } ];
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint_node_modules-1.6.0.1 | vendor/node_modules/eslint/lib/rules/sort-vars.js |
eslint_node_modules-1.6.0 | vendor/node_modules/eslint/lib/rules/sort-vars.js |