Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-uilib

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-uilib - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

tests/lib/rules/no-direct-import.js

35

lib/rules/no-direct-import.js

@@ -0,1 +1,14 @@

const MAP_SCHEMA = {
type: 'object',
properties: {
origin: {
type: 'string'
},
destination: {
type: 'string'
}
},
additionalProperties: false
};
module.exports = {

@@ -9,6 +22,8 @@ meta: {

messages: {
uiLib: "Do not import directly from the open source project. Please use 'wix-react-native-ui-lib' (autofix available).",
uiLib: "Do not import directly from this source. Please use another import source (autofix available).",
},
fixable: 'code',
schema: [],
schema: [
MAP_SCHEMA
],
},

@@ -19,3 +34,5 @@ create(context) {

try {
const msg = "Do not import directly from the open source project. Please use 'wix-react-native-ui-lib' (autofix available).";
const origin = context.options[0].origin;
const destination = context.options[0].destination;
const msg = `Do not import directly from '${origin}'. Please use '${destination}' (autofix available).`;
context.report({

@@ -25,5 +42,4 @@ node,

fix(fixer) {
if (node) {
const source = options[0];
return fixer.replaceText(node.source, `'wix-${source}'`);
if (node && destination) {
return fixer.replaceText(node.source, `'${destination}'`);
}

@@ -38,5 +54,6 @@ },

function checkImportDeclaretion(node) {
const origin = context.options[0].origin;
const source = node.source.value;
if (source && source === 'react-native-ui-lib') {
reportDirectImport(node, [source]);
if (source && origin && source === origin) {
reportDirectImport(node);
}

@@ -49,2 +66,2 @@ }

}
};
};
{
"name": "eslint-plugin-uilib",
"version": "1.0.8",
"version": "1.0.9",
"description": "uilib set of eslint rules",

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

[
{
"component": "Avatar",
"source": "module-with-deprecations",
"message": "",
"props": [
{
"prop": "color",
"message": "Please use the 'backgroundColor' prop instead.",
"fix": "backgroundColor"
"prop": "url",
"message": "Please use the 'imageSource' prop instead."
}

@@ -11,0 +11,0 @@ ]

@@ -14,4 +14,5 @@ const RuleTester = require('eslint').RuleTester;

const valideExample = 'const test = <Avatar backgroundColor={Colors.red30}/>';
const invalideExample = 'const test = <Avatar color={Colors.red30}/>';
const valideExample = `const test = <Avatar imageSource={{uri: 'some_uri_string'}}/>`;
const valideImportExample = `import {Avatar} from 'another-module'; const test = <Avatar url={'some_uri_string'}/>`;
const invalideExample = `import {Avatar} from 'module-with-deprecations'; const test = <Avatar url={'some_uri_string'}/>`;

@@ -24,2 +25,6 @@ ruleTester.run('component-deprecation', rule, {

},
{
options: ruleOptions,
code: valideImportExample,
},
],

@@ -31,3 +36,3 @@ invalid: [

errors: [
{ message: 'The \'Avatar\' component\'s prop \'color\' is deprecated. Please use the \'backgroundColor\' prop instead.' },
{ message: `The 'Avatar' component's prop 'url' is deprecated. Please use the 'imageSource' prop instead.` },
],

@@ -39,3 +44,3 @@ },

errors: [
{ message: 'The \'Avatar\' component\'s prop \'color\' is deprecated. Please use the \'backgroundColor\' prop instead. Please fix this issue by 10/11/18!' },
{ message: `The 'Avatar' component's prop 'url' is deprecated. Please use the 'imageSource' prop instead. Please fix this issue by 10/11/18!` },
],

@@ -42,0 +47,0 @@ },

@@ -1,2 +0,1 @@

const Colors = require('../../../../src/style/colorsPalette').colorsPalette;

@@ -3,0 +2,0 @@ const extraFixColorsMap = require('../../../../src/style/colorsPalette').extraFixColorsMap;

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