eslint-plugin-standard
Advanced tools
Comparing version 4.0.2 to 4.1.0
{ | ||
"name": "eslint-plugin-standard", | ||
"description": "ESlint Plugin for the Standard Linter", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh", |
@@ -12,2 +12,4 @@ # eslint-plugin-standard [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] | ||
### Deprecated: This package isn't used by `standard` anymore, as of `standard` v16. See: https://github.com/standard/standard/issues/1316 | ||
ESlint Rules for the Standard Linter | ||
@@ -22,8 +24,8 @@ | ||
```js | ||
{ | ||
module.exports = { | ||
rules: { | ||
'standard/object-curly-even-spacing': [2, "either"], | ||
'standard/array-bracket-even-spacing': [2, "either"], | ||
'standard/computed-property-even-spacing': [2, "even"], | ||
'standard/no-callback-literal': [2, ["cb", "callback"]] | ||
'standard/object-curly-even-spacing': [2, 'either'], | ||
'standard/array-bracket-even-spacing': [2, 'either'], | ||
'standard/computed-property-even-spacing': [2, 'even'], | ||
'standard/no-callback-literal': [2, ['cb', 'callback']] | ||
} | ||
@@ -41,2 +43,1 @@ } | ||
- `no-callback-literal` - Ensures that we strictly follow the callback pattern with `undefined`, `null` or an error object in the first position of a callback. | ||
@@ -17,2 +17,3 @@ 'use strict' | ||
meta: { | ||
type: 'layout', | ||
docs: { | ||
@@ -24,4 +25,4 @@ url: 'https://github.com/standard/eslint-plugin-standard#rules-explanations' | ||
create: function (context) { | ||
var spaced = context.options[0] === 'always' | ||
var either = context.options[0] === 'either' | ||
const spaced = context.options[0] === 'always' | ||
const either = context.options[0] === 'either' | ||
@@ -39,3 +40,3 @@ /** | ||
var options = { | ||
const options = { | ||
either, | ||
@@ -125,4 +126,4 @@ spaced, | ||
function isEvenlySpacedAndNotTooLong (node, start, end) { | ||
var expectedSpace = start[1].range[0] - start[0].range[1] | ||
var endSpace = end[1].range[0] - end[0].range[1] | ||
const expectedSpace = start[1].range[0] - start[0].range[1] | ||
const endSpace = end[1].range[0] - end[0].range[1] | ||
return endSpace === expectedSpace && endSpace <= 1 | ||
@@ -141,8 +142,8 @@ } | ||
var first = context.getFirstToken(node) | ||
var second = context.getFirstToken(node, 1) | ||
var penultimate = context.getLastToken(node, 1) | ||
var last = context.getLastToken(node) | ||
const first = context.getFirstToken(node) | ||
const second = context.getFirstToken(node, 1) | ||
const penultimate = context.getLastToken(node, 1) | ||
const last = context.getLastToken(node) | ||
var openingBracketMustBeSpaced = | ||
const openingBracketMustBeSpaced = | ||
(options.objectsInArraysException && second.value === '{') || | ||
@@ -154,3 +155,3 @@ (options.arraysInArraysException && second.value === '[') || | ||
var closingBracketMustBeSpaced = | ||
const closingBracketMustBeSpaced = | ||
(options.objectsInArraysException && penultimate.value === '}') || | ||
@@ -157,0 +158,0 @@ (options.arraysInArraysException && penultimate.value === ']') || |
@@ -14,2 +14,3 @@ 'use strict' | ||
meta: { | ||
type: 'layout', | ||
docs: { | ||
@@ -21,4 +22,4 @@ url: 'https://github.com/standard/eslint-plugin-standard#rules-explanations' | ||
create: function (context) { | ||
var propertyNameMustBeSpaced = context.options[0] === 'always' // default is "never" | ||
var propertyNameMustBeEven = context.options[0] === 'even' // default is "never" | ||
const propertyNameMustBeSpaced = context.options[0] === 'always' // default is "never" | ||
const propertyNameMustBeEven = context.options[0] === 'even' // default is "never" | ||
@@ -105,9 +106,9 @@ // -------------------------------------------------------------------------- | ||
var property = node[propertyName] | ||
const property = node[propertyName] | ||
var before = context.getTokenBefore(property) | ||
var first = context.getFirstToken(property) | ||
var last = context.getLastToken(property) | ||
var after = context.getTokenAfter(property) | ||
var startSpace, endSpace | ||
const before = context.getTokenBefore(property) | ||
const first = context.getFirstToken(property) | ||
const last = context.getLastToken(property) | ||
const after = context.getTokenAfter(property) | ||
let startSpace, endSpace | ||
@@ -114,0 +115,0 @@ if (propertyNameMustBeEven) { |
@@ -18,2 +18,3 @@ /** | ||
function couldBeError (node) { | ||
let exprs | ||
switch (node.type) { | ||
@@ -32,3 +33,3 @@ case 'Identifier': | ||
case 'SequenceExpression': | ||
var exprs = node.expressions | ||
exprs = node.expressions | ||
return exprs.length !== 0 && couldBeError(exprs[exprs.length - 1]) | ||
@@ -53,2 +54,3 @@ | ||
meta: { | ||
type: 'suggestion', | ||
docs: { | ||
@@ -60,3 +62,3 @@ url: 'https://github.com/standard/eslint-plugin-standard#rules-explanations' | ||
create: function (context) { | ||
var callbackNames = context.options[0] || ['callback', 'cb'] | ||
const callbackNames = context.options[0] || ['callback', 'cb'] | ||
@@ -70,4 +72,4 @@ function isCallback (name) { | ||
CallExpression: function (node) { | ||
var errorArg = node.arguments[0] | ||
var calleeName = node.callee.name | ||
const errorArg = node.arguments[0] | ||
const calleeName = node.callee.name | ||
@@ -74,0 +76,0 @@ if (errorArg && !couldBeError(errorArg) && isCallback(calleeName)) { |
@@ -17,2 +17,3 @@ 'use strict' | ||
meta: { | ||
type: 'layout', | ||
docs: { | ||
@@ -24,4 +25,4 @@ url: 'https://github.com/standard/eslint-plugin-standard#rules-explanations' | ||
create: function (context) { | ||
var spaced = context.options[0] === 'always' | ||
var either = context.options[0] === 'either' | ||
const spaced = context.options[0] === 'always' | ||
const either = context.options[0] === 'either' | ||
@@ -39,3 +40,3 @@ /** | ||
var options = { | ||
const options = { | ||
spaced, | ||
@@ -124,4 +125,4 @@ either, | ||
function isEvenlySpacedAndNotTooLong (node, start, end) { | ||
var expectedSpace = start[1].range[0] - start[0].range[1] | ||
var endSpace = end[1].range[0] - end[0].range[1] | ||
const expectedSpace = start[1].range[0] - start[0].range[1] | ||
const endSpace = end[1].range[0] - end[0].range[1] | ||
return endSpace === expectedSpace && endSpace <= 1 | ||
@@ -140,3 +141,3 @@ } | ||
function validateBraceSpacing (node, first, second, penultimate, last) { | ||
var closingCurlyBraceMustBeSpaced = | ||
const closingCurlyBraceMustBeSpaced = | ||
(options.arraysInObjectsException && penultimate.value === ']') || | ||
@@ -194,9 +195,9 @@ (options.objectsInObjectsException && penultimate.value === '}') | ||
var firstSpecifier = node.properties[0] | ||
var lastSpecifier = node.properties[node.properties.length - 1] | ||
const firstSpecifier = node.properties[0] | ||
const lastSpecifier = node.properties[node.properties.length - 1] | ||
var first = context.getTokenBefore(firstSpecifier) | ||
var second = context.getFirstToken(firstSpecifier) | ||
var penultimate = context.getLastToken(lastSpecifier) | ||
var last = context.getTokenAfter(lastSpecifier) | ||
const first = context.getTokenBefore(firstSpecifier) | ||
const second = context.getFirstToken(firstSpecifier) | ||
let penultimate = context.getLastToken(lastSpecifier) | ||
let last = context.getTokenAfter(lastSpecifier) | ||
@@ -214,11 +215,11 @@ // support trailing commas | ||
ImportDeclaration: function (node) { | ||
var firstSpecifier = node.specifiers[0] | ||
var lastSpecifier = node.specifiers[node.specifiers.length - 1] | ||
const firstSpecifier = node.specifiers[0] | ||
const lastSpecifier = node.specifiers[node.specifiers.length - 1] | ||
// don't do anything for namespace or default imports | ||
if (firstSpecifier && lastSpecifier && firstSpecifier.type === 'ImportSpecifier' && lastSpecifier.type === 'ImportSpecifier') { | ||
var first = context.getTokenBefore(firstSpecifier) | ||
var second = context.getFirstToken(firstSpecifier) | ||
var penultimate = context.getLastToken(lastSpecifier) | ||
var last = context.getTokenAfter(lastSpecifier) | ||
const first = context.getTokenBefore(firstSpecifier) | ||
const second = context.getFirstToken(firstSpecifier) | ||
const penultimate = context.getLastToken(lastSpecifier) | ||
const last = context.getTokenAfter(lastSpecifier) | ||
@@ -235,8 +236,8 @@ validateBraceSpacing(node, first, second, penultimate, last) | ||
var firstSpecifier = node.specifiers[0] | ||
var lastSpecifier = node.specifiers[node.specifiers.length - 1] | ||
var first = context.getTokenBefore(firstSpecifier) | ||
var second = context.getFirstToken(firstSpecifier) | ||
var penultimate = context.getLastToken(lastSpecifier) | ||
var last = context.getTokenAfter(lastSpecifier) | ||
const firstSpecifier = node.specifiers[0] | ||
const lastSpecifier = node.specifiers[node.specifiers.length - 1] | ||
const first = context.getTokenBefore(firstSpecifier) | ||
const second = context.getFirstToken(firstSpecifier) | ||
const penultimate = context.getLastToken(lastSpecifier) | ||
const last = context.getTokenAfter(lastSpecifier) | ||
@@ -252,6 +253,6 @@ validateBraceSpacing(node, first, second, penultimate, last) | ||
var first = context.getFirstToken(node) | ||
var second = context.getFirstToken(node, 1) | ||
var penultimate = context.getLastToken(node, 1) | ||
var last = context.getLastToken(node) | ||
const first = context.getFirstToken(node) | ||
const second = context.getFirstToken(node, 1) | ||
const penultimate = context.getLastToken(node, 1) | ||
const last = context.getLastToken(node) | ||
@@ -258,0 +259,0 @@ validateBraceSpacing(node, first, second, penultimate, last) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28707
616
41