From 903eb5358e4ff8f85a4943d7cbfe9949a98f0aa2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 26 Sep 2019 17:49:50 +0200 Subject: [PATCH] Use the extracted linting configs --- .eslintrc.js | 156 +-------------------------------------------- .remarkrc.js | 5 +- package.json | 13 +--- prettier.config.js | 11 ++-- yarn.lock | 29 ++++++++- 5 files changed, 37 insertions(+), 177 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3cdb41d2dc9c..0a2e0a462f1c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,162 +1,8 @@ -const error = 2; -const warn = 1; const ignore = 0; module.exports = { root: true, - extends: [ - 'airbnb', - 'plugin:jest/recommended', - 'plugin:import/react-native', - 'plugin:@typescript-eslint/recommended', - 'prettier', - 'prettier/react', - 'prettier/@typescript-eslint', - ], - plugins: [ - '@typescript-eslint', - 'prettier', - 'jest', - 'import', - 'react', - 'jsx-a11y', - 'json', - 'html', - ], - parser: '@typescript-eslint/parser', - parserOptions: { - ecmaVersion: 8, - sourceType: 'module', - ecmaFeatures: { - jsx: true, - }, - }, - env: { es6: true, node: true, 'jest/globals': true }, - settings: { - 'import/core-modules': ['enzyme'], - 'import/ignore': ['node_modules\\/(?!@storybook)'], - 'import/resolver': { - node: { - extensions: ['.js', '.ts', '.tsx', '.mjs', '.d.ts'], - paths: ['node_modules/', 'node_modules/@types/'], - }, - }, - 'html/html-extensions': ['.html'], - }, - rules: { - 'no-restricted-imports': [ - error, - { - paths: [ - { - name: 'lodash.isequal', - message: - 'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead', - }, - { - name: 'lodash.mergewith', - message: - 'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead', - }, - { - name: 'lodash.pick', - message: - 'Lodash modularised (and lodash < 4.17.11) have CVE vulnerabilities. Please use tree-shakeable imports like lodash/xxx instead', - }, - ], - // catch-all for any lodash modularised. The CVE is listed against the entire family for lodash < 4.17.11 - patterns: ['lodash.*'], - }, - ], - 'prettier/prettier': [warn], - 'no-debugger': process.env.NODE_ENV === 'production' ? error : ignore, - 'class-methods-use-this': ignore, - 'import/extensions': [ - error, - 'always', - { - js: 'never', - ts: 'never', - tsx: 'never', - mjs: 'never', - }, - ], - 'import/no-extraneous-dependencies': [ - error, - { - devDependencies: [ - 'examples/**', - 'examples-native/**', - '**/example/**', - '*.js', - '**/*.test.js', - '**/*.stories.*', - '**/scripts/*.js', - '**/stories/**/*.js', - '**/__tests__/**/*.js', - '**/.storybook/**/*.*', - ], - peerDependencies: true, - }, - ], - 'import/prefer-default-export': ignore, - 'import/default': error, - 'import/named': error, - 'import/namespace': error, - 'react/jsx-filename-extension': [ - warn, - { - extensions: ['.js', '.jsx', '.tsx'], - }, - ], - 'react/jsx-no-bind': [ - error, - { - ignoreDOMComponents: true, - ignoreRefs: true, - allowArrowFunctions: true, - allowFunctions: true, - allowBind: true, - }, - ], - 'jsx-a11y/accessible-emoji': ignore, - 'jsx-a11y/label-has-associated-control': [ - warn, - { - labelComponents: ['CustomInputLabel'], - labelAttributes: ['label'], - controlComponents: ['CustomInput'], - depth: 3, - }, - ], - 'react/no-unescaped-entities': ignore, - 'jsx-a11y/label-has-for': [error, { required: { some: ['nesting', 'id'] } }], - 'jsx-a11y/anchor-is-valid': [ - error, - { - components: ['A', 'LinkTo', 'Link'], - specialLink: ['overrideParams', 'kind', 'story', 'to'], - }, - ], - 'no-underscore-dangle': [ - error, - { - allow: [ - '__STORYBOOK_CLIENT_API__', - '__STORYBOOK_ADDONS_CHANNEL__', - '__STORYBOOK_STORY_STORE__', - ], - }, - ], - '@typescript-eslint/no-var-requires': ignore, - '@typescript-eslint/camelcase': ignore, - '@typescript-eslint/no-unused-vars': ignore, - '@typescript-eslint/explicit-member-accessibility': ignore, - '@typescript-eslint/explicit-function-return-type': ignore, - '@typescript-eslint/no-explicit-any': ignore, // would prefer to enable this - '@typescript-eslint/no-use-before-define': ignore, // this is duplicated - '@typescript-eslint/interface-name-prefix': ignore, // I don't agree - }, + extends: ['@storybook/eslint-config-storybook'], overrides: [ { files: [ diff --git a/.remarkrc.js b/.remarkrc.js index 2c78f5c67277..f8250d11d53a 100644 --- a/.remarkrc.js +++ b/.remarkrc.js @@ -1,3 +1,2 @@ -module.exports = { - plugins: ['remark-preset-lint-recommended', ['remark-lint-list-item-indent', false]], -}; +/* eslint-disable import/no-extraneous-dependencies */ +module.exports = require('@storybook/linter-config/remark.config'); diff --git a/package.json b/package.json index 3dfd05dfa3eb..5f6714d40264 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "babel", "components", "documentation", - "eslint", "frontend", "jamstack", "markup", @@ -136,6 +135,8 @@ "@babel/preset-react": "^7.0.0", "@babel/preset-typescript": "^7.3.3", "@emotion/snapshot-serializer": "^0.8.2", + "@storybook/eslint-config-storybook": "^1.0.0", + "@storybook/linter-config": "^1.0.0", "@types/common-tags": "^1.8.0", "@types/jest": "^24.0.11", "@types/lodash": "^4.14.129", @@ -144,7 +145,6 @@ "@types/semver": "^6.0.0", "@types/webpack": "^4.39.0", "@types/webpack-env": "^1.14.0", - "@typescript-eslint/eslint-plugin": "^1.7.0", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^24.7.1", @@ -170,15 +170,6 @@ "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.9.1", "eslint": "^5.14.1", - "eslint-config-airbnb": "^17.0.0", - "eslint-config-prettier": "^4.3.0", - "eslint-plugin-html": "^5.0.3", - "eslint-plugin-import": "^2.16.0", - "eslint-plugin-jest": "^22.4.1", - "eslint-plugin-json": "^1.4.0", - "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-prettier": "^3.0.1", - "eslint-plugin-react": "^7.12.4", "esm": "^3.2.25", "github-release-from-changelog": "^1.3.2", "glob": "^7.1.3", diff --git a/prettier.config.js b/prettier.config.js index f54c4bfe882d..6c440564303a 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,13 +1,10 @@ -module.exports = { - printWidth: 100, - tabWidth: 2, - bracketSpacing: true, - trailingComma: 'es5', - singleQuote: true, +const base = require('@storybook/linter-config/prettier.config'); + +module.exports = Object.assign({}, base, { overrides: [ { files: '*.html', options: { parser: 'babel' }, }, ], -}; +}); diff --git a/yarn.lock b/yarn.lock index ccb7b2a71427..c8fd529752ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3288,6 +3288,33 @@ resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.7.0.tgz#9a06f4f137ee84d7df0460c1fdb1135ffa6c50fd" integrity sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow== +"@storybook/eslint-config-storybook@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@storybook/eslint-config-storybook/-/eslint-config-storybook-1.0.0.tgz#a7af05e793d218524c1fc675ea0c07f14344a9d8" + integrity sha512-JiMe7XSMLedktdSNL7W1aaIvJIE+iH/g8EYxqNhtWZG6EpF9oWFwO9D4oI48eXmPw3CK+O4Xiwzr3rRBsW4yWA== + dependencies: + "@storybook/linter-config" "*" + +"@storybook/linter-config@*", "@storybook/linter-config@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@storybook/linter-config/-/linter-config-1.0.0.tgz#bd3c27c5dec2f7601e363d6e6d386d925440db6d" + integrity sha512-z3KX8CEiNSCPP0lmzFH4JGMi0N+x+Jeh169TNyOZfD6Jn7C6JnQJ1m7asTMIgoCZNy5P524y1yMiMpE+v28C+Q== + dependencies: + "@typescript-eslint/eslint-plugin" "^1.7.0" + "@typescript-eslint/parser" "^2.3.1" + eslint-config-airbnb "^17.0.0" + eslint-config-prettier "^4.3.0" + eslint-plugin-html "^5.0.3" + eslint-plugin-import "^2.16.0" + eslint-plugin-jest "^22.4.1" + eslint-plugin-json "^1.4.0" + eslint-plugin-jsx-a11y "^6.2.1" + eslint-plugin-prettier "^3.0.1" + eslint-plugin-react "^7.12.4" + remark-cli "^6.0.1" + remark-lint "^6.0.4" + remark-preset-lint-recommended "^3.0.2" + "@svgr/babel-plugin-add-jsx-attribute@^4.2.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz#dadcb6218503532d6884b210e7f3c502caaa44b1" @@ -3979,7 +4006,7 @@ eslint-scope "^4.0.0" eslint-visitor-keys "^1.0.0" -"@typescript-eslint/parser@^2.2.0": +"@typescript-eslint/parser@^2.2.0", "@typescript-eslint/parser@^2.3.1": version "2.3.1" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.3.1.tgz#f2b93b614d9b338825c44e75552a433e2ebf8c33" integrity sha512-ZlWdzhCJ2iZnSp/VBAJ/sowFbyHycIux8t0UEH0JsKgQvfSf7949hLYFMwTXdCMeEnpP1zRTHimrR+YHzs8LIw==