Skip to content

Instantly share code, notes, and snippets.

@iegik
Last active September 28, 2022 08:15
Show Gist options
  • Save iegik/316bb57ad44a122c7af9bcec888eb864 to your computer and use it in GitHub Desktop.
Save iegik/316bb57ad44a122c7af9bcec888eb864 to your computer and use it in GitHub Desktop.
ESLint
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["react", "react-native", "import"],
"extends": [
"eslint:recommended",
"plugin:import/recommended",
"plugin:react-native/all",
"plugin:prettier/recommended"
],
"env": {
"browser": true,
"node": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 7,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"impliedStrict": true,
"modules": true
}
},
"settings": {
"import/resolver": { "typescript": true, "node": true }
},
"rules": {
"no-undef": 2,
"no-console": [2, { "allow": ["info", "error"] }],
"no-unused-vars": 0,
"arrow-parens": [2, "always"],
"arrow-body-style": [2, "as-needed"],
"class-methods-use-this": 0,
"comma-dangle": [2, "always-multiline"],
"no-plusplus": 0,
"object-curly-newline": [
"error",
{
"consistent": true
}
],
"import/ignore": 0,
"import/imports-first": 0,
"import/newline-after-import": 0,
"import/no-dynamic-require": 0,
"import/no-extraneous-dependencies": 0,
"import/no-named-as-default": 0,
"import/no-unresolved": [2, { "commonjs": true, "amd": true }],
"import/named": 2,
"import/namespace": 0,
"import/default": 2,
"import/export": 2,
"import/no-webpack-loader-syntax": 0,
"import/prefer-default-export": 0,
"import/no-duplicates": 0,
"max-len": 0,
"newline-per-chained-call": 0,
"no-confusing-arrow": 0,
"no-continue": 0,
"no-use-before-define": 0,
"prefer-template": 2,
"require-yield": 0,
"react/forbid-prop-types": 0,
"react/jsx-first-prop-new-line": [2, "multiline"],
"react/jsx-filename-extension": 0,
"react/jsx-no-target-blank": 0,
"react/require-default-props": 0,
"react/require-extension": 0,
"react/self-closing-comp": 0,
"react/jsx-one-expression-per-line": 0,
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 2,
"react-native/no-inline-styles": 2,
"react-native/no-color-literals": 2,
"react-native/no-raw-text": 2,
"react-native/no-single-element-style-arrays": 2,
"react-native/sort-styles": 2,
}
}

Code Style

Project configured to use following rule chain:

.editorconfig -> .prettierrc -> .eslint
  • .editorconfig will tell your editor how to handle spaces and newlines
  • .prettierrc will add some newlines, spaces and brackets to make code easier to read
  • .eslintrc will strict code to the rules, to exclude oblivious errors

Recommended VSCode settings plugin:

  "editor.tabSize": 2,
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
  },
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },

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