diff --git a/.eslintrc-precommit.js b/.eslintrc-precommit.js new file mode 100644 index 00000000000..2f6a02b6a9a --- /dev/null +++ b/.eslintrc-precommit.js @@ -0,0 +1,18 @@ +module.exports = { + extends: ['./.eslintrc.js'], + // This eslint configuration is only used for precommits. It will not affect the CI checks in Github. + rules: { + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: 'enzyme', + message: + 'We are replacing enzyme with React Testing Library for this project. Import from @testing-library/react-native to write unit tests instead. Reference - https://testing-library.com/docs/react-testing-library/migrate-from-enzyme/', + }, + ], + }, + ], + }, +}; diff --git a/package.json b/package.json index b6966e1ce1c..c421bca3cb9 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "lint-staged": { "*.{js,jsx,ts,tsx}": [ "prettier --write", - "eslint" + "eslint --config .eslintrc-precommit.js" ], "*.json": [ "prettier --write"