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

eslint-plugin-uilib

Package Overview
Dependencies
Maintainers
3
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.27 to 1.0.28

8

lib/rules/no-direct-import.js

@@ -34,6 +34,6 @@ const MAP_SCHEMA = {

const destination = context.options[0].destination;
const msg = `Do not import directly from '${origin}'. Please use '${destination}' (autofix available).`;
const message = `Do not import directly from '${origin}'. Please use '${destination}' (autofix available).`;
context.report({
node,
message: `${msg}`,
message,
fix(fixer) {

@@ -50,3 +50,3 @@ if (node && destination) {

function checkImportDeclaretion(node) {
function checkImportDeclaration(node) {
const origin = context.options[0].origin;

@@ -60,5 +60,5 @@ const source = node.source.value;

return {
ImportDeclaration: node => checkImportDeclaretion(node),
ImportDeclaration: checkImportDeclaration
};
},
};

@@ -51,6 +51,17 @@ const _ = require('lodash');

function isComponentRelevant(node, components) {
let isComponentRelevant = true;
if (!_.isEmpty(components)) {
if (_.get(node, 'parent.type') === 'JSXOpeningElement') {
return components.includes(_.get(node, 'parent.name.name'));
}
}
return isComponentRelevant;
}
function findAndReportDeprecation(node, possibleDeprecation, useShortVersion) {
const path = `${defaultImportName}.${possibleDeprecation}`;
const foundDeprecation = _.find(deprecations, {path});
if (foundDeprecation) {
if (foundDeprecation && isComponentRelevant(node, foundDeprecation.components)) {
reportDeprecatedTypography(node, foundDeprecation, useShortVersion);

@@ -57,0 +68,0 @@ }

{
"name": "eslint-plugin-uilib",
"version": "1.0.27",
"version": "1.0.28",
"description": "uilib set of eslint rules",

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

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

const valideExample = `import {Component} from 'another-module';`;
const invalideExample = `import {Component} from 'some-module';`;
const validExample = `import {Component} from 'another-module';`;
const invalidExample = `import {Component} from 'some-module';`;

@@ -21,3 +21,3 @@ ruleTester.run('no-direct-import', rule, {

options: ruleOptions,
code: valideExample,
code: validExample,
},

@@ -28,3 +28,4 @@ ],

options: ruleOptions,
code: invalideExample,
code: invalidExample,
output: `import {Component} from 'another-module';`,
errors: [

@@ -31,0 +32,0 @@ { message: `Do not import directly from 'some-module'. Please use 'another-module' (autofix available).` },

@@ -315,2 +315,82 @@ const RuleTester = require('eslint').RuleTester;

code: `${fullClassValidRenamed}`,
},
{
options: options,
code: `
${ourImport}
import {List} from 'another-source';
<List.Item title={'bla'} />`
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography} from 'our-source';
import {List} from 'another-source';
export default class OurList extends Component {
render() {
const titleVal = 'bla';
return (
<List.Item title={titleVal}/>
)
}
}`
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, List} from 'our-source';
export default class OurList extends Component {
render() {
const titleVal = 'bla';
return (
<List.Item title={titleVal}/>
)
}
}`
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, List} from 'our-source';
export default class OurList extends Component {
render() {
const titleVal = this.props.title;
const subtitleVal = this.props.subtitle;
return (
<List.Item title={titleVal} subtitle={subtitleVal}/>
)
}
}`
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, List} from 'our-source';
export default class OurList extends Component {
render() {
const {title, subtitle} = this.props;
return (
<List.Item title={title} subtitle={subtitle}/>
)
}
}`
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, List} from 'our-source';
export default class OurList extends Component {
render() {
const {title: titleVal, subtitle: subtitleVal} = this.props;
return (
<List.Item title={titleVal} subtitle={subtitleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
}

@@ -443,4 +523,194 @@ ],

errors: [{message: error}]
}
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, Text} from 'our-source';
export default class OurList extends Component {
render() {
const titleVal = true;
return (
<Text title={titleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, Text} from 'our-source';
export default class OurList extends Component {
render() {
const {isTitle} = this.props;
const titleVal = this.props.isTitle;
const subtitleVal = !this.props.isTitle;
return (
<Text title={titleVal} subtitle={subtitleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, Text} from 'our-source';
export default class OurList extends Component {
render() {
const {isTitle} = this.props;
const titleVal = isTitle;
const subtitleVal = !isTitle;
return (
<Text title={titleVal} subtitle={subtitleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, TextField} from 'our-source';
export default class OurList extends Component {
render() {
const titleVal = true;
return (
<TextField title={titleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, TextField} from 'our-source';
export default class OurList extends Component {
render() {
const {isTitle} = this.props;
const titleVal = this.props.isTitle;
const subtitleVal = !this.props.isTitle;
return (
<TextField title={titleVal} subtitle={subtitleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
{
options: options,
code: `
import React, {Component} from 'react';
import {Typography, TextField} from 'our-source';
export default class OurList extends Component {
render() {
const {isTitle} = this.props;
const titleVal = isTitle;
const subtitleVal = !isTitle;
return (
<TextField title={titleVal} subtitle={subtitleVal}/>
)
}
}`,
errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
},
// TODO: these tests are not currently supported, they might be supported when prop-value-shape-deprecation is merged (or we'll have to add support)
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, Button} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <Button labelProps={{title: titleVal}}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, Button} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <Button title={titleVal}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, Card} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <Card.Section content={{title: titleVal}}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, TabBar} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <TabBar labelStyle={{title: titleVal}} selectedLabelStyle={{title: titleVal}}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, Label} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <Label labelProps={{title: titleVal}}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
// TODO: this is not currently supported, it should be easily supported after the new utils are added
// {
// options: options,
// code: `
// import React, {Component} from 'react';
// import {Typography, Text as T} from 'our-source';
// export default class OurList extends Component {
// render() {
// const titleVal = true;
// return (
// <T title={titleVal}/>
// )
// }
// }`,
// errors: [{message: `'Typography.title' is deprecated. Please use 'Typography.heading' instead (fix is available).`}]
// },
],
});

@@ -6,3 +6,9 @@ [

"fix": "Typography.valid"
},
{
"path": "Typography.title",
"message": "Please use 'Typography.heading' instead (fix is available).",
"fix": "Typography.heading",
"components": ["Text", "TextField"]
}
]
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