Skip to content

Instantly share code, notes, and snippets.

@Karnak19
Created December 1, 2021 13:01
Show Gist options
  • Save Karnak19/971dc1245653e121544d6375f5b3ef82 to your computer and use it in GitHub Desktop.
Save Karnak19/971dc1245653e121544d6375f5b3ef82 to your computer and use it in GitHub Desktop.
React Typescript Eslint
module.exports = {
root: true, // Make sure eslint picks up the config at the root of the directory
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020, // Use the latest ecmascript standard
sourceType: "module", // Allows using import/export statements
ecmaFeatures: {
jsx: true, // Enable JSX since we're using React
},
},
settings: {
react: {
version: "detect", // Automatically detect the react version
},
},
env: {
browser: true, // Enables browser globals like window and document
amd: true, // Enables require() and define() as global variables as per the amd spec.
node: true, // Enables Node.js global variables and Node.js scoping.
},
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
"plugin:prettier/recommended", // Make this the last element so prettier config overrides other formatting rules
],
rules: {
"react/react-in-jsx-scope": "off",
"prettier/prettier": ["error", {}, { usePrettierrc: true }], // Use our .prettierrc file as source
"react/function-component-definition": [
2,
{ namedComponents: "function-declaration" },
],
"no-console": 1,
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ argsIgnorePattern: "^_", ignoreRestSiblings: true },
],
"react/jsx-filename-extension": [2, { extensions: [".tsx", ".jsx"] }],
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment