New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-react-native

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-native - npm Package Compare versions

Comparing version 3.7.0 to 3.8.0

lib/rules/no-single-element-style-arrays.js

2

index.js

@@ -12,2 +12,3 @@ /* eslint-disable global-require */

'no-raw-text': require('./lib/rules/no-raw-text'),
'no-single-element-style-arrays': require('./lib/rules/no-single-element-style-arrays'),
};

@@ -38,2 +39,3 @@

'no-raw-text': 0,
'no-single-element-style-arrays': 0
},

@@ -40,0 +42,0 @@ environments: {

4

lib/rules/no-color-literals.js

@@ -12,4 +12,4 @@ /**

const StyleSheets = styleSheet.StyleSheets;
const astHelpers = styleSheet.astHelpers;
const { StyleSheets } = styleSheet;
const { astHelpers } = styleSheet;

@@ -16,0 +16,0 @@ module.exports = Components.detect((context) => {

@@ -12,4 +12,4 @@ /**

const StyleSheets = styleSheet.StyleSheets;
const astHelpers = styleSheet.astHelpers;
const { StyleSheets } = styleSheet;
const { astHelpers } = styleSheet;

@@ -16,0 +16,0 @@ module.exports = Components.detect((context) => {

@@ -11,7 +11,7 @@ /**

const elementName = node => (
node.openingElement &&
node.openingElement.name &&
node.openingElement.name.type === 'JSXIdentifier' &&
node.openingElement.name.name
const elementName = (node) => (
node.openingElement
&& node.openingElement.name
&& node.openingElement.name.type === 'JSXIdentifier'
&& node.openingElement.name.name
);

@@ -37,5 +37,5 @@

const hasOnlyLineBreak = value => /^[\r\n\t\f\v]+$/.test(value.replace(/ /g, ''));
const hasOnlyLineBreak = (value) => /^[\r\n\t\f\v]+$/.test(value.replace(/ /g, ''));
const getValidation = node => !allowedElements.includes(elementName(node.parent));
const getValidation = (node) => !allowedElements.includes(elementName(node.parent));

@@ -46,6 +46,6 @@ return {

const onlyFor = ['JSXExpressionContainer', 'JSXElement'];
if (typeof node.value !== 'string' ||
hasOnlyLineBreak(node.value) ||
!onlyFor.includes(parentType) ||
(node.parent.parent && node.parent.parent.type === 'JSXAttribute')
if (typeof node.value !== 'string'
|| hasOnlyLineBreak(node.value)
|| !onlyFor.includes(parentType)
|| (node.parent.parent && node.parent.parent.type === 'JSXAttribute')
) return;

@@ -68,4 +68,4 @@

if (
node.parent.type !== 'JSXExpressionContainer' ||
(node.parent.parent && node.parent.parent.type === 'JSXAttribute')
node.parent.type !== 'JSXExpressionContainer'
|| (node.parent.parent && node.parent.parent.type === 'JSXAttribute')
) return;

@@ -72,0 +72,0 @@

@@ -11,4 +11,4 @@ /**

const StyleSheets = styleSheet.StyleSheets;
const astHelpers = styleSheet.astHelpers;
const { StyleSheets } = styleSheet;
const { astHelpers } = styleSheet;

@@ -15,0 +15,0 @@ module.exports = Components.detect((context, components) => {

@@ -29,4 +29,4 @@ /**

const options = context.options[1] || {};
const ignoreClassNames = options.ignoreClassNames;
const ignoreStyleProperties = options.ignoreStyleProperties;
const { ignoreClassNames } = options;
const { ignoreStyleProperties } = options;
const isValidOrder = order === 'asc' ? (a, b) => a <= b : (a, b) => a >= b;

@@ -44,3 +44,3 @@

return a.range[0] - b.range[0];
} else if (identifierA < identifierB) {
} if (identifierA < identifierB) {
sortOrder = -1;

@@ -58,6 +58,5 @@ } else if (identifierA > identifierB) {

const hasComments = array
.map(prop => sourceCode.getComments(prop))
.map((prop) => sourceCode.getComments(prop))
.reduce(
(hasComment, comment) =>
hasComment || comment.leading.length > 0 || comment.trailing > 0,
(hasComment, comment) => hasComment || comment.leading.length > 0 || comment.trailing > 0,
false

@@ -100,4 +99,4 @@ );

if (
arrayName === 'style properties' &&
isEitherShortHand(prevName, currentName)
arrayName === 'style properties'
&& isEitherShortHand(prevName, currentName)
) {

@@ -104,0 +103,0 @@ return;

@@ -25,3 +25,3 @@ /**

return key.type === 'Identifier' ? key.name : key.value;
} else if (node.type === 'Identifier') {
} if (node.type === 'Identifier') {
return node.name;

@@ -40,4 +40,4 @@ }

const containsAndroidAndIOS = (
hasNodeWithName(components, 'IOS') &&
hasNodeWithName(components, 'Android')
hasNodeWithName(components, 'IOS')
&& hasNodeWithName(components, 'Android')
);

@@ -44,0 +44,0 @@

@@ -67,3 +67,3 @@ /**

const id = this.getId(currentNode);
this.list[id] = Object.assign({}, this.list[id], props);
this.list[id] = { ...this.list[id], ...props };
};

@@ -155,13 +155,8 @@

const returnsJSX =
node[property] &&
node[property].type === 'JSXElement'
;
const returnsReactCreateElement =
node[property] &&
node[property].callee &&
node[property].callee.property &&
node[property].callee.property.name === 'createElement'
;
const returnsJSX = node[property]
&& node[property].type === 'JSXElement';
const returnsReactCreateElement = node[property]
&& node[property].callee
&& node[property].callee.property
&& node[property].callee.property.name === 'createElement';
return Boolean(returnsJSX || returnsReactCreateElement);

@@ -177,5 +172,5 @@ },

return (
utils.getParentES6Component() ||
utils.getParentES5Component() ||
utils.getParentStatelessComponent()
utils.getParentES6Component()
|| utils.getParentES5Component()
|| utils.getParentStatelessComponent()
);

@@ -190,2 +185,3 @@ },

getParentES5Component: function () {
// eslint-disable-next-line react/destructuring-assignment
let scope = context.getScope();

@@ -225,2 +221,3 @@ while (scope) {

getParentStatelessComponent: function () {
// eslint-disable-next-line react/destructuring-assignment
let scope = context.getScope();

@@ -274,3 +271,3 @@ while (scope) {

let variableInScope;
const variables = context.getScope().variables;
const { variables } = context.getScope();
for (i = 0, j = variables.length; i < j; i++) { // eslint-disable-line no-plusplus

@@ -288,8 +285,8 @@ if (variables[i].name === variableName) {

let defInScope;
const defs = variableInScope.defs;
const { defs } = variableInScope;
for (i = 0, j = defs.length; i < j; i++) { // eslint-disable-line no-plusplus
if (
defs[i].type === 'ClassName' ||
defs[i].type === 'FunctionName' ||
defs[i].type === 'Variable'
defs[i].type === 'ClassName'
|| defs[i].type === 'FunctionName'
|| defs[i].type === 'Variable'
) {

@@ -402,3 +399,3 @@ defInScope = defs[i];

const ruleInstructions = rule(context, components, utils);
const updatedRuleInstructions = Object.assign({}, ruleInstructions);
const updatedRuleInstructions = { ...ruleInstructions };
Object.keys(detectionInstructions).forEach((instruction) => {

@@ -405,0 +402,0 @@ updatedRuleInstructions[instruction] = (node) => {

@@ -37,3 +37,3 @@

.styleSheets[styleSheetName]
.filter(property => property.key.name !== styleSheetProperty);
.filter((property) => property.key.name !== styleSheetProperty);
}

@@ -92,8 +92,7 @@ };

let currentContent;
const getSourceCode = node => currentContent
const getSourceCode = (node) => currentContent
.getSourceCode(node)
.getText(node);
const getStyleSheetObjectNames = settings =>
settings['react-native/style-sheet-object-names'] || ['StyleSheet'];
const getStyleSheetObjectNames = (settings) => settings['react-native/style-sheet-object-names'] || ['StyleSheet'];

@@ -103,8 +102,8 @@ const astHelpers = {

return Boolean(
node &&
node.type === 'CallExpression' &&
node.callee &&
node.callee.object &&
node.callee.object.name &&
objectNames.includes(node.callee.object.name)
node
&& node.type === 'CallExpression'
&& node.callee
&& node.callee.object
&& node.callee.object.name
&& objectNames.includes(node.callee.object.name)
);

@@ -115,6 +114,6 @@ },

return Boolean(
node &&
node.callee &&
node.callee.property &&
node.callee.property.name === 'create'
node
&& node.callee
&& node.callee.property
&& node.callee.property.name === 'create'
);

@@ -127,4 +126,4 @@ },

return Boolean(
astHelpers.containsStyleSheetObject(node, objectNames) &&
astHelpers.containsCreateCall(node)
astHelpers.containsStyleSheetObject(node, objectNames)
&& astHelpers.containsCreateCall(node)
);

@@ -141,9 +140,9 @@ },

if (
node &&
node.type === 'CallExpression' &&
node.arguments &&
node.arguments[0] &&
node.arguments[0].properties
node
&& node.type === 'CallExpression'
&& node.arguments
&& node.arguments[0]
&& node.arguments[0].properties
) {
return node.arguments[0].properties.filter(property => property.type === 'Property');
return node.arguments[0].properties.filter((property) => property.type === 'Property');
}

@@ -156,9 +155,9 @@

if (
node &&
node.type === 'CallExpression' &&
node.arguments &&
node.arguments[0] &&
node.arguments[0].properties
node
&& node.type === 'CallExpression'
&& node.arguments
&& node.arguments[0]
&& node.arguments[0].properties
) {
const properties = node.arguments[0].properties;
const { properties } = node.arguments[0];

@@ -213,4 +212,4 @@ const result = [];

+ quasi.value.cooked
+ astHelpers.getExpressionIdentifier(node.expressions[index])
, '');
+ astHelpers.getExpressionIdentifier(node.expressions[index]),
'');
default:

@@ -226,4 +225,4 @@ return '';

if (
node &&
node.key
node
&& node.key
) {

@@ -236,6 +235,6 @@ return astHelpers.getExpressionIdentifier(node.key);

return Boolean(
node.type === 'JSXAttribute' &&
node.name &&
node.name.name &&
node.name.name.toLowerCase().includes('style')
node.type === 'JSXAttribute'
&& node.name
&& node.name.name
&& node.name.name.toLowerCase().includes('style')
);

@@ -254,3 +253,3 @@ },

);
} else if (node && node.expression) {
} if (node && node.expression) {
return astHelpers.getStyleObjectExpressionFromNode(node.expression);

@@ -385,5 +384,5 @@ }

return node && Boolean(
node.type === 'JSXExpressionContainer' &&
node.expression &&
node.expression.type === 'ArrayExpression'
node.type === 'JSXExpressionContainer'
&& node.expression
&& node.expression.type === 'ArrayExpression'
);

@@ -460,5 +459,5 @@ },

if (
node &&
node.object &&
node.object.name
node
&& node.object
&& node.object.name
) {

@@ -471,5 +470,5 @@ return node.object.name;

if (
node &&
node.property &&
node.property.name
node
&& node.property
&& node.property.name
) {

@@ -482,10 +481,10 @@ return node.property.name;

if (
node &&
node.object &&
node.object.type === 'Identifier' &&
node.object.name &&
node.property &&
node.property.type === 'Identifier' &&
node.property.name &&
node.parent.type !== 'MemberExpression'
node
&& node.object
&& node.object.type === 'Identifier'
&& node.object.name
&& node.property
&& node.property.type === 'Identifier'
&& node.property.name
&& node.parent.type !== 'MemberExpression'
) {

@@ -500,3 +499,3 @@ return [node.object.name, node.property.name].join('.');

return property2.startsWith(property1);
} else if (shorthands.includes(property2)) {
} if (shorthands.includes(property2)) {
return property1.startsWith(property2);

@@ -503,0 +502,0 @@ }

@@ -24,3 +24,3 @@ /**

while (scope.childScopes.length) {
scope = scope.childScopes[0];
([scope] = scope.childScopes);
}

@@ -73,3 +73,3 @@ }

let scope = context.getScope();
let variables = scope.variables;
let { variables } = scope;

@@ -76,0 +76,0 @@ while (scope.type !== 'global') {

{
"name": "eslint-plugin-react-native",
"version": "3.7.0",
"version": "3.8.0",
"author": "Tom Hastjarjanto <tom@intellicode.nl>",

@@ -26,16 +26,16 @@ "description": "React Native specific linting rules for ESLint",

"devDependencies": {
"@typescript-eslint/parser": "^1.4.2",
"babel-eslint": "10.0.1",
"coveralls": "^3.0.3",
"eslint": "^5.16.0",
"eslint-config-airbnb": "15.1.0",
"eslint-plugin-import": "^2.0.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0",
"@typescript-eslint/parser": "^2.0.0",
"babel-eslint": "^10.0.3",
"coveralls": "^3.0.7",
"eslint": "^6.5.1",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.16.0",
"mocha": "^5.2.0",
"nyc": "^14.0.0",
"typescript": "^3.3.3333"
"nyc": "^14.1.1",
"typescript": "^3.6.4"
},
"peerDependencies": {
"eslint": "^3.17.0 || ^4 || ^5"
"eslint": "^3.17.0 || ^4 || ^5 | ^6"
},

@@ -42,0 +42,0 @@ "keywords": [

@@ -85,2 +85,3 @@

"react-native/no-raw-text": 2,
"react-native/no-single-element-style-arrays": 2,
}

@@ -98,2 +99,3 @@ }

* [no-raw-text](docs/rules/no-raw-text.md): Detect raw text outside of `Text` component
* [no-single-element-style-arrays](docs/rules/no-raw-text.md): No style arrays that have 1 element only `<View style={[{height: 10}]}/>`

@@ -100,0 +102,0 @@ [npm-url]: https://npmjs.org/package/eslint-plugin-react-native

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc