From 731f0a8da14075ae8d77335bb3a3a6f193e575f9 Mon Sep 17 00:00:00 2001 From: Jonathon Meng Date: Mon, 13 Jul 2020 17:33:51 -0600 Subject: [PATCH] first commit coming from monorepo --- README.md | 12 ++++++ package.json | 22 +++++++++++ src/index.js | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 README.md create mode 100644 package.json create mode 100644 src/index.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..5aa0fee --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# eslint-config + +A config for eslint for the Domo Apps Generator (https://git.empdev.domo.com/CustomApps/generator-da) + +Loosely based on Airbnb's JS and React style guides (https://github.com/airbnb/javascript) with some Typescript-specific rules added. + +In the index.js file, the rules are specified in the rules property. The rules have been migrated from the old tslint-config repo (https://git.empdev.domo.com/CustomApps/tslint-config) + +Depending on what kind of rule you are adding, make sure it is added in the proper order according to the website. The Airbnb style guide is organized into sections, and the React rules are organized into numbers. Add a comment indicating what section or number the rule is coming from. + +### Working with Prettier +All of the rules in eslint-config are almost all focused with the actual semantics of your program and not whitespace, formatting, etc. Prettier is what we use to manage whitespace and formatting. Rules tied to whitespace and formatting should be configured in prettier, not in eslint-config. diff --git a/package.json b/package.json new file mode 100644 index 0000000..9bc5e4f --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "@appteam6/eslint-config", + "version": "1.1.0", + "main": "src/index.js", + "sideEffects": false, + "repository": "git@git.empdev.domo.com:CustomApps/monorepo.git", + "scripts": { + "build": "echo 'no build for eslint-config'", + "prepare": "yarn run build", + "test": "echo 'no tests for eslint-config'", + "test:watch": "yarn run test" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^2.6.1", + "@typescript-eslint/parser": "^2.6.1", + "eslint": "^6.1.0", + "eslint-config-prettier": "^6.5.0", + "eslint-plugin-prettier": "^3.1.1", + "eslint-plugin-react": "^7.16.0", + "prettier": "^1.19.1" + } +} diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..04444a3 --- /dev/null +++ b/src/index.js @@ -0,0 +1,110 @@ +'use strict'; + +module.exports = { + plugins: ['prettier', '@typescript-eslint', 'react'], + parser: '@typescript-eslint/parser', // Specifies the ESLint typescript parser + extends: [ + ], + parserOptions: { + ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features + sourceType: 'module', // Allows for the use of imports + ecmaFeatures: { + jsx: true, // Allows for the parsing of TSX + }, + project: './tsconfig.json', + }, + rules: { + // prettier + 'prettier/prettier': 'error', + // non-formatting related AirBnB rules + 'prefer-const': 'error', + 'no-var': 'error', + 'object-shorthand': 'error', + 'prefer-template': 'error', + 'no-eval': 'error', + 'no-new-func': 'error', + 'no-param-reassign': 'error', + 'prefer-arrow-callback': 'error', + 'no-duplicate-imports': 'error', + 'one-var': ['error', 'never'], + 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], + 'eqeqeq': 'error', + '@typescript-eslint/strict-boolean-expressions': 'error', + 'brace-style': ['error', '1tbs', { "allowSingleLine": true }], + 'no-else-return': 'error', + 'spaced-comment': 'error', + 'no-new-wrappers': 'error', + 'radix': 'error', + 'no-shadow-restricted-names': 'error', + '@typescript-eslint/no-this-alias': 'error', + + // react rules + 'react/jsx-boolean-value': 'error', + 'react/jsx-key': 'error', + 'react/no-string-refs': 'error', + 'react/self-closing-comp': 'error', + 'react/jsx-wrap-multilines': 'error', + + // team rules + 'prefer-object-spread': 'error', + 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], + 'quote-props': ['error', 'as-needed'], + 'no-fallthrough': 'error', + '@typescript-eslint/member-ordering': 'error', + 'max-classes-per-file': ['error', 1], + '@typescript-eslint/adjacent-overload-signatures': 'error', + '@typescript-eslint/ban-types': [ + 'error', + { + types: { + Object: 'Use {} instead', + Array: 'Use [] instead', + String: 'Use string instead', + Number: 'Use number instead', + } + } + ], + '@typescript-eslint/no-empty-interface': 'error', + '@typescript-eslint/no-namespace': [ + 'error', + { allowDeclarations: true }, + ], + '@typescript-eslint/no-non-null-assertion': 'error', + '@typescript-eslint/no-require-imports': 'error', + '@typescript-eslint/prefer-for-of': 'error', + '@typescript-eslint/unified-signatures': 'error', + 'guard-for-in': 'error', + '@typescript-eslint/ban-types': 'error', + '@typescript-eslint/camelcase': 'error', + '@typescript-eslint/class-name-casing': 'error', + '@typescript-eslint/no-for-in-array': 'error', + 'no-restricted-imports': ['error', 'rxjs', 'lodash'], + 'no-caller': 'error', + 'no-bitwise': 'error', + 'no-cond-assign': 'error', + 'no-console': 'warn', + 'no-debugger': 'warn', + 'constructor-super': 'error', + 'no-shadow-restricted-names': 'error', + 'no-empty': 'error', + 'no-shadow': 'error', + 'no-sparse-arrays': 'error', + 'no-unsafe-finally': 'error', + 'no-unused-expressions': 'error', + '@typescript-eslint/restrict-plus-operands': 'error', + 'use-isnan': 'error', + 'arrow-body-style': 'error', + '@typescript-eslint/interface-name-prefix': ['error', 'never'], + 'new-parens': 'error', + // TODO: when released, enable this rule + // '@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'as' }], + '@typescript-eslint/no-parameter-properties': 'error', + '@typescript-eslint/no-unnecessary-qualifier': 'error', + 'no-floating-decimal': 'error', + }, + settings: { + react: { + version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use + }, + }, +};