@sprucelabs/eslint-plugin-spruce
Advanced tools
Comparing version 8.10.1-canary.43 to 8.10.1-canary.44
50
index.js
@@ -29,3 +29,3 @@ const rules = [ | ||
!QueryOption.value.name.match( | ||
new RegExp(`.*${rule.suffix}`, 'gi') | ||
new RegExp(`.*${rule.suffix}$`, 'gi') | ||
) | ||
@@ -54,31 +54,31 @@ ) { | ||
}, | ||
TemplateLiteral(node) { | ||
// `value` will return up until the `${` (if one exists). | ||
// Bad: { ${ | ||
// Good: { {} } ${ | ||
// Good: { {} } | ||
const source = context.getSourceCode() | ||
const tokens = source.getTokens(node) | ||
const previousTokens = source.getTokensBefore(node, { count: 1 }) | ||
const openBrackets = tokens[0].value.match(/{/gi) | ||
const closeBrackets = tokens[0].value.match(/}/gi) | ||
if ( | ||
previousTokens[0].value === 'gql' && | ||
(openBrackets && openBrackets.length - 1) > | ||
(closeBrackets && closeBrackets.length) | ||
) { | ||
context.report( | ||
node, | ||
'No nested interpolation in GraphQL documents.' | ||
) | ||
} | ||
}, | ||
Identifier(node) { | ||
rules.forEach(rule => { | ||
if (node.name.match(new RegExp(`.*${rule.suffix}`, 'gi'))) { | ||
if (node.name.match(new RegExp(`.*${rule.suffix}$`, 'gi'))) { | ||
const source = context.getSourceCode() | ||
const tokens = source.getTokensAfter(node, { count: 3 }) | ||
if ( | ||
tokens[0].value === '=' && | ||
tokens[1].value === 'gql' && | ||
tokens[2].type === 'Template' | ||
) { | ||
// `value` will return up until the `${` (if one exists). | ||
// Bad: { ${ | ||
// Good: { {} } ${ | ||
// Good: { {} } | ||
const openBrackets = tokens[2].value.match(/{/gi) | ||
const closeBrackets = tokens[2].value.match(/}/gi) | ||
if ( | ||
(openBrackets && openBrackets.length - 1) > | ||
(closeBrackets && closeBrackets.length) | ||
) { | ||
context.report( | ||
node, | ||
'No nested interpolation in GraphQL documents.' | ||
) | ||
} | ||
} | ||
if (tokens[0].value === '=' && tokens[1].type === 'Template') { | ||
@@ -85,0 +85,0 @@ context.report( |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "8.10.1-canary.43+421ecfef", | ||
"version": "8.10.1-canary.44+8a2e00f8", | ||
"description": "ESLint plugin for Spruce Javascript projects", | ||
@@ -21,3 +21,3 @@ "author": "George Pantazis <gcpantazis@gmail.com>", | ||
}, | ||
"gitHead": "421ecfef7423c3d5df7999a91fd0ba79aea153f7" | ||
"gitHead": "8a2e00f84491aa3ebaea124fb3dcf9acb3cafe71" | ||
} |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
3321