eslint-plugin-react-native
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -5,3 +5,5 @@ /** | ||
*/ | ||
'use strict'; | ||
const util = require('util'); | ||
@@ -14,3 +16,3 @@ const Components = require('../util/Components'); | ||
module.exports = Components.detect(context => { | ||
module.exports = Components.detect((context) => { | ||
const styleSheets = new StyleSheets(); | ||
@@ -20,3 +22,3 @@ | ||
if (colorLiterals) { | ||
colorLiterals.forEach(style => { | ||
colorLiterals.forEach((style) => { | ||
if (style) { | ||
@@ -35,3 +37,3 @@ const expression = util.inspect(style.expression); | ||
return { | ||
VariableDeclarator: node => { | ||
VariableDeclarator: (node) => { | ||
if (astHelpers.isStyleSheetDeclaration(node)) { | ||
@@ -41,3 +43,3 @@ const styles = astHelpers.getStyleDeclarations(node); | ||
if (styles) { | ||
styles.forEach(style => { | ||
styles.forEach((style) => { | ||
const literals = astHelpers.collectColorLiterals(style.value, context); | ||
@@ -50,3 +52,3 @@ styleSheets.addColorLiterals(literals); | ||
JSXAttribute: node => { | ||
JSXAttribute: (node) => { | ||
if (astHelpers.isStyleAttribute(node)) { | ||
@@ -53,0 +55,0 @@ const literals = astHelpers.collectColorLiterals(node.value, context); |
@@ -5,3 +5,5 @@ /** | ||
*/ | ||
'use strict'; | ||
const util = require('util'); | ||
@@ -14,3 +16,3 @@ const Components = require('../util/Components'); | ||
module.exports = Components.detect(context => { | ||
module.exports = Components.detect((context) => { | ||
const styleSheets = new StyleSheets(); | ||
@@ -20,3 +22,3 @@ | ||
if (inlineStyles) { | ||
inlineStyles.forEach(style => { | ||
inlineStyles.forEach((style) => { | ||
if (style) { | ||
@@ -35,3 +37,3 @@ const expression = util.inspect(style.expression); | ||
return { | ||
JSXAttribute: node => { | ||
JSXAttribute: (node) => { | ||
if (astHelpers.isStyleAttribute(node)) { | ||
@@ -38,0 +40,0 @@ const styles = astHelpers.collectStyleObjectExpressions(node.value, context); |
@@ -5,3 +5,5 @@ /** | ||
*/ | ||
'use strict'; | ||
const Components = require('../util/Components'); | ||
@@ -36,2 +38,9 @@ const styleSheet = require('../util/stylesheet'); | ||
return { | ||
MemberExpression: function (node) { | ||
const styleRef = astHelpers.getPotentialStyleReferenceFromMemberExpression(node); | ||
if (styleRef) { | ||
styleReferences.add(styleRef); | ||
} | ||
}, | ||
VariableDeclarator: function (node) { | ||
@@ -46,11 +55,2 @@ if (astHelpers.isStyleSheetDeclaration(node)) { | ||
JSXAttribute: function (node) { | ||
if (astHelpers.isStyleAttribute(node)) { | ||
const styles = astHelpers.collectStyleReferences(node.value); | ||
styles.forEach((style) => { | ||
styleReferences.add(style); | ||
}); | ||
} | ||
}, | ||
'Program:exit': function () { | ||
@@ -57,0 +57,0 @@ const list = components.all(); |
@@ -6,2 +6,3 @@ /** | ||
*/ | ||
'use strict'; | ||
@@ -33,4 +34,3 @@ | ||
for (let i = 0; i < components.length; i++) { | ||
const node = components[i]; | ||
components.forEach((node) => { | ||
const propName = getKeyValue(node); | ||
@@ -45,3 +45,3 @@ | ||
} | ||
} | ||
}); | ||
} | ||
@@ -48,0 +48,0 @@ |
@@ -5,2 +5,3 @@ /** | ||
*/ | ||
'use strict'; | ||
@@ -96,3 +97,3 @@ | ||
if ({}.hasOwnProperty.call(this.list, i) && this.list[i].confidence >= 2) { | ||
length++; | ||
length += 1; | ||
} | ||
@@ -271,3 +272,3 @@ }); | ||
const variables = context.getScope().variables; | ||
for (i = 0, j = variables.length; i < j; i++) { | ||
for (i = 0, j = variables.length; i < j; i++) { // eslint-disable-line no-plusplus | ||
if (variables[i].name === variableName) { | ||
@@ -285,3 +286,3 @@ variableInScope = variables[i]; | ||
const defs = variableInScope.defs; | ||
for (i = 0, j = defs.length; i < j; i++) { | ||
for (i = 0, j = defs.length; i < j; i++) { // eslint-disable-line no-plusplus | ||
if ( | ||
@@ -302,7 +303,7 @@ defs[i].type === 'ClassName' || | ||
// Traverse the node properties to the component declaration | ||
for (i = 0, j = componentPath.length; i < j; i++) { | ||
for (i = 0, j = componentPath.length; i < j; i++) { // eslint-disable-line no-plusplus | ||
if (!currentNode.properties) { | ||
continue; // eslint-disable-line no-continue | ||
} | ||
for (k = 0, l = currentNode.properties.length; k < l; k++) { | ||
for (k = 0, l = currentNode.properties.length; k < l; k++) { // eslint-disable-line no-plusplus, max-len | ||
if (currentNode.properties[k].key.name === componentPath[i]) { | ||
@@ -309,0 +310,0 @@ currentNode = currentNode.properties[k]; |
@@ -0,2 +1,4 @@ | ||
'use strict'; | ||
/** | ||
@@ -35,3 +37,3 @@ * StyleSheets represents the StyleSheets found in the source code. | ||
.styleSheets[styleSheetName] | ||
.filter((property) => property.key.name !== styleSheetProperty); | ||
.filter(property => property.key.name !== styleSheetProperty); | ||
} | ||
@@ -157,16 +159,2 @@ }; | ||
collectStyleReferences: function (node) { | ||
if (astHelpers.hasArrayOfStyleReferences(node)) { | ||
const styleReferenceContainers = node | ||
.expression | ||
.elements; | ||
return astHelpers.collectStyleReferencesFromContainers( | ||
styleReferenceContainers | ||
); | ||
} | ||
return astHelpers.getStyleReferenceFromNode(node.expression); | ||
}, | ||
collectStyleObjectExpressions: function (node, context) { | ||
@@ -210,13 +198,5 @@ currentContent = context; | ||
collectStyleReferencesFromContainers: function (nodes) { | ||
let styleReferences = []; | ||
nodes.forEach(node => { | ||
styleReferences = styleReferences.concat(astHelpers.getStyleReferenceFromNode(node)); | ||
}); | ||
return styleReferences; | ||
}, | ||
collectStyleObjectExpressionFromContainers: function (nodes) { | ||
let objectExpressions = []; | ||
nodes.forEach(node => { | ||
nodes.forEach((node) => { | ||
objectExpressions = objectExpressions | ||
@@ -231,3 +211,3 @@ .concat(astHelpers.getStyleObjectExpressionFromNode(node)); | ||
let colorLiterals = []; | ||
nodes.forEach(node => { | ||
nodes.forEach((node) => { | ||
colorLiterals = colorLiterals | ||
@@ -345,3 +325,3 @@ .concat(astHelpers.getColorLiteralsFromNode(node)); | ||
if (node.properties && node.properties.length) { | ||
node.properties.forEach(p => { | ||
node.properties.forEach((p) => { | ||
if (!p.value || !p.key) { | ||
@@ -375,3 +355,3 @@ return; | ||
if (node.properties && node.properties.length) { | ||
node.properties.forEach(p => { | ||
node.properties.forEach((p) => { | ||
if (p.key && p.key.name && p.key.name.toLowerCase().indexOf('color') !== -1) { | ||
@@ -413,2 +393,17 @@ if (p.value.type === 'Literal') { | ||
}, | ||
getPotentialStyleReferenceFromMemberExpression: function (node) { | ||
if ( | ||
node && | ||
node.object && | ||
node.object.type === 'Identifier' && | ||
node.object.name && | ||
node.property && | ||
node.property.type === 'Identifier' && | ||
node.property.name && | ||
node.parent.type !== 'MemberExpression' | ||
) { | ||
return [node.object.name, node.property.name].join('.'); | ||
} | ||
}, | ||
}; | ||
@@ -415,0 +410,0 @@ |
@@ -5,2 +5,3 @@ /** | ||
*/ | ||
'use strict'; | ||
@@ -30,3 +31,3 @@ | ||
variables = scope.variables; | ||
for (i = 0, len = variables.length; i < len; i++) { | ||
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus | ||
if (variables[i].name === name) { | ||
@@ -53,3 +54,3 @@ variables[i].eslintUsed = true; | ||
for (i = 0, len = variables.length; i < len; i++) { | ||
for (i = 0, len = variables.length; i < len; i++) { // eslint-disable-line no-plusplus | ||
if (variables[i].name === name) { | ||
@@ -56,0 +57,0 @@ return true; |
{ | ||
"name": "eslint-plugin-react-native", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"author": "Tom Hastjarjanto <tom@intellicode.nl>", | ||
@@ -26,8 +26,8 @@ "description": "React Native specific linting rules for ESLint", | ||
"dependencies": { | ||
"eslint": "3.10.2", | ||
"babel-eslint": "7.1.0" | ||
"eslint": "3.11.0", | ||
"babel-eslint": "7.1.1" | ||
}, | ||
"devDependencies": { | ||
"coveralls": "2.11.15", | ||
"eslint-config-airbnb": "10.0.1", | ||
"eslint-config-airbnb": "13.0.0", | ||
"eslint-plugin-import": "^2.0.0", | ||
@@ -37,3 +37,3 @@ "eslint-plugin-jsx-a11y": "2.2.2", | ||
"istanbul": "0.4.4", | ||
"mocha": "3.1.2" | ||
"mocha": "3.2.0" | ||
}, | ||
@@ -40,0 +40,0 @@ "keywords": [ |
38721
1041
+ Addedbabel-eslint@7.1.1(transitive)
+ Addedeslint@3.11.0(transitive)
- Removedbabel-eslint@7.1.0(transitive)
- Removedeslint@3.10.2(transitive)
Updatedbabel-eslint@7.1.1
Updatedeslint@3.11.0