eslint-plugin-uilib
Advanced tools
Comparing version 2.1.6 to 2.1.7
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 @@ } |
{ | ||
"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'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164067
4652