Skip to content

Commit

Permalink
first commit coming from monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathon Meng committed Jul 13, 2020
0 parents commit 731f0a8
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@appteam6/eslint-config",
"version": "1.1.0",
"main": "src/index.js",
"sideEffects": false,
"repository": "[email protected]: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"
}
}
110 changes: 110 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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
},
},
};

0 comments on commit 731f0a8

Please sign in to comment.