Skip to content

Instantly share code, notes, and snippets.

@spmsupun
Last active December 24, 2021 19:10
Show Gist options
  • Save spmsupun/8041716c7bd8377eb7df45b4474bdc52 to your computer and use it in GitHub Desktop.
Save spmsupun/8041716c7bd8377eb7df45b4474bdc52 to your computer and use it in GitHub Desktop.
ESLint file for react with TypeScript and Airbnb guide
{
"extends": [
"airbnb",
"airbnb-typescript"
],
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["jest"],
"rules":
{
"no-console": "off",
"class-methods-use-this": "off",
"no-underscore-dangle": "off",
"camelcase": "off",
"no-param-reassign": "off",
// react
"react/jsx-props-no-spreading": "off",
"react/no-array-index-key": "off",
"react/function-component-definition": [
2,
{
"namedComponents": "function-declaration"
}
],
//jest
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error"
},
"env": {
"browser": true,
"node": true,
"jest/globals": true
},
"settings": {
"import/resolver": {
"node": {
"paths": [
"src"
]
}
}
}
}

ESLint file for react with TypeScript and Airbnb guide

ESLint configuration file for woring with react on typescript with airbnb guide. Conflicts are being fixed

Getting Started

Make sure you have been installed react and ESLint you your computer.

Turn off eslint in compilation: ESLINT_NO_DEV_ERRORS=true react-scripts start

For disable eslint: DISABLE_ESLINT_PLUGIN=true

Installing

Copy the .eslintrc.json file in your root folder

Install devDependencies:

yarn add --dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-airbnb eslint-config-airbnb-typescript eslint-plugin-jest eslint-plugin-jsx-a11y

With npm:

npm install --dev @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-airbnb eslint-config-airbnb-typescript eslint-plugin-jest eslint-plugin-jsx-a11y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment