@silvermine/eslint-plugin-silvermine
Advanced tools
Comparing version 1.2.1 to 2.0.0-preview.1
@@ -5,3 +5,3 @@ { | ||
}, | ||
"extends": "eslint-config-silvermine/node" | ||
"extends": "@silvermine/eslint-config/node" | ||
} |
/** | ||
* @fileoverview Shareable eslint plugin for use by eslint-config-silvermine | ||
* @fileoverview Shareable eslint plugin for use by @silvermine/eslint-config | ||
*/ | ||
@@ -16,2 +16,5 @@ | ||
uninitializedLast = require('./rules/uninitialized-last'), | ||
noArrowProperties = require('./rules/no-arrow-for-class-property'), | ||
modulesOnly = require('./rules/module-files-only'), | ||
blockScopeCase = require('./rules/block-scope-case'), | ||
indent = require('./rules/indent'); | ||
@@ -30,2 +33,5 @@ | ||
'uninitialized-last': uninitializedLast, | ||
'no-arrow-for-class-property': noArrowProperties, | ||
'module-files-only': modulesOnly, | ||
'block-scope-case': blockScopeCase, | ||
}; |
@@ -7,6 +7,38 @@ /** | ||
var _ = require('underscore'), | ||
ALLOWED_OPTIONS = [ true, false, 'never', 'single-only', 'allow' ], | ||
DEFAULT_OPTIONS; | ||
DEFAULT_OPTIONS = { | ||
'var': 'never', | ||
'let': 'never', | ||
'const': 'never', | ||
}; | ||
module.exports = { | ||
meta: { | ||
schema: [ | ||
{ | ||
type: 'object', | ||
properties: { | ||
'var': { | ||
'enum': ALLOWED_OPTIONS, | ||
}, | ||
'let': { | ||
'enum': ALLOWED_OPTIONS, | ||
}, | ||
'const': { | ||
'enum': ALLOWED_OPTIONS, | ||
}, | ||
}, | ||
}, | ||
], | ||
}, | ||
create: function(context) { | ||
var options; | ||
options = _.assign({}, DEFAULT_OPTIONS, context.options[0] || {}); | ||
function validateVar(node) { | ||
@@ -24,4 +56,26 @@ if (node.loc.start.line !== node.loc.end.line) { | ||
function shouldValidate(option, declarations) { | ||
if (option === 'never' || option === true) { | ||
return true; | ||
} | ||
if (option === 'single-only' && declarations.length > 1) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
function validateDeclaration(node) { | ||
var kindOption = options[node.kind]; | ||
if (shouldValidate(kindOption, node.declarations)) { | ||
_.each(node.declarations, function(decl) { | ||
validateVar(decl); | ||
}); | ||
} | ||
} | ||
return { | ||
'VariableDeclarator': validateVar, | ||
'VariableDeclaration': validateDeclaration, | ||
}; | ||
@@ -28,0 +82,0 @@ }, |
{ | ||
"name": "@silvermine/eslint-plugin-silvermine", | ||
"version": "1.2.1", | ||
"version": "2.0.0-preview.1", | ||
"description": "eslint plugins to support our JS Code Standards. See @silvermine/eslint-config-silvermine", | ||
@@ -17,3 +17,3 @@ "scripts": { | ||
"eslint-plugin", | ||
"eslint-config-silvermine" | ||
"@silvermine/eslint-config" | ||
], | ||
@@ -27,2 +27,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@silvermine/eslint-config": "1.5.0", | ||
"class.extend": "0.9.2", | ||
@@ -33,8 +34,7 @@ "lodash.assign": "4.2.0", | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=6.0" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "3.0.2", | ||
"eslint": "4.15.0", | ||
"eslint-config-silvermine": "1.4.0", | ||
"eslint": "4.19.1", | ||
"grunt": "1.0.3", | ||
@@ -44,4 +44,6 @@ "grunt-cli": "1.2.0", | ||
"istanbul": "0.4.5", | ||
"mocha": "5.2.0" | ||
"mocha": "5.2.0", | ||
"typescript": "3.0.3", | ||
"typescript-eslint-parser": "21.0.1" | ||
} | ||
} |
@@ -25,9 +25,9 @@ # Silvermine ESLint plugin | ||
Next, install `eslint-plugin-silvermine`: | ||
Next, install `@silvermine/eslint-plugin-silvermine`: | ||
``` | ||
$ npm install eslint-plugin-silvermine --save-dev | ||
$ npm install @silvermine/eslint-plugin-silvermine --save-dev | ||
``` | ||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-silvermine` globally. | ||
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `@silvermine/eslint-plugin-silvermine` globally. | ||
@@ -41,3 +41,3 @@ ## Usage | ||
"plugins": [ | ||
"silvermine" | ||
"@silvermine/eslint-plugin-silvermine" | ||
] | ||
@@ -53,3 +53,3 @@ } | ||
"rules": { | ||
"silvermine/fluent-chaining": 2 | ||
"@silvermine/silvermine/fluent-chaining": 2 | ||
} | ||
@@ -56,0 +56,0 @@ } |
@@ -12,5 +12,5 @@ /** | ||
formatCode = require('../../code-helper'), | ||
RuleTester = require('eslint').RuleTester, | ||
ruleTester = new RuleTester(), | ||
invalidExample, invalidExample2, validExample; | ||
ruleTester = require('../../ruleTesters').es6(), | ||
invalidExample, invalidExample2, validExample, | ||
validSingleConst, invalidSingleConst, invalidSingleConst2; | ||
@@ -45,2 +45,37 @@ validExample = formatCode( | ||
validSingleConst = formatCode( | ||
'const MY_INT = 1;', | ||
'', | ||
'const MY_CONST = {', | ||
' a: 1,', | ||
' b: 2,', | ||
' c: 3', | ||
'};' | ||
); | ||
invalidSingleConst = formatCode( | ||
'const MY_INT = 1,', | ||
' MY_CONST = {', | ||
' a: 1,', | ||
' b: 2,', | ||
' c: 3', | ||
' };' | ||
); | ||
invalidSingleConst2 = formatCode( | ||
'let myLetVar = [', | ||
' 1,', | ||
' 2,', | ||
' 3', | ||
'];', | ||
'', | ||
'const MY_INT = 1;', | ||
'', | ||
'const MY_CONST = {', | ||
' a: 1,', | ||
' b: 2,', | ||
' c: 3', | ||
'};' | ||
); | ||
// ------------------------------------------------------------------------------ | ||
@@ -52,3 +87,10 @@ // Tests | ||
valid: [ | ||
validExample, | ||
{ | ||
code: validExample, | ||
options: [], | ||
}, | ||
{ | ||
code: validSingleConst, | ||
options: [ { 'var': 'never', 'let': 'never', 'const': 'single-only' } ], | ||
}, | ||
], | ||
@@ -59,2 +101,3 @@ | ||
code: invalidExample, | ||
options: [], | ||
errors: [ | ||
@@ -69,2 +112,3 @@ { | ||
code: invalidExample2, | ||
options: [], | ||
errors: [ | ||
@@ -77,3 +121,23 @@ { | ||
}, | ||
{ | ||
code: invalidSingleConst, | ||
options: [ { 'var': 'never', 'let': 'never', 'const': 'single-only' } ], | ||
errors: [ | ||
{ | ||
message: 'Variable declaration for MY_CONST should not span multiple lines.', | ||
type: 'VariableDeclarator', | ||
}, | ||
], | ||
}, | ||
{ | ||
code: invalidSingleConst2, | ||
options: [ { 'var': 'never', 'let': 'never', 'const': 'single-only' } ], | ||
errors: [ | ||
{ | ||
message: 'Variable declaration for myLetVar should not span multiple lines.', | ||
type: 'VariableDeclarator', | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
105671
41
3002
4
9
1
1
+ Added@silvermine/eslint-config@1.5.0(transitive)
+ Added@silvermine/eslint-plugin-silvermine@1.2.1(transitive)