eslint-plugin-dollar-sign
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -0,0 +0,0 @@ /** |
{ | ||
"name": "eslint-plugin-dollar-sign", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Enforce $varName for jQuery assignment.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,5 +0,18 @@ | ||
# eslint-plugin-dollar-sign | ||
# eslint-plugin-dollar-sign [![Build Status](https://travis-ci.org/erikdesjardins/eslint-plugin-dollar-sign.svg?branch=master)](https://travis-ci.org/erikdesjardins/eslint-plugin-dollar-sign) | ||
Enforce $varName for jQuery assignment. | ||
An direct port of the `requireDollarBeforejQueryAssignment` rule from JSCS. | ||
A direct port of the `requireDollarBeforejQueryAssignment` rule from JSCS. | ||
`npm i --save-dev eslint-plugin-dollar-sign` | ||
```json | ||
{ | ||
"plugins": [ | ||
"dollar-sign" | ||
], | ||
"rules": { | ||
"dollar-sign/dollar-sign": [2, "ignoreProperties"] | ||
} | ||
} | ||
``` |
@@ -24,28 +24,15 @@ /** | ||
var nextToken = sourceCode.getFirstToken(right.callee); | ||
if (nextToken.value !== '$') { | ||
if (right.callee.type !== 'Identifier' || right.callee.name !== '$') { | ||
return; | ||
} | ||
nextToken = sourceCode.getTokenAfter(nextToken); | ||
if (nextToken.value !== '(') { | ||
return; | ||
} | ||
var identifier = sourceCode.getLastToken(left); | ||
while (!(nextToken.type === 'Punctuator' && nextToken.value === ')')) { | ||
nextToken = sourceCode.getTokenAfter(nextToken); | ||
} | ||
nextToken = sourceCode.getTokenAfter(nextToken); | ||
if (!nextToken || !(nextToken.type === 'Punctuator' && nextToken.value === '.')) { | ||
var identifier = sourceCode.getLastToken(left); | ||
context.report({ | ||
node: identifier, | ||
message: 'jQuery identifiers must start with a $', | ||
fix: function(fixer) { | ||
return fixer.insertTextBefore(identifier, '$'); | ||
} | ||
}); | ||
} | ||
context.report({ | ||
node: identifier, | ||
message: 'jQuery identifiers must start with a $', | ||
fix: function(fixer) { | ||
return fixer.insertTextBefore(identifier, '$'); | ||
} | ||
}); | ||
} | ||
@@ -52,0 +39,0 @@ |
@@ -209,2 +209,13 @@ /** | ||
}, | ||
// multiple var declarations | ||
{ | ||
code: 'var bar, foo = $(".foo");', | ||
output: 'var bar, $foo = $(".foo");', | ||
errors: [{ | ||
message: errorMessage, | ||
type: 'Identifier', | ||
line: 1, | ||
column: 10 | ||
}] | ||
}, | ||
@@ -211,0 +222,0 @@ //// in object definition |
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
14616
8
19