Skip to content

Commit

Permalink
chore: use eslint instead tslint
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Mar 7, 2020
1 parent baef307 commit accb1c9
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 119 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
!.eslintrc.js

build
node_modules

*.d.ts
219 changes: 219 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react-hooks', 'react'],
env: {
browser: true,
es6: true,
node: true,
},
globals: {
__DEV__: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: { jsx: true },
useJSXTextNode: true,
},
settings: {
react: {
pragma: 'React',
version: '16.0',
},
},
rules: {
// see https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/style.js#L122
indent: [
2,
2,
{
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
FunctionDeclaration: {
parameters: 1,
body: 1,
},
FunctionExpression: {
parameters: 1,
body: 1,
},
CallExpression: {
arguments: 1,
},
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
flatTernaryExpressions: false,
ignoreComments: false,
},
],

semi: [2, 'never'],
'semi-spacing': [2, { before: false, after: true }],
'wrap-iife': [2, 'inside'],
'no-use-before-define': [2, { functions: true, classes: true, variables: true }],
'no-caller': 2,
'no-cond-assign': [2, 'except-parens'],
'no-constant-condition': 2,
'no-debugger': 2,
'no-dupe-args': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty': [2, { allowEmptyCatch: true }],
'no-extra-boolean-cast': 2,
'no-extra-semi': 2,
'no-func-assign': 2,
'no-new': 2,
'no-sparse-arrays': 2,
'no-undef': 2,
'no-unexpected-multiline': 2,
'no-unreachable': 2,
'no-unused-vars': [
2,
{
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
vars: 'all',
varsIgnorePattern: '^_',
},
],

strict: 2,
'max-params': [2, 5],
'max-depth': [1, 4],
'no-eq-null': 0,
'no-unused-expressions': 0,
'dot-notation': 2,
'use-isnan': 2,

// Best practices
'block-scoped-var': 2,
complexity: [0, 11],
curly: [2, 'multi-line'],
eqeqeq: [2, 'always', { null: 'ignore' }],
'no-else-return': 2,
'no-extra-bind': 2,
'no-implicit-coercion': 2,
'no-return-assign': 0,
'no-sequences': 2,
yoda: 2,

// Variables
'no-restricted-globals': [2, 'fdescribe', 'fit'],
'no-var': 1,

// Codestyle
'arrow-parens': [2, 'always'],
'array-bracket-spacing': [2, 'never'],
'brace-style': [2, '1tbs', { allowSingleLine: true }],
camelcase: [2, { properties: 'never' }],
'comma-dangle': ['warn', 'always-multiline'],
'comma-spacing': [2, { before: false, after: true }],
'eol-last': 2,
'func-call-spacing': [2, 'never'],
'block-spacing': 2,
'keyword-spacing': [2, { before: true, after: true }],
'max-len': [
2,
{
code: 100,
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignorePattern: 'require',
},
],
'no-lonely-if': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multiple-empty-lines': [2, { max: 1, maxBOF: 0, maxEOF: 0 }],
'no-trailing-spaces': 2,
'no-unneeded-ternary': 2,
'no-nested-ternary': 2,
'object-curly-spacing': [2, 'always'],
'one-var-declaration-per-line': [2, 'initializations'],
'one-var': [2, { let: 'never', const: 'never' }],
'operator-linebreak': [2, 'before'],
'padded-blocks': [2, 'never'],
'quote-props': [2, 'as-needed', { numbers: true }],
quotes: [2, 'single', { avoidEscape: true }],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [
2,
{
asyncArrow: 'always',
anonymous: 'never',
named: 'never',
},
],
'space-in-parens': 2,
'no-console': [2, { allow: ['assert', 'error', 'warn'] }],
'key-spacing': [2, { beforeColon: false, afterColon: true, mode: 'strict' }],
'space-infix-ops': 2,

// REACT
// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
'jsx-quotes': [2, 'prefer-double'],
'react/jsx-boolean-value': 2,
'react/display-name': 0,
'react/jsx-closing-tag-location': 2,
'react/jsx-equals-spacing': 2,
'react/jsx-first-prop-new-line': [2, 'multiline'],
'react/jsx-handler-names': 0,
'react/jsx-indent': [2, 2],
'react/jsx-indent-props': [2, 2],
'react/jsx-key': 2,
'react/jsx-no-bind': 1,
'react/jsx-no-duplicate-props': 2,
'react/jsx-no-literals': 0,
'react/jsx-no-undef': 2,
'react/jsx-sort-props': 0,
'react/jsx-tag-spacing': [2, { beforeClosing: 'never', beforeSelfClosing: 'always' }],
'react/jsx-uses-react': 2,
'react/jsx-uses-vars': 2,
'react/no-find-dom-node': 2,
'react/no-multi-comp': 0,
'react/no-set-state': 0,
'react/react-in-jsx-scope': 2,
'react/require-optimization': 0,
'react/self-closing-comp': 2,
'react/style-prop-object': 2,
'react/void-dom-elements-no-children': 2,

// https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#supported-rules
'@typescript-eslint/consistent-type-assertions': 2,
'@typescript-eslint/no-empty-interface': 2,
'@typescript-eslint/no-unused-vars': [
2,
{
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
vars: 'all',
varsIgnorePattern: '^_',
},
],

// https://reactjs.org/docs/hooks-rules.html
'react-hooks/rules-of-hooks': 2, // Checks rules of Hooks
'react-hooks/exhaustive-deps': 1, // Checks effect dependencies
},
overrides: [
{
files: ['*.test.{ts,tsx}'],
env: {
jest: true,
},
},
{
files: ['*.js'],
rules: {
strict: 0,
},
},
],
}
1 change: 1 addition & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"*.{js,ts,tsx}": [
"prettier --write",
"eslint --fix",
"git add"
],
"*.md": [
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"bootstrap": "lerna bootstrap --no-ci",
"build": "lerna run build --concurrency=1",
"lint": "lerna run lint",
"lint": "eslint --ext .js,.ts,.tsx .",
"postinstall": "npm run bootstrap",
"publish:next": "lerna publish --canary --preid dev --npm-tag next --no-git-tag-version",
"unit:coverage": "npm run unit -- --coverage",
Expand All @@ -15,9 +15,14 @@
"@types/enzyme": "3.1.15",
"@types/jest": "25.1.3",
"@types/react": "16.8.8",
"@typescript-eslint/eslint-plugin": "2.22.0",
"@typescript-eslint/parser": "2.22.0",
"chalk": "2.4.1",
"enzyme": "3.7.0",
"enzyme-adapter-react-16": "1.7.0",
"eslint": "6.8.0",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "2.5.0",
"gzip-size": "5.1.0",
"husky": "3.0.5",
"jest": "25.1.0",
Expand All @@ -34,8 +39,6 @@
"rollup-plugin-terser": "4.0.4",
"rollup-plugin-typescript2": "0.21.0",
"ts-jest": "25.2.1",
"tslint": "5.11.0",
"tslint-react": "3.6.0",
"typescript": "3.2.1"
}
}
116 changes: 0 additions & 116 deletions tslint.json

This file was deleted.

0 comments on commit accb1c9

Please sign in to comment.