Skip to content

Commit

Permalink
fix: cleanup/add/remove rules based on lint fixes
Browse files Browse the repository at this point in the history
- update rules to suit resolving non-fixable issues
- add more warning rules to optionally add and enforce later
- reorder package.json deps to show most important first
- print only lint errors when running lint command, warnings meant for ide
  • Loading branch information
nickofthyme committed May 30, 2020
1 parent 1624541 commit 21ef4de
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 40 deletions.
89 changes: 73 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,35 @@ module.exports = {
'@typescript-eslint/camelcase': 0,

/**
*****************************************
* Rules to consider adding/fixing later
*****************************************
*/
'import/no-cycle': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-member-access': 0,
'@typescript-eslint/no-unsafe-return': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/restrict-template-expressions': 1,
'@typescript-eslint/restrict-plus-operands': 1,
'@typescript-eslint/no-unsafe-call': 1,
'@typescript-eslint/unbound-method': 1,
'unicorn/consistent-function-scoping': 1,
'unicorn/explicit-length-check': 1,
'no-use-before-define': 0,
'no-restricted-properties': 0, // need to find and filter desired options
'class-methods-use-this': 1,
'unicorn/prefer-number-properties': 0,
'global-require': 1,
'import/no-dynamic-require': 1,
'no-shadow': 1,
'no-param-reassign': 1,
'react/no-array-index-key': 1,
'react/prefer-stateless-function': 1,
'jsx-a11y/no-static-element-interactions': 1,
'jsx-a11y/mouse-events-have-key-events': 1,
'jsx-a11y/click-events-have-key-events': 1,
eqeqeq: 1,

/**
* Standard rules
Expand All @@ -57,9 +78,16 @@ module.exports = {
'comma-dangle': ['error', 'always-multiline'],
'consistent-return': 0,
'no-plusplus': 0,
'no-bitwise': 0,
'no-void': 0,
'no-restricted-globals': 0,
'no-case-declarations': 0,
'no-return-await': 0,
'max-classes-per-file': 0,
'no-continue': 0,
'no-lonely-if': 0,
'no-return-assign': 0,
'no-underscore-dangle': 0,
'multiline-comment-style': ['error', 'starred-block'],
'no-unused-vars': [
'error',
{
Expand All @@ -68,12 +96,6 @@ module.exports = {
ignoreRestSiblings: true,
},
],
'unicorn/filename-case': [
'error',
{
case: 'snakeCase',
},
],
'sort-keys': 0,
'no-irregular-whitespace': 'error',
'no-unused-expressions': 'error',
Expand All @@ -91,6 +113,7 @@ module.exports = {
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/ban-ts-comment': 1,
'@typescript-eslint/no-unused-vars': [
'error',
{
Expand All @@ -100,8 +123,8 @@ module.exports = {
},
],
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: true, variables: true, typedefs: true },
'warn',
{ functions: false, classes: true, variables: true, typedefs: false },
],

/*
Expand All @@ -120,7 +143,6 @@ module.exports = {
],
// https://basarat.gitbooks.io/typescript/docs/tips/defaultIsBad.html
'import/prefer-default-export': 0,
'import/no-default-export': 'error',
// Limit usage in development directories
'import/no-extraneous-dependencies': 0,

Expand All @@ -133,19 +155,31 @@ module.exports = {
'react/destructuring-assignment': 0,
// No jsx extension: https://github.com/facebook/create-react-app/issues/87#issuecomment-234627904
'react/jsx-filename-extension': 0,
'react/jsx-props-no-spreading': 0,
'react/static-property-placement': 0,
'react/state-in-constructor': 0,

/*
* react-hooks plugin
* jest plugin
*/
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'jest/no-standalone-expect': 0, // using custom expect functions
'jest/no-disabled-tests': 0,

/*
* unicorn plugin
*/
'unicorn/prevent-abbreviations': 0, // Common abbreviations are known and readable
'unicorn/no-null': 0,
'unicorn/no-fn-reference-in-iterator': 0,
'unicorn/no-nested-ternary': 1,
'unicorn/no-reduce': 0,
'unicorn/no-useless-undefined': 0,
'unicorn/filename-case': [
'error',
{
case: 'snakeCase',
},
],

/*
* file-header plugin
Expand Down Expand Up @@ -210,7 +244,7 @@ module.exports = {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.ts'],
devDependencies: ['**/*.test.ts?(x)', 'src/mocks/**/*.ts?(x)'],
},
],
},
Expand All @@ -233,12 +267,35 @@ module.exports = {
},
},
{
files: ['stories/**/*.ts?(x)'],
files: ['stories/**/*.ts?(x)', 'docs/**/*.ts?(x)'],
rules: {
'import/no-default-export': 0,
'@typescript-eslint/no-unsafe-call': 0,
},
},
{
files: ['integration/**/*.ts?(x)'],
rules: {
'jest/expect-expect': [
'error',
{
assertFunctionNames: [
'expect',
'common.expectChartAtUrlToMatchScreenshot',
'common.expectElementAtUrlToMatchScreenshot',
'common.expectChartAtUrlToMatchScreenshot',
'common.expectChartWithMouseAtUrlToMatchScreenshot',
'common.expectChartWithDragAtUrlToMatchScreenshot',
],
},
],
},
},
{
files: ['*.test.ts?(x)'],
rules: {
'unicorn/error-message': 0,
},
},
{
files: ['stories/**/*.ts?(x)', '*.test.ts?(x)'],
rules: {
Expand Down
48 changes: 24 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
"publishConfig": {
"access": "public"
},
"files": [
"dist/**/*"
],
"scripts": {
"autoprefix:css": "echo 'Autoprefixing...' && yarn postcss dist/*.css --no-map --use autoprefixer -d dist",
"api:check": "yarn build:ts && yarn api:extract",
Expand All @@ -26,7 +29,7 @@
"build:watch": "echo 'Watching build...' && yarn build:clean && yarn build:css && yarn build:compile -w ",
"concat:sass": "echo 'Concat SASS...' && node scripts/concat_sass.js",
"cz": "git-cz",
"lint": "NODE_ENV=production eslint --ext .tsx,.ts,.js .",
"lint": "NODE_ENV=production eslint --quiet --ext .tsx,.ts,.js .",
"lint:fix": "yarn lint --fix",
"prettier:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,html,css,scss}\"",
"playground": "cd .playground && webpack-dev-server",
Expand All @@ -50,9 +53,26 @@
"ts:prune": "ts-prune",
"watch": "yarn test --watch"
},
"files": [
"dist/**/*"
],
"dependencies": {
"@popperjs/core": "^2.4.0",
"classnames": "^2.2.6",
"d3-array": "^1.2.4",
"d3-collection": "^1.0.7",
"d3-color": "^1.4.0",
"d3-scale": "^1.0.7",
"d3-shape": "^1.3.4",
"newtype-ts": "^0.2.4",
"path2d-polyfill": "^0.4.2",
"prop-types": "^15.7.2",
"re-reselect": "^3.4.0",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"reselect": "^4.0.0",
"resize-observer-polyfill": "^1.5.1",
"ts-debounce": "^1.0.0",
"utility-types": "^3.10.0",
"uuid": "^3.3.2"
},
"devDependencies": {
"@babel/core": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
Expand Down Expand Up @@ -174,26 +194,6 @@
"webpack-cli": "^3.3.1",
"webpack-dev-server": "^3.3.1"
},
"dependencies": {
"@popperjs/core": "^2.4.0",
"classnames": "^2.2.6",
"d3-array": "^1.2.4",
"d3-collection": "^1.0.7",
"d3-color": "^1.4.0",
"d3-scale": "^1.0.7",
"d3-shape": "^1.3.4",
"newtype-ts": "^0.2.4",
"path2d-polyfill": "^0.4.2",
"prop-types": "^15.7.2",
"re-reselect": "^3.4.0",
"react-redux": "^7.1.0",
"redux": "^4.0.4",
"reselect": "^4.0.0",
"resize-observer-polyfill": "^1.5.1",
"ts-debounce": "^1.0.0",
"utility-types": "^3.10.0",
"uuid": "^3.3.2"
},
"peerDependencies": {
"moment-timezone": "^0.5.27",
"react": "^16.12.0",
Expand Down

0 comments on commit 21ef4de

Please sign in to comment.