diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..db4c6d9b --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..109523bd --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,543 @@ +/* eslint-disable import/unambiguous */ +/* eslint-disable filenames/match-regex */ +module.exports = { + env: { + browser: true, + es6: true, + node: true + }, + extends: ['prettier'], + parser: '@babel/eslint-parser', + parserOptions: { + ecmaFeatures: { + experimentalObjectRestSpread: true, + globalReturn: false, + impliedStrict: true, + jsx: true + }, + ecmaVersion: 2017, + requireConfigFile: false, + sourceType: 'module' + }, + plugins: [ + 'no-use-extend-native', + 'babel', + 'import', + 'jsdoc', + 'promise', + 'filenames', + 'unicorn' + ], + rules: { + 'accessor-pairs': 2, + 'array-bracket-newline': 0, + 'array-bracket-spacing': [2, 'never'], + 'array-callback-return': 2, + 'array-element-newline': 0, + 'arrow-body-style': [2, 'as-needed'], + 'arrow-parens': [2, 'always'], + 'arrow-spacing': [ + 2, + { + after: true, + before: true + } + ], + 'babel/new-cap': 0, + 'babel/no-invalid-this': 2, + 'babel/object-curly-spacing': [2, 'never'], + 'block-scoped-var': 2, + 'block-spacing': [2, 'always'], + 'brace-style': [ + 2, + '1tbs', + { + allowSingleLine: false + } + ], + 'callback-return': 2, + camelcase: 0, + 'capitalized-comments': 0, + 'class-methods-use-this': 2, + 'comma-dangle': [2, 'never'], + 'comma-spacing': [ + 2, + { + after: true, + before: false + } + ], + 'comma-style': [2, 'last'], + complexity: [1, 10], + 'computed-property-spacing': [2, 'never'], + 'consistent-return': 2, + 'consistent-this': [2, 'self'], + 'constructor-super': 2, + curly: 2, + 'default-case': 0, + 'dot-location': [2, 'property'], + 'dot-notation': 2, + 'eol-last': 2, + eqeqeq: 2, + 'filenames/match-exported': 2, + 'filenames/match-regex': [ + 2, + '^[A-Z]?[a-z]+(?:[A-Z][a-z]+)*(\\.[a-z]+)*$', + false + ], + 'filenames/no-index': 0, + 'for-direction': 2, + 'func-call-spacing': [2, 'never'], + 'func-name-matching': 2, + 'func-names': 0, + 'func-style': [2, 'expression'], + 'generator-star-spacing': [ + 2, + { + after: false, + before: true + } + ], + 'global-require': 2, + 'guard-for-in': 2, + 'handle-callback-err': 2, + 'id-length': [ + 1, + { + exceptions: ['P', 'R', '$', '_'], + max: 50, + min: 2 + } + ], + 'id-match': [ + 2, + '(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)', + { + onlyDeclarations: true, + properties: true + } + ], + 'import/default': 2, + 'import/export': 2, + 'import/extensions': [ + 2, + 'never', + { + json: 'always' + } + ], + 'import/first': [2, 'absolute-first'], + 'import/max-dependencies': 0, + 'import/named': 2, + 'import/namespace': 2, + 'import/newline-after-import': 2, + 'import/no-absolute-path': 2, + 'import/no-amd': 2, + 'import/no-anonymous-default-export': [ + 2, + { + allowAnonymousClass: false, + allowAnonymousFunction: false, + allowArray: false, + allowArrowFunction: false, + allowLiteral: false, + allowObject: false + } + ], + + // @question(lint) this was overriden at the end + // 'import/no-commonjs': 2, + 'import/no-commonjs': 'off', + + 'import/no-deprecated': 1, + 'import/no-duplicates': 0, + 'import/no-dynamic-require': 2, + 'import/no-extraneous-dependencies': [ + 2, + { + devDependencies: true, + optionalDependencies: true, + peerDependencies: true + } + ], + 'import/no-internal-modules': 0, + 'import/no-mutable-exports': 2, + 'import/no-named-as-default': 2, + 'import/no-named-as-default-member': 2, + 'import/no-named-default': 2, + 'import/no-namespace': 0, + 'import/no-nodejs-modules': 0, + 'import/no-restricted-paths': 0, + 'import/no-unassigned-import': 2, + 'import/no-unresolved': 2, + 'import/no-webpack-loader-syntax': 2, + 'import/order': [ + 2, + { + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], + 'newlines-between': 'never' + } + ], + 'import/prefer-default-export': 0, + + // @question(lint) this was overriden at the end + // 'import/unambiguous': 1, + 'import/unambiguous': 'off', + + indent: [2, 2], + 'init-declarations': 0, + 'jsdoc/check-param-names': 1, + 'jsdoc/check-tag-names': 1, + 'jsdoc/check-types': 1, + 'jsdoc/newline-after-description': [1, 'always'], + 'jsdoc/require-description-complete-sentence': 1, + 'jsdoc/require-hyphen-before-description': 0, + 'jsdoc/require-param': 0, + 'jsdoc/require-param-description': 0, + 'jsdoc/require-param-type': 0, + 'jsdoc/require-returns-description': 0, + 'jsdoc/require-returns-type': 0, + 'jsx-quotes': [2, 'prefer-single'], + 'key-spacing': [ + 2, + { + afterColon: true, + beforeColon: false + } + ], + 'keyword-spacing': [ + 2, + { + after: true, + before: true + } + ], + 'line-comment-position': [ + 2, + { + position: 'above' + } + ], + 'linebreak-style': [2, 'unix'], + 'lines-around-comment': [ + 2, + { + allowArrayEnd: true, + allowArrayStart: true, + allowBlockEnd: true, + allowBlockStart: true, + allowObjectEnd: true, + allowObjectStart: true, + beforeBlockComment: true, + beforeLineComment: true + } + ], + 'lines-around-directive': [2, 'always'], + 'max-len': [ + 1, + { + code: 160 + } + ], + 'max-nested-callbacks': [1, 3], + 'max-statements-per-line': [ + 2, + { + max: 1 + } + ], + 'multiline-ternary': 0, + 'new-cap': [ + 0, + { + capIsNew: false, + newIsCap: true + } + ], + 'new-parens': 2, + 'newline-before-return': 2, + 'newline-per-chained-call': 0, + 'no-alert': 2, + 'no-array-constructor': 2, + 'no-await-in-loop': 0, + 'no-buffer-constructor': 2, + 'no-caller': 2, + 'no-case-declarations': 2, + 'no-catch-shadow': 2, + 'no-class-assign': 2, + 'no-compare-neg-zero': 2, + 'no-cond-assign': 2, + 'no-confusing-arrow': 2, + 'no-console': 2, + 'no-const-assign': 2, + 'no-constant-condition': 1, + 'no-continue': 2, + 'no-control-regex': 2, + 'no-debugger': 1, + 'no-delete-var': 2, + 'no-div-regex': 2, + 'no-dupe-args': 2, + 'no-dupe-class-members': 2, + 'no-dupe-keys': 2, + 'no-duplicate-case': 2, + 'no-duplicate-imports': 2, + 'no-else-return': 0, + 'no-empty': 2, + 'no-empty-character-class': 2, + 'no-empty-pattern': 2, + 'no-eq-null': 2, + 'no-eval': 2, + 'no-ex-assign': 2, + 'no-extend-native': 2, + 'no-extra-bind': 2, + 'no-extra-boolean-cast': 0, + 'no-extra-parens': 2, + 'no-extra-semi': 2, + 'no-fallthrough': 2, + 'no-floating-decimal': 2, + 'no-func-assign': 2, + 'no-global-assign': 2, + 'no-implicit-coercion': 2, + 'no-implicit-globals': 0, + 'no-implied-eval': 2, + 'no-inline-comments': 2, + 'no-inner-declarations': 2, + 'no-invalid-regexp': 2, + 'no-invalid-this': 0, + 'no-irregular-whitespace': 2, + 'no-iterator': 2, + 'no-label-var': 2, + 'no-labels': 2, + 'no-lone-blocks': 2, + 'no-lonely-if': 2, + 'no-loop-func': 2, + 'no-magic-numbers': 0, + 'no-mixed-requires': 0, + 'no-mixed-spaces-and-tabs': 2, + 'no-multi-spaces': 2, + 'no-multi-str': 2, + 'no-multiple-empty-lines': [ + 2, + { + max: 1, + maxBOF: 0, + maxEOF: 1 + } + ], + 'no-native-reassign': 2, + 'no-negated-condition': 2, + 'no-negated-in-lhs': 2, + 'no-nested-ternary': 2, + 'no-new': 2, + 'no-new-func': 2, + 'no-new-object': 2, + 'no-new-require': 2, + 'no-new-symbol': 2, + 'no-new-wrappers': 2, + 'no-obj-calls': 2, + 'no-octal': 2, + 'no-octal-escape': 2, + 'no-param-reassign': [ + 2, + { + props: false + } + ], + 'no-path-concat': 2, + 'no-process-env': 2, + 'no-process-exit': 2, + 'no-proto': 2, + 'no-redeclare': [ + 2, + { + builtinGlobals: true + } + ], + 'no-regex-spaces': 2, + 'no-restricted-globals': 0, + 'no-restricted-modules': 0, + 'no-restricted-properties': 0, + 'no-restricted-syntax': 0, + 'no-return-assign': 2, + 'no-return-await': 2, + 'no-script-url': 2, + 'no-self-assign': 2, + 'no-self-compare': 2, + 'no-sequences': 2, + 'no-shadow': [ + 2, + { + builtinGlobals: false, + hoist: 'all' + } + ], + 'no-shadow-restricted-names': 2, + 'no-spaced-func': 2, + 'no-sparse-arrays': 2, + 'no-sync': 0, + 'no-tabs': 2, + 'no-template-curly-in-string': 2, + 'no-ternary': 0, + 'no-this-before-super': 2, + 'no-throw-literal': 2, + 'no-trailing-spaces': 2, + 'no-undef': 2, + 'no-undef-init': 2, + 'no-undefined': 0, + 'no-underscore-dangle': 0, + 'no-unexpected-multiline': 2, + 'no-unmodified-loop-condition': 2, + 'no-unneeded-ternary': 2, + 'no-unreachable': 1, + 'no-unsafe-finally': 2, + 'no-unsafe-negation': 2, + 'no-unused-expressions': 2, + 'no-unused-vars': 2, + 'no-use-before-define': 2, + 'no-use-extend-native/no-use-extend-native': 2, + 'no-useless-call': 2, + 'no-useless-computed-key': 2, + 'no-useless-concat': 2, + 'no-useless-constructor': 2, + 'no-useless-escape': 2, + 'no-useless-rename': [ + 2, + { + ignoreDestructuring: false, + ignoreExport: false, + ignoreImport: false + } + ], + 'no-useless-return': 2, + 'no-var': 2, + 'no-void': 2, + 'no-warning-comments': [ + 1, + { + location: 'start', + terms: ['todo', '@toto'] + } + ], + 'no-whitespace-before-property': 2, + 'no-with': 2, + 'nonblock-statement-body-position': [2, 'below'], + 'object-curly-spacing': [0, 'never'], + 'object-property-newline': [ + 2, + { + allowMultiplePropertiesPerLine: false + } + ], + 'object-shorthand': [2, 'always'], + 'one-var': [2, 'never'], + 'one-var-declaration-per-line': 2, + 'operator-assignment': [2, 'always'], + 'operator-linebreak': [2, 'after'], + 'padded-blocks': [2, 'never'], + 'padding-line-between-statements': 0, + 'prefer-arrow-callback': 2, + 'prefer-const': 2, + 'prefer-destructuring': 0, + 'prefer-numeric-literals': 2, + 'prefer-promise-reject-errors': 2, + 'prefer-reflect': 0, + 'prefer-rest-params': 2, + 'prefer-spread': 2, + 'prefer-template': 0, + 'promise/always-return': 2, + 'promise/avoid-new': 0, + 'promise/catch-or-return': 2, + 'promise/no-callback-in-promise': 0, + 'promise/no-native': 0, + 'promise/no-nesting': 0, + 'promise/no-promise-in-callback': 0, + 'promise/no-return-wrap': 2, + 'promise/param-names': 2, + 'promise/prefer-await-to-callbacks': 1, + + // @question(lint) this was overriden at the end + // 'promise/prefer-await-to-then': 1, + 'promise/prefer-await-to-then': 'off', + + 'quote-props': [2, 'as-needed'], + quotes: [2, 'single'], + radix: 2, + 'require-await': 1, + 'require-jsdoc': 0, + 'require-yield': 2, + semi: [2, 'always'], + 'semi-spacing': [ + 2, + { + after: true, + before: false + } + ], + 'semi-style': [2, 'last'], + 'sort-keys': [ + 2, + 'asc', + { + caseSensitive: false, + natural: true + } + ], + 'sort-vars': 2, + 'space-before-blocks': [2, 'always'], + 'space-before-function-paren': [2, 'always'], + 'space-in-parens': [2, 'never'], + 'space-infix-ops': 2, + 'space-unary-ops': [ + 2, + { + nonwords: false, + words: true + } + ], + 'spaced-comment': [2, 'always'], + + // @question(lint) this was overriden at the end + // strict: [2, 'never'], + strict: 'off', + + 'switch-colon-spacing': [ + 2, + { + after: true, + before: false + } + ], + 'symbol-description': 2, + 'template-tag-spacing': [2, 'never'], + 'unicode-bom': [2, 'never'], + 'unicorn/catch-error-name': [ + 'error', + { + name: 'error' + } + ], + 'unicorn/custom-error-definition': 0, + 'unicorn/escape-case': 2, + 'unicorn/explicit-length-check': 0, + 'unicorn/filename-case': 0, + 'unicorn/no-abusive-eslint-disable': 2, + 'unicorn/no-array-instanceof': 2, + 'unicorn/no-hex-escape': 2, + 'unicorn/no-new-buffer': 2, + 'unicorn/no-process-exit': 0, + 'unicorn/number-literal-case': 2, + 'unicorn/prefer-starts-ends-with': 2, + 'unicorn/prefer-type-error': 2, + 'unicorn/throw-new-error': 2, + 'use-isnan': 2, + 'valid-jsdoc': 0, + 'valid-typeof': 2, + 'vars-on-top': 2, + 'wrap-iife': [2, 'inside'], + 'wrap-regex': 0, + yoda: 0 + }, + settings: { + 'import/extensions': ['.js'] + } +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 3e91346b..00000000 --- a/.eslintrc.json +++ /dev/null @@ -1,529 +0,0 @@ -{ - "env": { - "browser": true, - "es6": true, - "node": true - }, - "parser": "@babel/eslint-parser", - "parserOptions": { - "ecmaFeatures": { - "experimentalObjectRestSpread": true, - "globalReturn": false, - "impliedStrict": true, - "jsx": true - }, - "ecmaVersion": 2017, - "requireConfigFile": false, - "sourceType": "module" - }, - "plugins": [ - "no-use-extend-native", - "babel", - "import", - "jsdoc", - "promise", - "filenames", - "unicorn" - ], - "rules": { - "accessor-pairs": 2, - "array-bracket-newline": 0, - "array-bracket-spacing": [2, "never"], - "array-callback-return": 2, - "array-element-newline": 0, - "arrow-body-style": [2, "as-needed"], - "arrow-parens": [2, "always"], - "arrow-spacing": [ - 2, - { - "after": true, - "before": true - } - ], - "babel/new-cap": 0, - "babel/no-invalid-this": 2, - "babel/object-curly-spacing": [2, "never"], - "block-scoped-var": 2, - "block-spacing": [2, "always"], - "brace-style": [ - 2, - "1tbs", - { - "allowSingleLine": false - } - ], - "callback-return": 2, - "camelcase": 0, - "capitalized-comments": 0, - "class-methods-use-this": 2, - "comma-dangle": [2, "never"], - "comma-spacing": [ - 2, - { - "after": true, - "before": false - } - ], - "comma-style": [2, "last"], - "complexity": [1, 10], - "computed-property-spacing": [2, "never"], - "consistent-return": 2, - "consistent-this": [2, "self"], - "constructor-super": 2, - "curly": 2, - "default-case": 0, - "dot-location": [2, "property"], - "dot-notation": 2, - "eol-last": 2, - "eqeqeq": 2, - "filenames/match-exported": 2, - "filenames/match-regex": [ - 2, - "^[A-Z]?[a-z]+(?:[A-Z][a-z]+)*(\\.[a-z]+)*$", - false - ], - "filenames/no-index": 0, - "for-direction": 2, - "func-call-spacing": [2, "never"], - "func-name-matching": 2, - "func-names": 0, - "func-style": [2, "expression"], - "generator-star-spacing": [ - 2, - { - "after": false, - "before": true - } - ], - "global-require": 2, - "guard-for-in": 2, - "handle-callback-err": 2, - "id-length": [ - 1, - { - "exceptions": ["P", "R", "$", "_"], - "max": 50, - "min": 2 - } - ], - "id-match": [ - 2, - "(^[A-Za-z]+(?:[A-Z][a-z]*)*\\d*$)|(^[A-Z]+(_[A-Z]+)*(_\\d$)*$)|(^(_|\\$)$)", - { - "onlyDeclarations": true, - "properties": true - } - ], - "import/default": 2, - "import/export": 2, - "import/extensions": [ - 2, - "never", - { - "json": "always" - } - ], - "import/first": [2, "absolute-first"], - "import/max-dependencies": 0, - "import/named": 2, - "import/namespace": 2, - "import/newline-after-import": 2, - "import/no-absolute-path": 2, - "import/no-amd": 2, - "import/no-anonymous-default-export": [ - 2, - { - "allowAnonymousClass": false, - "allowAnonymousFunction": false, - "allowArray": false, - "allowArrowFunction": false, - "allowLiteral": false, - "allowObject": false - } - ], - "import/no-commonjs": 2, - "import/no-deprecated": 1, - "import/no-duplicates": 0, - "import/no-dynamic-require": 2, - "import/no-extraneous-dependencies": [ - 2, - { - "devDependencies": true, - "optionalDependencies": true, - "peerDependencies": true - } - ], - "import/no-internal-modules": 0, - "import/no-mutable-exports": 2, - "import/no-named-as-default": 2, - "import/no-named-as-default-member": 2, - "import/no-named-default": 2, - "import/no-namespace": 0, - "import/no-nodejs-modules": 0, - "import/no-restricted-paths": 0, - "import/no-unassigned-import": 2, - "import/no-unresolved": 2, - "import/no-webpack-loader-syntax": 2, - "import/order": [ - 2, - { - "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], - "newlines-between": "never" - } - ], - "import/prefer-default-export": 0, - "import/unambiguous": 1, - "indent": [2, 2], - "init-declarations": 0, - "jsdoc/check-param-names": 1, - "jsdoc/check-tag-names": 1, - "jsdoc/check-types": 1, - "jsdoc/newline-after-description": [1, "always"], - "jsdoc/require-description-complete-sentence": 1, - "jsdoc/require-hyphen-before-description": 0, - "jsdoc/require-param": 0, - "jsdoc/require-param-description": 0, - "jsdoc/require-param-type": 0, - "jsdoc/require-returns-description": 0, - "jsdoc/require-returns-type": 0, - "jsx-quotes": [2, "prefer-single"], - "key-spacing": [ - 2, - { - "afterColon": true, - "beforeColon": false - } - ], - "keyword-spacing": [ - 2, - { - "after": true, - "before": true - } - ], - "line-comment-position": [ - 2, - { - "position": "above" - } - ], - "linebreak-style": [2, "unix"], - "lines-around-comment": [ - 2, - { - "allowArrayEnd": true, - "allowArrayStart": true, - "allowBlockEnd": true, - "allowBlockStart": true, - "allowObjectEnd": true, - "allowObjectStart": true, - "beforeBlockComment": true, - "beforeLineComment": true - } - ], - "lines-around-directive": [2, "always"], - "max-len": [ - 1, - { - "code": 160 - } - ], - "max-nested-callbacks": [1, 3], - "max-statements-per-line": [ - 2, - { - "max": 1 - } - ], - "multiline-ternary": 0, - "new-cap": [ - 0, - { - "capIsNew": false, - "newIsCap": true - } - ], - "new-parens": 2, - "newline-before-return": 2, - "newline-per-chained-call": 0, - "no-alert": 2, - "no-array-constructor": 2, - "no-await-in-loop": 0, - "no-buffer-constructor": 2, - "no-caller": 2, - "no-case-declarations": 2, - "no-catch-shadow": 2, - "no-class-assign": 2, - "no-compare-neg-zero": 2, - "no-cond-assign": 2, - "no-confusing-arrow": 2, - "no-console": 2, - "no-const-assign": 2, - "no-constant-condition": 1, - "no-continue": 2, - "no-control-regex": 2, - "no-debugger": 1, - "no-delete-var": 2, - "no-div-regex": 2, - "no-dupe-args": 2, - "no-dupe-class-members": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-duplicate-imports": 2, - "no-else-return": 0, - "no-empty": 2, - "no-empty-character-class": 2, - "no-empty-pattern": 2, - "no-eq-null": 2, - "no-eval": 2, - "no-ex-assign": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-extra-boolean-cast": 0, - "no-extra-parens": 2, - "no-extra-semi": 2, - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-func-assign": 2, - "no-global-assign": 2, - "no-implicit-coercion": 2, - "no-implicit-globals": 0, - "no-implied-eval": 2, - "no-inline-comments": 2, - "no-inner-declarations": 2, - "no-invalid-regexp": 2, - "no-invalid-this": 0, - "no-irregular-whitespace": 2, - "no-iterator": 2, - "no-label-var": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-lonely-if": 2, - "no-loop-func": 2, - "no-magic-numbers": 0, - "no-mixed-requires": 0, - "no-mixed-spaces-and-tabs": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": [ - 2, - { - "max": 1, - "maxBOF": 0, - "maxEOF": 1 - } - ], - "no-native-reassign": 2, - "no-negated-condition": 2, - "no-negated-in-lhs": 2, - "no-nested-ternary": 2, - "no-new": 2, - "no-new-func": 2, - "no-new-object": 2, - "no-new-require": 2, - "no-new-symbol": 2, - "no-new-wrappers": 2, - "no-obj-calls": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-param-reassign": [ - 2, - { - "props": false - } - ], - "no-path-concat": 2, - "no-process-env": 2, - "no-process-exit": 2, - "no-proto": 2, - "no-redeclare": [ - 2, - { - "builtinGlobals": true - } - ], - "no-regex-spaces": 2, - "no-restricted-globals": 0, - "no-restricted-modules": 0, - "no-restricted-properties": 0, - "no-restricted-syntax": 0, - "no-return-assign": 2, - "no-return-await": 2, - "no-script-url": 2, - "no-self-assign": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-shadow": [ - 2, - { - "builtinGlobals": false, - "hoist": "all" - } - ], - "no-shadow-restricted-names": 2, - "no-spaced-func": 2, - "no-sparse-arrays": 2, - "no-sync": 0, - "no-tabs": 2, - "no-template-curly-in-string": 2, - "no-ternary": 0, - "no-this-before-super": 2, - "no-throw-literal": 2, - "no-trailing-spaces": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-undefined": 0, - "no-underscore-dangle": 0, - "no-unexpected-multiline": 2, - "no-unmodified-loop-condition": 2, - "no-unneeded-ternary": 2, - "no-unreachable": 1, - "no-unsafe-finally": 2, - "no-unsafe-negation": 2, - "no-unused-expressions": 2, - "no-unused-vars": 2, - "no-use-before-define": 2, - "no-use-extend-native/no-use-extend-native": 2, - "no-useless-call": 2, - "no-useless-computed-key": 2, - "no-useless-concat": 2, - "no-useless-constructor": 2, - "no-useless-escape": 2, - "no-useless-rename": [ - 2, - { - "ignoreDestructuring": false, - "ignoreExport": false, - "ignoreImport": false - } - ], - "no-useless-return": 2, - "no-var": 2, - "no-void": 2, - "no-warning-comments": [ - 1, - { - "location": "start", - "terms": ["todo", "@toto"] - } - ], - "no-whitespace-before-property": 2, - "no-with": 2, - "nonblock-statement-body-position": [2, "below"], - "object-curly-spacing": [0, "never"], - "object-property-newline": [ - 2, - { - "allowMultiplePropertiesPerLine": false - } - ], - "object-shorthand": [2, "always"], - "one-var": [2, "never"], - "one-var-declaration-per-line": 2, - "operator-assignment": [2, "always"], - "operator-linebreak": [2, "after"], - "padded-blocks": [2, "never"], - "padding-line-between-statements": 0, - "prefer-arrow-callback": 2, - "prefer-const": 2, - "prefer-destructuring": 0, - "prefer-numeric-literals": 2, - "prefer-promise-reject-errors": 2, - "prefer-reflect": 0, - "prefer-rest-params": 2, - "prefer-spread": 2, - "prefer-template": 0, - "promise/always-return": 2, - "promise/avoid-new": 0, - "promise/catch-or-return": 2, - "promise/no-callback-in-promise": 0, - "promise/no-native": 0, - "promise/no-nesting": 0, - "promise/no-promise-in-callback": 0, - "promise/no-return-wrap": 2, - "promise/param-names": 2, - "promise/prefer-await-to-callbacks": 1, - "promise/prefer-await-to-then": 1, - "quote-props": [2, "as-needed"], - "quotes": [2, "single"], - "radix": 2, - "require-await": 1, - "require-jsdoc": 0, - "require-yield": 2, - "semi": [2, "always"], - "semi-spacing": [ - 2, - { - "after": true, - "before": false - } - ], - "semi-style": [2, "last"], - "sort-keys": [ - 2, - "asc", - { - "caseSensitive": false, - "natural": true - } - ], - "sort-vars": 2, - "space-before-blocks": [2, "always"], - "space-before-function-paren": [2, "always"], - "space-in-parens": [2, "never"], - "space-infix-ops": 2, - "space-unary-ops": [ - 2, - { - "nonwords": false, - "words": true - } - ], - "spaced-comment": [2, "always"], - "strict": [2, "never"], - "switch-colon-spacing": [ - 2, - { - "after": true, - "before": false - } - ], - "symbol-description": 2, - "template-tag-spacing": [2, "never"], - "unicode-bom": [2, "never"], - "unicorn/catch-error-name": [ - "error", - { - "name": "error" - } - ], - "unicorn/custom-error-definition": 0, - "unicorn/escape-case": 2, - "unicorn/explicit-length-check": 0, - "unicorn/filename-case": 0, - "unicorn/no-abusive-eslint-disable": 2, - "unicorn/no-array-instanceof": 2, - "unicorn/no-hex-escape": 2, - "unicorn/no-new-buffer": 2, - "unicorn/no-process-exit": 0, - "unicorn/number-literal-case": 2, - "unicorn/prefer-starts-ends-with": 2, - "unicorn/prefer-type-error": 2, - "unicorn/throw-new-error": 2, - "use-isnan": 2, - "valid-jsdoc": 0, - "valid-typeof": 2, - "vars-on-top": 2, - "wrap-iife": [2, "inside"], - "wrap-regex": 0, - "yoda": 0, - - "import/unambiguous": "off", - "import/no-commonjs": "off", - "promise/prefer-await-to-then": "off", - "strict": "off" - }, - "settings": { - "import/extensions": [".js"] - } -} diff --git a/.husky/pre-commit b/.husky/pre-commit index 44764e3e..adde63d5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,4 @@ [ -n "$CI" ] && exit 0 . "$(dirname "$0")/_/husky.sh" -yarn lint +yarn lint-staged diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg index 05005dff..0442a7b8 100755 --- a/.husky/prepare-commit-msg +++ b/.husky/prepare-commit-msg @@ -1,4 +1,5 @@ [ -n "$CI" ] && exit 0 +yarn pretty-quick --staged exec < /dev/tty node ./lib/cli.js --hook || true \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..db4c6d9b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/.prettierignore_staged b/.prettierignore_staged new file mode 100644 index 00000000..db4c6d9b --- /dev/null +++ b/.prettierignore_staged @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index e1cb6f1c..00000000 --- a/.prettierrc +++ /dev/null @@ -1,10 +0,0 @@ -{ - "arrowParens": "always", - "bracketSpacing": false, - "endOfLine": "auto", - "printWidth": 85, - "semi": true, - "singleQuote": true, - "tabWidth": 2, - "trailingComma": "none" -} diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..1c9798c8 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,10 @@ +module.exports = { + arrowParens: 'always', + bracketSpacing: false, + endOfLine: 'auto', + printWidth: 85, + semi: true, + singleQuote: true, + tabWidth: 2, + trailingComma: 'none' +}; diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 00000000..5f26ed62 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,24 @@ +/* eslint-disable filenames/match-regex */ +const escapedFileNames = (filenames) => + filenames.map((filename) => `"${filename}"`).join(' '); + +module.exports = { + './*.{js,jsx,ts,tsx}': (files) => { + const filenames = escapedFileNames(files); + + return [ + `prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${filenames}`, + `eslint --no-ignore --max-warnings=0 --fix ${filenames}`, + `git add ${filenames}` + ]; + }, + + './*.{json,md,mdx,css,html,yml,yaml,scss}': (files) => { + const filenames = escapedFileNames(files); + + return [ + `prettier --with-node-modules --ignore-path='./.prettierignore_staged' --write ${filenames}`, + `git add ${filenames}` + ]; + } +}; diff --git a/package.json b/package.json index 5d51715f..b23e62b2 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,14 @@ "build": "yarn build:cli && yarn build:cz", "clean": "rimraf dist binaries", "eslint": "eslint lib/*.js", - "lint": "yarn eslint", + "lint:eslint": "eslint . --ext js,jsx,ts,tsx --max-warnings=0", + "lint:fix": "yarn lint:prettier --write && yarn lint:eslint --fix", + "lint:prettier": "prettier \"**/*.{js,jsx,ts,tsx,json,md,mdx,css,html,yml,yaml,scss}\"", + "lint": "yarn lint:prettier --check && yarn lint:eslint", "postinstall": "is-ci || husky install", "postpublish": "pinst --enable", "prepublishOnly": "pinst --disable", + "pretty-quick": "pretty-quick", "release": "semantic-release", "test:coverage": "jest --coverage", "test:dev": "jest --watch", @@ -45,6 +49,7 @@ "commitizen": "4.2.3", "dotenv": "8.2.0", "eslint": "7.21.0", + "eslint-config-prettier": "8.1.0", "eslint-plugin-babel": "5.3.1", "eslint-plugin-filenames": "1.3.2", "eslint-plugin-import": "2.22.1", @@ -60,10 +65,13 @@ "inquirer-list-search-prompt": "1.0.2", "is-ci": "3.0.0", "jest": "26.6.3", + "lint-staged": "10.5.4", "minimist": "1.2.5", "mocha": "8.3.0", "pinst": "2.1.6", "pkg": "4.4.9", + "prettier": "2.2.1", + "pretty-quick": "3.1.0", "rimraf": "3.0.2", "semantic-release": "17.4.0", "signale": "1.4.0", diff --git a/test/.eslintrc.js b/test/.eslintrc.js new file mode 100644 index 00000000..79fd96d9 --- /dev/null +++ b/test/.eslintrc.js @@ -0,0 +1,13 @@ +/* eslint-disable filenames/match-regex */ +module.exports = { + env: { + jest: true + }, + plugins: ['jest'], + rules: { + 'jest/no-disabled-tests': 'error', + 'jest/no-focused-tests': 'error', + 'jest/no-identical-title': 'error', + 'jest/valid-expect': 'error' + } +}; diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 83449b84..00000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "env": { - "jest": true - }, - "plugins": [ - "jest" - ], - "rules": { - "jest/no-disabled-tests": "error", - "jest/no-focused-tests": "error", - "jest/no-identical-title": "error", - "jest/valid-expect": "error" - } -} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b8bf9501..c671a972 100644 --- a/yarn.lock +++ b/yarn.lock @@ -995,6 +995,11 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/minimatch@^3.0.3": + version "3.0.3" + resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" + integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== + "@types/minimist@^1.2.0": version "1.2.1" resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.1.tgz#283f669ff76d7b8260df8ab7a4262cc83d988256" @@ -1343,6 +1348,11 @@ arr-union@^3.1.0: resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= +array-differ@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" + integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== + array-filter@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83" @@ -1388,6 +1398,11 @@ arrify@^1.0.1: resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" integrity sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0= +arrify@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/arrify/-/arrify-2.0.1.tgz#c9655e9331e0abcd588d2a7cad7e9956f66701fa" + integrity sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug== + asap@^2.0.0: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" @@ -3175,6 +3190,11 @@ escodegen@^1.14.1: optionalDependencies: source-map "~0.6.1" +eslint-config-prettier@8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz#4ef1eaf97afe5176e6a75ddfb57c335121abc5a6" + integrity sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw== + eslint-import-resolver-node@^0.3.4: version "0.3.4" resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" @@ -6452,6 +6472,11 @@ move-concurrently@^1.0.1: rimraf "^2.5.4" run-queue "^1.0.3" +mri@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.6.tgz#49952e1044db21dbf90f6cd92bc9c9a777d415a6" + integrity sha512-oi1b3MfbyGa7FJMP9GmLTttni5JoICpYBRlq+x5V16fZbLsnL9N3wFqqIm/nIG43FjUFkFh9Epzp/kzUGUnJxQ== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -6472,6 +6497,17 @@ multimap@^1.1.0: resolved "https://registry.yarnpkg.com/multimap/-/multimap-1.1.0.tgz#5263febc085a1791c33b59bb3afc6a76a2a10ca8" integrity sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw== +multimatch@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/multimatch/-/multimatch-4.0.0.tgz#8c3c0f6e3e8449ada0af3dd29efb491a375191b3" + integrity sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ== + dependencies: + "@types/minimatch" "^3.0.3" + array-differ "^3.0.0" + array-union "^2.1.0" + arrify "^2.0.1" + minimatch "^3.0.4" + multistream@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/multistream/-/multistream-2.1.1.tgz#629d3a29bd76623489980d04519a2c365948148c" @@ -7543,6 +7579,11 @@ prepend-http@^1.0.1: resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= +prettier@2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5" + integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== + pretty-format@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93" @@ -7553,6 +7594,18 @@ pretty-format@^26.6.2: ansi-styles "^4.0.0" react-is "^17.0.1" +pretty-quick@3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/pretty-quick/-/pretty-quick-3.1.0.tgz#cb172e9086deb57455dea7c7e8f136cd0a4aef6c" + integrity sha512-DtxIxksaUWCgPFN7E1ZZk4+Aav3CCuRdhrDSFZENb404sYMtuo9Zka823F+Mgeyt8Zt3bUiCjFzzWYE9LYqkmQ== + dependencies: + chalk "^3.0.0" + execa "^4.0.0" + find-up "^4.1.0" + ignore "^5.1.4" + mri "^1.1.5" + multimatch "^4.0.0" + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"