How can i see all my deprecated methods functions in react native? i have a old react native project and its not working fine errors are coming one by one so i updated all of my packages which were outdated but after that many errors are coming too while running the project
i tired to fix some but now i get to know that my projects and many deprecated functions and it become very hard to solve one by one i do have many files in one project, So is their any easy way so see all deprecated functions methods variables etc. i do run npm outdated to see deprecated npm packages but it was not a solution..
i dont want my code updated i just want to search or see that what functions and methods are deprecated
CodePudding user response:
Well, honestly there's no way to actually make your code updated because you have deprecated functions.
It's better to solve them one by one I guess.
CodePudding user response:
eslint-plugin-deprecation lets deprecated functions and more be shown.
Install it with npm i -D eslint-plugin-deprecation
. If not already installed, install just enough Typescript to run make this ESLint plugin work but not so much to force the whole project to use it: npm i -D [email protected] @types/jest @types/react @types/react-native @types/react-test-renderer @tsconfig/react-native
. This is a subset of the official guide.
Create tsconfig.json
if it doesn't exist:
{
"extends": "@tsconfig/react-native/tsconfig.json"
}
Replace or add to .eslintrc.js
:
module.exports = {
root: true,
extends: '@react-native-community',
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"project": "./tsconfig.json"
},
"plugins": ["deprecation"],
"rules": {
"deprecation/deprecation": "warn",
},
};
Create .eslintignore
:
.eslintrc.js
As an example, add and use a deprecated function in a newly created project's App.js:
// ...
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
/**
* @deprecated
*/
function dontUseThis() {}
/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's
* LTI update could not be added via codemod */
const Section = ({children, title}): Node => {
dontUseThis(); // Newly added line 37 as an example of a deprecated function
const isDarkMode = useColorScheme() === 'dark';
return (
// ...
Then deprecated functions will be shown when npm run lint
is used:
$ npm run lint
> [email protected] lint
> eslint .
/run/user/1000/AwesomeProject/App.js
10:14 warning 'Node' is defined but never used no-unused-vars
37:3 warning 'dontUseThis' is deprecated. deprecation/deprecation
✖ 2 problems (0 errors, 2 warnings)