Skip to content

Standard ESLint used in all Zero41 React Native projects

Notifications You must be signed in to change notification settings

Zero41/eslint-config-zero41-react-native

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Standard ESLint for React Native Zero41 Projects

Installation

  1. Install eslint:
yarn add eslint@^8 --dev
npm i eslint@^8 --save-dev
  1. 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
  1. 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,
  },
};
  1. 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,
  },
};
  1. 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,
  },
};
  1. 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,
  },
};
  1. Your TSConfig might exclude your .eslintrc.js which can cause parsing errors, in that case add .eslintrc.js to a .eslintignore

Other ESLint Configs

About

Standard ESLint used in all Zero41 React Native projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published