From 5c712b1ab4c490324c218be969bf4088dc491d12 Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Thu, 17 May 2018 12:44:32 +0300 Subject: [PATCH] add eslint --- .eslintignore | 2 + .eslintrc.yml | 121 +++++++++++++++++++++++++++++++++++++ .gitignore | 10 +++- .stylelintrc | 163 ++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 8 +++ 5 files changed, 301 insertions(+), 3 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.yml create mode 100644 .stylelintrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000000..cbd76a023c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +**/__tests__/**/*.js +**/*.spec.js diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 0000000000..ea5f0fc84c --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,121 @@ +root: true + +globals: + React: true + describe: true + it: true + +parser: babel-eslint + +plugins: + - jsx-a11y + - react + - import + - babel + +env: + browser: true + es6: true + +parserOptions: + ecmaVersion: 8 + sourceType: module + ecmaFeatures: + experimentalObjectRestSpread: true + jsx: true + restParams: true + spread: true + arrowFunctions: true + classes: true + defaultParams: true + templateStrings: true + +extends: ['eslint-config-airbnb'] + +rules: + indent: + - error + - 2 + - SwitchCase: 1 + linebreak-style: + - error + - unix + quotes: + - error + - single + - allowTemplateLiterals: true + semi: + - error + - never + + # rewrite airbnb config + + array-callback-return: warn + no-debugger: 2 + no-console: 0 + default-case: warn + dot-location: [warn, property] + eqeqeq: 2 + comma-dangle: + - error + - always-multiline + max-len: + - error + - code: 180 + + no-multi-spaces: 0 + no-return-assign: 0 + no-underscore-dangle: 0 + no-lonely-if: 0 + no-param-reassign: 0 + no-confusing-arrow: 0 + no-extra-boolean-cast: 0 + no-plusplus: 0 + no-nested-ternary: 0 + no-mixed-operators: 0 + no-shadow: 0 + no-cond-assign: 0 + no-use-before-define: 0 + no-template-curly-in-string: 0 + no-unused-vars: 0 + + func-names: 0 + padded-blocks: 0 + object-curly-newline: 0 + quote-props: 0 + array-bracket-spacing: 0 + brace-style: 0 + arrow-parens: 0 + key-spacing: 0 + consistent-return: 0 + function-paren-newline: 0 + class-methods-use-this: 0 + object-property-newline: 0 + prefer-const: 0 + prefer-promise-reject-errors: 0 + + react/default-props-match-prop-types: 0 + react/require-default-props: 0 + react/jsx-filename-extension: 0 + react/display-name: 0 + react/prop-types: 0 + react/forbid-prop-types: 0 + react/sort-comp: 0 + react/jsx-closing-bracket-location: 0 + react/no-array-index-key: 0 + react/no-danger: 0 + react/no-unused-state: 0 + + import/extensions: 0 + import/no-unresolved: 0 + import/first: 0 + import/no-extraneous-dependencies: 0 + import/newline-after-import: 0 + import/no-dynamic-require: 0 + + jsx-a11y/no-static-element-interactions: 0 + jsx-a11y/click-events-have-key-events: 0 + jsx-a11y/media-has-caption: 0 + jsx-a11y/aria-role: 0 + jsx-a11y/label-has-for: 0 + diff --git a/.gitignore b/.gitignore index b227352ff4..48e0f54e8e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ -/.idea -/node_modules/ -/dist/ +.DS_Store +.idea + +*-lock.* + +node_modules +dist diff --git a/.stylelintrc b/.stylelintrc new file mode 100644 index 0000000000..2ba7d058d1 --- /dev/null +++ b/.stylelintrc @@ -0,0 +1,163 @@ +{ + "plugins": [ + "stylelint-scss", + "stylelint-order" + ], + "defaultSeverity": "warning", + "rules": { + "order/properties-order": [ + "width", + "height", + "min-width", + "max-width", + "min-height", + "max-height", + "display", + "flex-direction", + "flex-wrap", + "order", + "justify-content", + "align-items", + "align-self", + "align-content", + "background", + "background-image", + "background-color", + "background-position", + "background-attachment", + "background-clip", + "background-origin", + "background-repeat", + "background-size", + "border", + "border-top", + "border-right", + "border-bottom", + "border-left", + "border-image", + "border-width", + "border-style", + "border-color", + "margin", + "margin-top", + "margin-bottom", + "margin-right", + "margin-left", + "padding", + "padding-top", + "padding-bottom", + "padding-right", + "padding-left", + "position", + "top", + "bottom", + "right", + "left", + "font-family", + "font-weight", + "text-overflow", + "text-shadow", + "text-align", + "text-decoration", + "text-transform", + "font-size", + "color" + ], + "max-empty-lines": 2, + "max-line-length": 100, + "no-duplicate-selectors": true, + "no-empty-source": true, + "no-eol-whitespace": true, + "no-extra-semicolons": true, + "no-invalid-double-slash-comments": true, + "no-missing-end-of-source-newline": true, + "no-unknown-animations": true, + "color-hex-case": "lower", + "color-hex-length": "short", + "color-no-invalid-hex": true, + "font-family-name-quotes": "always-where-recommended", + "font-family-no-duplicate-names": true, + "font-weight-notation": "numeric", + "function-calc-no-unspaced-operator": true, + "function-comma-space-after": "always", + "function-comma-space-before": "never", + "function-linear-gradient-no-nonstandard-direction": true, + "function-max-empty-lines": 0, + "function-parentheses-space-inside": "never", + "function-url-no-scheme-relative": true, + "function-url-quotes": "always", + "function-whitespace-after": "always", + "number-leading-zero": "never", + "number-max-precision": 3, + "number-no-trailing-zeros": true, + "string-no-newline": true, + "string-quotes": "single", + "length-zero-no-unit": true, + "unit-blacklist": ["vw", "vh", "rem"], + "unit-case": "lower", + "unit-no-unknown": true, + "value-keyword-case": "lower", + "value-list-comma-space-before": "never", + "value-list-max-empty-lines": 0, + "custom-property-empty-line-before": "never", + "shorthand-property-no-redundant-values": true, + "property-case": "lower", + "property-no-unknown": true, + "declaration-bang-space-after": "never", + "declaration-bang-space-before": "always", + "declaration-colon-space-after": "always", + "declaration-colon-space-before": "never", + "declaration-empty-line-before": "never", + "declaration-block-no-duplicate-properties": true, + "declaration-block-no-redundant-longhand-properties": true, + "declaration-block-semicolon-newline-after": "always", + "declaration-block-semicolon-space-before": "never", + "declaration-block-single-line-max-declarations": 1, + "declaration-block-trailing-semicolon": "always", + "block-closing-brace-empty-line-before": "never", + "block-closing-brace-newline-after": "always", + "block-no-empty": true, + "block-opening-brace-space-before": "always", + "selector-attribute-brackets-space-inside": "never", + "selector-attribute-operator-space-after": "never", + "selector-attribute-operator-space-before": "never", + "selector-attribute-quotes": "always", + "selector-combinator-space-after": "always", + "selector-combinator-space-before": "always", + "selector-descendant-combinator-no-non-space": true, + "selector-pseudo-class-case": "lower", + "selector-pseudo-class-no-unknown": [true, { + "ignorePseudoClasses": ["global"] + }], + "selector-pseudo-class-parentheses-space-inside": "never", + "selector-pseudo-element-case": "lower", + "selector-pseudo-element-colon-notation": "single", + "selector-pseudo-element-no-unknown": true, + "selector-type-case": "lower", + "selector-type-no-unknown": true, + "selector-max-empty-lines": 0, + "selector-list-comma-newline-after": "always-multi-line", + "selector-list-comma-newline-before": "never-multi-line", + "selector-list-comma-space-before": "never", + "media-feature-colon-space-after": "always", + "media-feature-colon-space-before": "never", + "media-feature-name-case": "lower", + "media-feature-name-no-unknown": true, + "media-feature-name-no-vendor-prefix": true, + "media-feature-parentheses-space-inside": "never", + "media-feature-range-operator-space-after": "always", + "media-feature-range-operator-space-before": "always", + "media-query-list-comma-newline-after": "never-multi-line", + "media-query-list-comma-newline-before": "never-multi-line", + "media-query-list-comma-space-before": "never", + "at-rule-name-case": "lower", + "at-rule-name-newline-after": "always-multi-line", + "at-rule-name-space-after": "always", + "at-rule-no-vendor-prefix": true, + "at-rule-semicolon-newline-after": "always", + "at-rule-semicolon-space-before": "never", + "comment-empty-line-before": "always", + "comment-no-empty": true, + "comment-whitespace-inside": "always" + } +} diff --git a/package.json b/package.json index af834ce8af..898d5e7d37 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "./bin/server", "scripts": { "test": "echo \"Error: no test specified\" && exit 1", + "eslint": "eslint --cache ./shared --ext js", "start": "nodemon bin/server", "build": "npm i && webpack -p --config webpack.prod.js" }, @@ -15,6 +16,7 @@ "devDependencies": { "babel": "^6.23.0", "babel-core": "^6.26.3", + "babel-eslint": "^8.2.3", "babel-loader": "^7.1.4", "babel-plugin-add-module-exports": "^0.2.1", "babel-polyfill": "^6.26.0", @@ -27,6 +29,12 @@ "bootstrap": "^4.0.0", "clean-webpack-plugin": "^0.1.19", "css-loader": "^0.28.11", + "eslint": "^4.19.1", + "eslint-config-airbnb": "^16.1.0", + "eslint-plugin-babel": "^5.1.0", + "eslint-plugin-import": "^2.11.0", + "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-react": "^7.8.2", "exports-loader": "^0.7.0", "extract-text-webpack-plugin": "^4.0.0-beta.0", "file-loader": "^1.1.11",