- Install
eslint
:
yarn add eslint@^8 --dev
npm i eslint@^8 --save-dev
- Install
eslint-config-zero41-react-native
:
yarn add eslint-config-zero41-react-native@https://github.com/Zero41/eslint-config-zero41-react-native.git --dev
npm install eslint-config-zero41-react-native@github:Zero41/eslint-config-zero41-react-native --save-dev
- Add
eslint-config-zero41-react-native
to your ESLint.eslintrc.js
config:
module.exports = {
root: true,
extends: ["eslint-config-zero41-react-native"],
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
};
- If you are using absolute imports, use paths to define the root:
module.exports = {
root: true,
extends: ["eslint-config-zero41-react-native"],
+ settings: {
+ "import/resolver": {
+ node: {
+ paths: ["./"],
+ },
+ },
+ },
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
};
- If you have files types other than
*.js
,*.jsx
,*.ts
or*.tsx
add them:
module.exports = {
root: true,
extends: ["eslint-config-zero41-react-native"],
settings: {
"import/resolver": {
node: {
paths: ["./"],
+ extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs"],
},
},
},
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
};
- Handle "Parse errors in imported module 'react-native': ';' expected."
React Native has an outstanding issue which can cause this error. If this occurs add this to your.eslintrc.js
module.exports = {
root: true,
extends: ["eslint-config-zero41-react-native"],
+ settings: {
+ 'import/ignore': ['react-native'],
+ }
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
};
- Your
TSConfig
might exclude your.eslintrc.js
which can cause parsing errors, in that case add.eslintrc.js
to a.eslintignore
- Standard ESLint for Zero41 Projects: eslint-config-zero41
- Standard ESLint for React Zero41 Projects: eslint-config-zero41-react