eslint-plugin-shopify
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -16,5 +16,5 @@ /* eslint no-unused-vars:0, no-console: 0 */ | ||
var beforeToken = context.getTokenBefore(node); | ||
var hasBeforeParen = beforeToken && beforeToken.type === 'Punctuator' && beforeToken.value === '('; | ||
var hasBeforeParen = beforeToken && (beforeToken.type === 'Punctuator') && (beforeToken.value === '('); | ||
var afterToken = context.getTokenAfter(node); | ||
var hasAfterParen = afterToken && afterToken.type === 'Punctuator' && afterToken.value === ')'; | ||
var hasAfterParen = afterToken && (afterToken.type === 'Punctuator') && (afterToken.value === ')'); | ||
@@ -21,0 +21,0 @@ return hasBeforeParen && hasAfterParen; |
var ALWAYS_MESSAGE = 'You must include a @flow declaration at the top of your file.'; | ||
var NEVER_MESSAGE = 'You must not include a @flow declaration in your file.'; | ||
var EXPLICIT_MESSAGE = 'You must include a @flow or @noflow declaration at the top of your file.'; | ||
var FLOW_REGEX = /@flow/; | ||
var EXPLICIT_FLOW_REGEX = /@(no)?flow/; | ||
function commentIsFlowDirective(comment) { | ||
return Boolean(comment) && comment.type === 'Block' && comment.start === 0 && FLOW_REGEX.test(comment.value); | ||
function commentIsFlowDirective(comment, regex) { | ||
return Boolean(comment) && comment.type === 'Block' && comment.start === 0 && regex.test(comment.value); | ||
} | ||
@@ -15,3 +17,3 @@ | ||
var commentNode = node.comments && node.comments[0]; | ||
var isFlowDirective = commentIsFlowDirective(commentNode); | ||
var isFlowDirective = commentIsFlowDirective(commentNode, config === 'explicit' ? EXPLICIT_FLOW_REGEX : FLOW_REGEX); | ||
@@ -25,2 +27,8 @@ switch (config) { | ||
case 'explicit': | ||
if (!isFlowDirective) { | ||
context.report(node, EXPLICIT_MESSAGE); | ||
} | ||
break; | ||
case 'never': | ||
@@ -37,3 +45,3 @@ if (isFlowDirective) { | ||
module.exports.schema = [{ | ||
enum: ['always', 'never'], | ||
enum: ['always', 'explicit', 'never'], | ||
}]; |
{ | ||
"name": "eslint-plugin-shopify", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "Shopify-specific ESLint rules.", | ||
@@ -16,3 +16,3 @@ "repository": { | ||
"scripts": { | ||
"lint": "node_modules/.bin/eslint .", | ||
"lint": "node_modules/.bin/eslint . --max-warnings 0", | ||
"test:unit": "istanbul cover --dir reports/coverage node_modules/.bin/_mocha tests/**/*.js -- --reporter dot", | ||
@@ -35,3 +35,5 @@ "test": "npm run lint && npm run test:unit" | ||
"eslint": "^1.5.0", | ||
"eslint-config-shopify": ">=5.3.0", | ||
"eslint-config-shopify": "^5.6.0", | ||
"eslint-plugin-shopify": "file:.", | ||
"eslint-plugin-react": "*", | ||
"istanbul": "^0.3.20", | ||
@@ -38,0 +40,0 @@ "mocha": "^2.3.2" |
@@ -57,2 +57,6 @@ # eslint-plugin-shopify | ||
### 2.1.0 - January 19, 2016 | ||
Add `explicit` option to `require-flow` rule to support either `@flow` or `@noflow`. | ||
### 2.0.1 - October 20, 2015 | ||
@@ -59,0 +63,0 @@ |
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
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
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
7820
89
85
7
1