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 2.1.6 to 2.1.7

31

lib/rules/function-deprecation.js
const _ = require("lodash");
const {handleError} = require('../utils');
const {addToImports, handleError} = require('../utils');

@@ -101,2 +101,3 @@ const RULE_ID = 'function-deprecation';

let everythingIsImported = false;
const imports = [];

@@ -114,2 +115,3 @@ function getDeprecation(value) {

function searchForPossibleDeprecation(node) {
addToImports(node, imports)
const importSource = node.source.value;

@@ -211,7 +213,24 @@ if (source === importSource) {

} else {
reportDeprecatedFunction(node, {
name: relevantDeprecation.deprecation.function,
message: relevantDeprecation.deprecation.message,
fix: relevantDeprecation.deprecation.fix,
});
const calleeType = _.get(node, 'callee.type');
const caller = _.get(node, 'callee.object.name');
if (calleeType === 'Identifier') {
reportDeprecatedFunction(node, {
name: relevantDeprecation.deprecation.function,
message: relevantDeprecation.deprecation.message,
fix: relevantDeprecation.deprecation.fix,
});
} else if (calleeType === 'MemberExpression' && caller) {
imports.forEach(currentImport => {
if (
Object.values(currentImport)[0][caller] &&
Object.keys(currentImport)[0] === relevantDeprecation.deprecation.source
) {
reportDeprecatedFunction(node, {
name: relevantDeprecation.deprecation.function,
message: relevantDeprecation.deprecation.message,
fix: relevantDeprecation.deprecation.fix,
});
}
});
}
}

@@ -218,0 +237,0 @@ }

2

package.json
{
"name": "eslint-plugin-uilib",
"version": "2.1.6",
"version": "2.1.7",
"description": "uilib set of eslint rules",

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

@@ -28,3 +28,12 @@ [

"message": "please stop using it."
},
{
"function": "deprecatedFunction2",
"message": "please stop using it."
},
{
"function": "deprecatedFunction3",
"source": "our-source",
"message": "please stop using it."
}
]

@@ -212,2 +212,16 @@ const RuleTester = require('eslint').RuleTester;

},
{
options: options,
code: `
import {a, c} from '${ourSource}';
import {b} from '${notOurSource}';
b.deprecatedFunction2();`
},
{
options: options,
code: `
import {a, c} from '${ourSource}';
import {b} from '${notOurSource}';
b.deprecatedFunction3();`
},
],

@@ -331,3 +345,11 @@ invalid: [

},
{
options: options,
code: `
import {a, c} from '${ourSource}';
import {b} from '${notOurSource}';
a.deprecatedFunction3();`,
errors: [{message: `The 'deprecatedFunction3' function is deprecated. please stop using it.`}]
},
],
});

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

const bigExampleValid = fs.readFileSync('../demo/src/screens/componentScreens/ChipScreen.tsx', 'utf8');
const bigExampleError = fs.readFileSync('../demo/src/screens/componentScreens/PickerScreen.js', 'utf8');
// TODO: parsing error
// const bigExampleError = fs.readFileSync('../demo/src/screens/componentScreens/PickerScreen.tsx', 'utf8');

@@ -201,13 +202,13 @@ RuleTester.setDefaultConfig({

},
// {
// options: ruleOptions,
// code: bigExampleError,
// errors: [
// {
// message: `The shape of 'pannableHeaderProps' prop of 'Dialog' doesn't contain 'title' anymore. Please use 'header' instead (fix is available).`
// }
// ]
// },
{
options: ruleOptions,
code: bigExampleError,
errors: [
{
message: `The shape of 'pannableHeaderProps' prop of 'Dialog' doesn't contain 'title' anymore. Please use 'header' instead (fix is available).`
}
]
},
{
options: ruleOptions,
code: `

@@ -214,0 +215,0 @@ import {Label} from 'our-source';

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