diff --git a/.eslintrc.js b/.eslintrc.js index 8b6d6a6..a431e21 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,10 +5,7 @@ // https://eslint.org/docs/developer-guide/shareable-configs#publishing-a-shareable-config module.exports = { - // https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/parser/README.md - // No need to define @typescript-eslint/parser as the react-app config specifies - // it as an override for all ts and tsx files, otherwise babel-eslint is used. - // parser: "@typescript-eslint/parser", + parser: "@typescript-eslint/parser", parserOptions: { ecmaVersion: 6, sourceType: "module", @@ -62,48 +59,49 @@ module.exports = { //************************************************************************ // Enforced // + curly: "warn", // Set console calls to emit warnings as not enabled by eslint:recommended - "no-console": "error", + "no-console": "warn", // Increase react-hooks/exhaustive-deps from warning to error - "react-hooks/exhaustive-deps": "error", - // //************************************************************************ - // // Relaxed: rules we are progressively adopting - // // - // // enforce types - // "@typescript-eslint/no-explicit-any": "warn", - // // enforce typed exports - // "@typescript-eslint/explicit-module-boundary-types": "warn", - // // enforce clean code - // "@typescript-eslint/no-unused-vars": "warn", - // // enforce interface naming convention + "react-hooks/exhaustive-deps": "warn", + // enforce types + "@typescript-eslint/no-explicit-any": "warn", + // Bans specific types from being used (e.g. builtin types) + "@typescript-eslint/ban-types": "warn", + // enforce typed exports + "@typescript-eslint/explicit-module-boundary-types": "warn", + // enforce clean code + "@typescript-eslint/no-unused-vars": "warn", + // Keep naming convention for later + // enforce interface naming convention // "@typescript-eslint/naming-convention": [ // "warn", // { - // "selector": "interface", - // "format": ["PascalCase"], - // "custom": { - // "regex": "^I[A-Z]", - // "match": true - // } + // selector: "interface", + // format: ["PascalCase"], + // custom: { + // regex: "^I[A-Z]", + // match: true, + // }, // }, // { - // "selector": "typeAlias", - // "format": ["PascalCase"], - // "custom": { - // "regex": "^T[A-Z]", - // "match": true - // } - // } - // ], - // // enforce import ordering - // "sort-imports": [ - // "warn", - // { - // "allowSeparatedGroups": true, - // "memberSyntaxSortOrder": ["none", "all", "single", "multiple"], - // "ignoreCase": false - // } + // selector: "typeAlias", + // format: ["PascalCase"], + // custom: { + // regex: "^T[A-Z]", + // match: true, + // }, + // }, // ], + // enforce import ordering + "sort-imports": [ + "warn", + { + allowSeparatedGroups: true, + memberSyntaxSortOrder: ["none", "all", "single", "multiple"], + ignoreCase: false, + }, + ], }, overrides: [ // Typescript overrides @@ -141,7 +139,7 @@ module.exports = { // > 10 chars and contains a separator "." so it would have to follow the no-duplicate-string rule "sonarjs/no-duplicate-string": "off", //Default complexity is 15 but since cypress test have some before and after hooks, let's increase a little bit - "sonarjs/cognitive-complexity": ["error", 20], + "sonarjs/cognitive-complexity": ["warn", 20], }, }, ], diff --git a/.gitignore b/.gitignore index e432813..a502002 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules/ # Ignore local build emerson-eps-eslint-config-*.tgz +# tsc +tmp diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..f306344 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,18 @@ +# Use .gitignore syntax + +# Generated/third-party code +tmp/ +node_modules/ + +# IDE Config +.vscode/ +.idea/ + +# tooling +.scannerwork/ + +# Generated files +config.json + +# npm can rewrite the whole package.json file with some commands +package.json diff --git a/README.md b/README.md index 6ab1512..47a9251 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This is the home of the shared E&P Software ESLint configs. The default config s ## Usage -The ESLint config and Prettier config must both be added to get the full shared configuration. The ESLint configuration includes the prettier plugin which will load the prettier config and report issues as errors. +The ESLint config and Prettier config must both be added to get the full shared configuration. ### (1) Install the shared Prettier and ESLint configs @@ -26,12 +26,12 @@ npm install --save-dev prettier eslint ### (2) Configure Prettier -Add `@emerson-eps/prettier-config` to your `package.json`: +Add `@emerson-eps/prettier-config` to your `.prettierrc.js`: -```json -{ - "prettier": "@emerson-eps/prettier-config" -} +```js +module.exports = { + ...require("@emerson-eps/prettier-config"), +}; ``` For more advanced setups, including how to override settings, see the instructions in the [@emerson-eps/prettier-config](https://github.com/emerson-eps/prettier-config) repository. @@ -49,6 +49,10 @@ Specify the package in the [`extends`](http://eslint.org/docs/user-guide/configu } ``` +### List of current rules + +The list of applied rules can be found [here](./config.json) + ## Running ESLint on your code Add a lint script to your `package.json`, for example: @@ -56,7 +60,7 @@ Add a lint script to your `package.json`, for example: ```json { "scripts": { - "lint": "eslint ." + "lint": "eslint . --max-warnings=0" } } ``` diff --git a/config.json b/config.json new file mode 100644 index 0000000..867caed --- /dev/null +++ b/config.json @@ -0,0 +1,1334 @@ +{ + "env": { + "node": true, + "es6": true, + "jest": true, + "jasmine": true, + "browser": true, + "commonjs": true + }, + "globals": {}, + "parser": "I:\\GitManaged\\GitHubEMR\\eslint-config\\node_modules\\@typescript-eslint\\parser\\dist\\index.js", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true + }, + "project": "./tsconfig.json" + }, + "plugins": [ + "jsx-a11y", + "flowtype", + "import", + "sonarjs", + "react-hooks", + "react", + "@typescript-eslint" + ], + "reportUnusedDisableDirectives": true, + "rules": { + "curly": [ + "error" + ], + "no-console": [ + "error" + ], + "react-hooks/exhaustive-deps": [ + "error" + ], + "@typescript-eslint/no-explicit-any": [ + "error" + ], + "@typescript-eslint/ban-types": [ + "error" + ], + "@typescript-eslint/explicit-module-boundary-types": [ + "error" + ], + "@typescript-eslint/no-unused-vars": [ + "error" + ], + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + }, + { + "selector": "typeAlias", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^T[A-Z]", + "match": true + } + } + ], + "sort-imports": [ + "error", + { + "allowSeparatedGroups": true, + "memberSyntaxSortOrder": [ + "none", + "all", + "single", + "multiple" + ], + "ignoreCase": false, + "ignoreDeclarationSort": false, + "ignoreMemberSort": false + } + ], + "lines-around-comment": [ + 0 + ], + "max-len": [ + 0 + ], + "no-confusing-arrow": [ + 0 + ], + "no-mixed-operators": [ + 0, + { + "groups": [ + [ + "&", + "|", + "^", + "~", + "<<", + ">>", + ">>>" + ], + [ + "==", + "!=", + "===", + "!==", + ">", + ">=", + "<", + "<=" + ], + [ + "&&", + "||" + ], + [ + "in", + "instanceof" + ] + ], + "allowSamePrecedence": false + } + ], + "no-tabs": [ + 0 + ], + "no-unexpected-multiline": [ + 0 + ], + "quotes": [ + 0 + ], + "@typescript-eslint/quotes": [ + 0 + ], + "babel/quotes": [ + 0 + ], + "vue/html-self-closing": [ + 0 + ], + "vue/max-len": [ + 0 + ], + "array-bracket-newline": [ + "off" + ], + "array-bracket-spacing": [ + "off" + ], + "array-element-newline": [ + "off" + ], + "arrow-parens": [ + "off" + ], + "arrow-spacing": [ + "off" + ], + "block-spacing": [ + "off" + ], + "brace-style": [ + "off" + ], + "comma-dangle": [ + "off" + ], + "comma-spacing": [ + "off" + ], + "comma-style": [ + "off" + ], + "computed-property-spacing": [ + "off" + ], + "dot-location": [ + "off", + "property" + ], + "eol-last": [ + "off" + ], + "func-call-spacing": [ + "off" + ], + "function-call-argument-newline": [ + "off" + ], + "function-paren-newline": [ + "off" + ], + "generator-star": [ + "off" + ], + "generator-star-spacing": [ + "off" + ], + "implicit-arrow-linebreak": [ + "off" + ], + "indent": [ + "off" + ], + "jsx-quotes": [ + "off" + ], + "key-spacing": [ + "off" + ], + "keyword-spacing": [ + "off" + ], + "linebreak-style": [ + "off" + ], + "multiline-ternary": [ + "off" + ], + "newline-per-chained-call": [ + "off" + ], + "new-parens": [ + "off" + ], + "no-arrow-condition": [ + "off" + ], + "no-comma-dangle": [ + "off" + ], + "no-extra-parens": [ + "off" + ], + "no-extra-semi": [ + "off" + ], + "no-floating-decimal": [ + "off" + ], + "no-mixed-spaces-and-tabs": [ + "off" + ], + "no-multi-spaces": [ + "off" + ], + "no-multiple-empty-lines": [ + "off" + ], + "no-reserved-keys": [ + "off" + ], + "no-space-before-semi": [ + "off" + ], + "no-trailing-spaces": [ + "off" + ], + "no-whitespace-before-property": [ + "off" + ], + "no-wrap-func": [ + "off" + ], + "nonblock-statement-body-position": [ + "off" + ], + "object-curly-newline": [ + "off" + ], + "object-curly-spacing": [ + "off" + ], + "object-property-newline": [ + "off" + ], + "one-var-declaration-per-line": [ + "off" + ], + "operator-linebreak": [ + "off" + ], + "padded-blocks": [ + "off" + ], + "quote-props": [ + "off" + ], + "rest-spread-spacing": [ + "off", + "never" + ], + "semi": [ + "off" + ], + "semi-spacing": [ + "off" + ], + "semi-style": [ + "off" + ], + "space-after-function-name": [ + "off" + ], + "space-after-keywords": [ + "off" + ], + "space-before-blocks": [ + "off" + ], + "space-before-function-paren": [ + "off" + ], + "space-before-function-parentheses": [ + "off" + ], + "space-before-keywords": [ + "off" + ], + "space-in-brackets": [ + "off" + ], + "space-in-parens": [ + "off" + ], + "space-infix-ops": [ + "off" + ], + "space-return-throw-case": [ + "off" + ], + "space-unary-ops": [ + "off" + ], + "space-unary-word-ops": [ + "off" + ], + "switch-colon-spacing": [ + "off" + ], + "template-curly-spacing": [ + "off" + ], + "template-tag-spacing": [ + "off" + ], + "unicode-bom": [ + "off", + "never" + ], + "wrap-iife": [ + "off" + ], + "wrap-regex": [ + "off" + ], + "yield-star-spacing": [ + "off" + ], + "@babel/object-curly-spacing": [ + "off" + ], + "@babel/semi": [ + "off" + ], + "@typescript-eslint/brace-style": [ + "off" + ], + "@typescript-eslint/comma-dangle": [ + "off" + ], + "@typescript-eslint/comma-spacing": [ + "off" + ], + "@typescript-eslint/func-call-spacing": [ + "off" + ], + "@typescript-eslint/indent": [ + "off" + ], + "@typescript-eslint/keyword-spacing": [ + "off" + ], + "@typescript-eslint/member-delimiter-style": [ + "off" + ], + "@typescript-eslint/no-extra-parens": [ + "off" + ], + "@typescript-eslint/no-extra-semi": [ + "off" + ], + "@typescript-eslint/object-curly-spacing": [ + "off" + ], + "@typescript-eslint/semi": [ + "off" + ], + "@typescript-eslint/space-before-function-paren": [ + "off" + ], + "@typescript-eslint/space-infix-ops": [ + "off" + ], + "@typescript-eslint/type-annotation-spacing": [ + "off" + ], + "babel/object-curly-spacing": [ + "off" + ], + "babel/semi": [ + "off" + ], + "flowtype/boolean-style": [ + "off" + ], + "flowtype/delimiter-dangle": [ + "off" + ], + "flowtype/generic-spacing": [ + "off" + ], + "flowtype/object-type-curly-spacing": [ + "off" + ], + "flowtype/object-type-delimiter": [ + "off" + ], + "flowtype/quotes": [ + "off" + ], + "flowtype/semi": [ + "off" + ], + "flowtype/space-after-type-colon": [ + "off" + ], + "flowtype/space-before-generic-bracket": [ + "off" + ], + "flowtype/space-before-type-colon": [ + "off" + ], + "flowtype/union-intersection-spacing": [ + "off" + ], + "react/jsx-child-element-spacing": [ + "off" + ], + "react/jsx-closing-bracket-location": [ + "off" + ], + "react/jsx-closing-tag-location": [ + "off" + ], + "react/jsx-curly-newline": [ + "off" + ], + "react/jsx-curly-spacing": [ + "off" + ], + "react/jsx-equals-spacing": [ + "off" + ], + "react/jsx-first-prop-new-line": [ + "off" + ], + "react/jsx-indent": [ + "off" + ], + "react/jsx-indent-props": [ + "off" + ], + "react/jsx-max-props-per-line": [ + "off" + ], + "react/jsx-newline": [ + "off" + ], + "react/jsx-one-expression-per-line": [ + "off" + ], + "react/jsx-props-no-multi-spaces": [ + "off" + ], + "react/jsx-tag-spacing": [ + "off" + ], + "react/jsx-wrap-multilines": [ + "off" + ], + "standard/array-bracket-even-spacing": [ + "off" + ], + "standard/computed-property-even-spacing": [ + "off" + ], + "standard/object-curly-even-spacing": [ + "off" + ], + "unicorn/empty-brace-spaces": [ + "off" + ], + "unicorn/no-nested-ternary": [ + "off" + ], + "unicorn/number-literal-case": [ + "off" + ], + "vue/array-bracket-newline": [ + "off" + ], + "vue/array-bracket-spacing": [ + "off" + ], + "vue/arrow-spacing": [ + "off" + ], + "vue/block-spacing": [ + "off" + ], + "vue/block-tag-newline": [ + "off" + ], + "vue/brace-style": [ + "off" + ], + "vue/comma-dangle": [ + "off" + ], + "vue/comma-spacing": [ + "off" + ], + "vue/comma-style": [ + "off" + ], + "vue/dot-location": [ + "off" + ], + "vue/func-call-spacing": [ + "off" + ], + "vue/html-closing-bracket-newline": [ + "off" + ], + "vue/html-closing-bracket-spacing": [ + "off" + ], + "vue/html-end-tags": [ + "off" + ], + "vue/html-indent": [ + "off" + ], + "vue/html-quotes": [ + "off" + ], + "vue/key-spacing": [ + "off" + ], + "vue/keyword-spacing": [ + "off" + ], + "vue/max-attributes-per-line": [ + "off" + ], + "vue/multiline-html-element-content-newline": [ + "off" + ], + "vue/mustache-interpolation-spacing": [ + "off" + ], + "vue/no-extra-parens": [ + "off" + ], + "vue/no-multi-spaces": [ + "off" + ], + "vue/no-spaces-around-equal-signs-in-attribute": [ + "off" + ], + "vue/object-curly-newline": [ + "off" + ], + "vue/object-curly-spacing": [ + "off" + ], + "vue/object-property-newline": [ + "off" + ], + "vue/operator-linebreak": [ + "off" + ], + "vue/script-indent": [ + "off" + ], + "vue/singleline-html-element-content-newline": [ + "off" + ], + "vue/space-in-parens": [ + "off" + ], + "vue/space-infix-ops": [ + "off" + ], + "vue/space-unary-ops": [ + "off" + ], + "vue/template-curly-spacing": [ + "off" + ], + "indent-legacy": [ + "off" + ], + "no-spaced-func": [ + "off" + ], + "react/jsx-space-before-closing": [ + "off" + ], + "sonarjs/cognitive-complexity": [ + "error" + ], + "sonarjs/elseif-without-else": [ + "off" + ], + "sonarjs/max-switch-cases": [ + "error" + ], + "sonarjs/no-all-duplicated-branches": [ + "error" + ], + "sonarjs/no-collapsible-if": [ + "error" + ], + "sonarjs/no-collection-size-mischeck": [ + "error" + ], + "sonarjs/no-duplicate-string": [ + "error" + ], + "sonarjs/no-duplicated-branches": [ + "error" + ], + "sonarjs/no-element-overwrite": [ + "error" + ], + "sonarjs/no-empty-collection": [ + "error" + ], + "sonarjs/no-extra-arguments": [ + "error" + ], + "sonarjs/no-gratuitous-expressions": [ + "error" + ], + "sonarjs/no-identical-conditions": [ + "error" + ], + "sonarjs/no-identical-expressions": [ + "error" + ], + "sonarjs/no-identical-functions": [ + "error" + ], + "sonarjs/no-ignored-return": [ + "error" + ], + "sonarjs/no-inverted-boolean-check": [ + "error" + ], + "sonarjs/no-nested-switch": [ + "error" + ], + "sonarjs/no-nested-template-literals": [ + "error" + ], + "sonarjs/no-one-iteration-loop": [ + "error" + ], + "sonarjs/no-redundant-boolean": [ + "error" + ], + "sonarjs/no-redundant-jump": [ + "error" + ], + "sonarjs/no-same-line-conditional": [ + "error" + ], + "sonarjs/no-small-switch": [ + "error" + ], + "sonarjs/no-unused-collection": [ + "error" + ], + "sonarjs/no-use-of-empty-return-value": [ + "error" + ], + "sonarjs/no-useless-catch": [ + "error" + ], + "sonarjs/non-existent-operator": [ + "error" + ], + "sonarjs/prefer-immediate-return": [ + "error" + ], + "sonarjs/prefer-object-literal": [ + "error" + ], + "sonarjs/prefer-single-boolean-return": [ + "error" + ], + "sonarjs/prefer-while": [ + "error" + ], + "react-hooks/rules-of-hooks": [ + "error" + ], + "react/display-name": [ + 2 + ], + "react/jsx-key": [ + 2 + ], + "react/jsx-no-comment-textnodes": [ + 2 + ], + "react/jsx-no-duplicate-props": [ + 2 + ], + "react/jsx-no-target-blank": [ + 2 + ], + "react/jsx-no-undef": [ + 2 + ], + "react/jsx-uses-react": [ + 2 + ], + "react/jsx-uses-vars": [ + 2 + ], + "react/no-children-prop": [ + 2 + ], + "react/no-danger-with-children": [ + 2 + ], + "react/no-deprecated": [ + 2 + ], + "react/no-direct-mutation-state": [ + 2 + ], + "react/no-find-dom-node": [ + 2 + ], + "react/no-is-mounted": [ + 2 + ], + "react/no-render-return-value": [ + 2 + ], + "react/no-string-refs": [ + 2 + ], + "react/no-unescaped-entities": [ + 2 + ], + "react/no-unknown-property": [ + 2 + ], + "react/no-unsafe": [ + 0 + ], + "react/prop-types": [ + 2 + ], + "react/react-in-jsx-scope": [ + 2 + ], + "react/require-render-return": [ + 2 + ], + "array-callback-return": [ + "warn" + ], + "default-case": [ + "warn", + { + "commentPattern": "^no default$" + } + ], + "eqeqeq": [ + "warn", + "smart" + ], + "no-array-constructor": [ + "warn" + ], + "no-caller": [ + "warn" + ], + "no-cond-assign": [ + "warn", + "except-parens" + ], + "no-const-assign": [ + "warn" + ], + "no-control-regex": [ + "warn" + ], + "no-delete-var": [ + "warn" + ], + "no-dupe-args": [ + "warn" + ], + "no-dupe-class-members": [ + "warn" + ], + "no-dupe-keys": [ + "warn" + ], + "no-duplicate-case": [ + "warn" + ], + "no-empty-character-class": [ + "warn" + ], + "no-empty-pattern": [ + "warn" + ], + "no-eval": [ + "warn" + ], + "no-ex-assign": [ + "warn" + ], + "no-extend-native": [ + "warn" + ], + "no-extra-bind": [ + "warn" + ], + "no-extra-label": [ + "warn" + ], + "no-fallthrough": [ + "warn" + ], + "no-func-assign": [ + "warn" + ], + "no-implied-eval": [ + "warn" + ], + "no-invalid-regexp": [ + "warn" + ], + "no-iterator": [ + "warn" + ], + "no-label-var": [ + "warn" + ], + "no-labels": [ + "warn", + { + "allowLoop": true, + "allowSwitch": false + } + ], + "no-lone-blocks": [ + "warn" + ], + "no-loop-func": [ + "warn" + ], + "no-multi-str": [ + "warn" + ], + "no-native-reassign": [ + "warn" + ], + "no-negated-in-lhs": [ + "warn" + ], + "no-new-func": [ + "warn" + ], + "no-new-object": [ + "warn" + ], + "no-new-symbol": [ + "warn" + ], + "no-new-wrappers": [ + "warn" + ], + "no-obj-calls": [ + "warn" + ], + "no-octal": [ + "warn" + ], + "no-octal-escape": [ + "warn" + ], + "no-redeclare": [ + "warn" + ], + "no-regex-spaces": [ + "warn" + ], + "no-restricted-syntax": [ + "warn", + "WithStatement" + ], + "no-script-url": [ + "warn" + ], + "no-self-assign": [ + "warn" + ], + "no-self-compare": [ + "warn" + ], + "no-sequences": [ + "warn" + ], + "no-shadow-restricted-names": [ + "warn" + ], + "no-sparse-arrays": [ + "warn" + ], + "no-template-curly-in-string": [ + "warn" + ], + "no-this-before-super": [ + "warn" + ], + "no-throw-literal": [ + "warn" + ], + "no-undef": [ + "error" + ], + "no-restricted-globals": [ + "error", + "addEventListener", + "blur", + "close", + "closed", + "confirm", + "defaultStatus", + "defaultstatus", + "event", + "external", + "find", + "focus", + "frameElement", + "frames", + "history", + "innerHeight", + "innerWidth", + "length", + "location", + "locationbar", + "menubar", + "moveBy", + "moveTo", + "name", + "onblur", + "onerror", + "onfocus", + "onload", + "onresize", + "onunload", + "open", + "opener", + "opera", + "outerHeight", + "outerWidth", + "pageXOffset", + "pageYOffset", + "parent", + "print", + "removeEventListener", + "resizeBy", + "resizeTo", + "screen", + "screenLeft", + "screenTop", + "screenX", + "screenY", + "scroll", + "scrollbars", + "scrollBy", + "scrollTo", + "scrollX", + "scrollY", + "self", + "status", + "statusbar", + "stop", + "toolbar", + "top" + ], + "no-unreachable": [ + "warn" + ], + "no-unused-expressions": [ + "error", + { + "allowShortCircuit": true, + "allowTernary": true, + "allowTaggedTemplates": true, + "enforceForJSX": false + } + ], + "no-unused-labels": [ + "warn" + ], + "no-unused-vars": [ + "warn", + { + "args": "none", + "ignoreRestSiblings": true + } + ], + "no-use-before-define": [ + "warn", + { + "functions": false, + "classes": false, + "variables": false + } + ], + "no-useless-computed-key": [ + "warn" + ], + "no-useless-concat": [ + "warn" + ], + "no-useless-constructor": [ + "warn" + ], + "no-useless-escape": [ + "warn" + ], + "no-useless-rename": [ + "warn", + { + "ignoreDestructuring": false, + "ignoreImport": false, + "ignoreExport": false + } + ], + "no-with": [ + "warn" + ], + "require-yield": [ + "warn" + ], + "strict": [ + "warn", + "never" + ], + "use-isnan": [ + "warn" + ], + "valid-typeof": [ + "warn" + ], + "no-restricted-properties": [ + "error", + { + "object": "require", + "property": "ensure", + "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" + }, + { + "object": "System", + "property": "import", + "message": "Please use import() instead. More info: https://facebook.github.io/create-react-app/docs/code-splitting" + } + ], + "getter-return": [ + "warn" + ], + "import/first": [ + "error" + ], + "import/no-amd": [ + "error" + ], + "import/no-anonymous-default-export": [ + "warn" + ], + "import/no-webpack-loader-syntax": [ + "error" + ], + "react/forbid-foreign-prop-types": [ + "warn", + { + "allowInPropTypes": true + } + ], + "react/jsx-pascal-case": [ + "warn", + { + "allowAllCaps": true, + "ignore": [] + } + ], + "react/no-typos": [ + "error" + ], + "react/style-prop-object": [ + "warn" + ], + "jsx-a11y/alt-text": [ + "warn" + ], + "jsx-a11y/anchor-has-content": [ + "warn" + ], + "jsx-a11y/anchor-is-valid": [ + "warn", + { + "aspects": [ + "noHref", + "invalidHref" + ] + } + ], + "jsx-a11y/aria-activedescendant-has-tabindex": [ + "warn" + ], + "jsx-a11y/aria-props": [ + "warn" + ], + "jsx-a11y/aria-proptypes": [ + "warn" + ], + "jsx-a11y/aria-role": [ + "warn", + { + "ignoreNonDOM": true + } + ], + "jsx-a11y/aria-unsupported-elements": [ + "warn" + ], + "jsx-a11y/heading-has-content": [ + "warn" + ], + "jsx-a11y/iframe-has-title": [ + "warn" + ], + "jsx-a11y/img-redundant-alt": [ + "warn" + ], + "jsx-a11y/no-access-key": [ + "warn" + ], + "jsx-a11y/no-distracting-elements": [ + "warn" + ], + "jsx-a11y/no-redundant-roles": [ + "warn" + ], + "jsx-a11y/role-has-required-aria-props": [ + "warn" + ], + "jsx-a11y/role-supports-aria-props": [ + "warn" + ], + "jsx-a11y/scope": [ + "warn" + ], + "flowtype/define-flow-type": [ + "warn" + ], + "flowtype/require-valid-file-annotation": [ + "warn" + ], + "flowtype/use-flow-type": [ + "warn" + ], + "@typescript-eslint/adjacent-overload-signatures": [ + "error" + ], + "@typescript-eslint/ban-ts-comment": [ + "error" + ], + "@typescript-eslint/no-array-constructor": [ + "error" + ], + "no-empty-function": [ + "off" + ], + "@typescript-eslint/no-empty-function": [ + "error" + ], + "@typescript-eslint/no-empty-interface": [ + "error" + ], + "@typescript-eslint/no-extra-non-null-assertion": [ + "error" + ], + "@typescript-eslint/no-inferrable-types": [ + "error" + ], + "@typescript-eslint/no-misused-new": [ + "error" + ], + "@typescript-eslint/no-namespace": [ + "error" + ], + "@typescript-eslint/no-non-null-asserted-optional-chain": [ + "error" + ], + "@typescript-eslint/no-non-null-assertion": [ + "warn" + ], + "@typescript-eslint/no-this-alias": [ + "error" + ], + "@typescript-eslint/no-var-requires": [ + "error" + ], + "@typescript-eslint/prefer-as-const": [ + "error" + ], + "@typescript-eslint/prefer-namespace-keyword": [ + "error" + ], + "@typescript-eslint/triple-slash-reference": [ + "error" + ], + "constructor-super": [ + "error" + ], + "for-direction": [ + "error" + ], + "no-async-promise-executor": [ + "error" + ], + "no-case-declarations": [ + "error" + ], + "no-class-assign": [ + "error" + ], + "no-compare-neg-zero": [ + "error" + ], + "no-constant-condition": [ + "error" + ], + "no-debugger": [ + "error" + ], + "no-dupe-else-if": [ + "error" + ], + "no-empty": [ + "error" + ], + "no-extra-boolean-cast": [ + "error" + ], + "no-global-assign": [ + "error" + ], + "no-import-assign": [ + "error" + ], + "no-inner-declarations": [ + "error" + ], + "no-irregular-whitespace": [ + "error" + ], + "no-misleading-character-class": [ + "error" + ], + "no-prototype-builtins": [ + "error" + ], + "no-setter-return": [ + "error" + ], + "no-unsafe-finally": [ + "error" + ], + "no-unsafe-negation": [ + "error" + ], + "no-useless-catch": [ + "error" + ] + }, + "settings": { + "react": { + "version": "detect" + } + }, + "ignorePatterns": [ + "build", + "coverage", + "dist*", + "doc", + "node_modules", + "tmp" + ] +} diff --git a/package.json b/package.json index 12237bd..36ec8e7 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,16 @@ "index.js" ], "scripts": { + "build": "npm run print-config:file", + "lint": "eslint . --max-warnings=0", "lint:fix": "eslint . --fix", + "lint:verbose": "eslint --max-warnings=0 -f stylish .", "prettier:fix": "prettier . --write", "print-config": "eslint --print-config .eslintrc.js", + "print-config:file": "eslint --print-config .eslintrc.js > config.json", "semantic-release": "semantic-release", - "test": "prettier . --check && eslint ." + "test": "prettier . --check && eslint .", + "tsc": "tsc" }, "dependencies": { "@typescript-eslint/eslint-plugin": "^4.33.0", diff --git a/sandbox.ts b/sandbox.ts new file mode 100644 index 0000000..f65b188 --- /dev/null +++ b/sandbox.ts @@ -0,0 +1,16 @@ +// A dummy files to test manually rules + +// eslint-disable-next-line no-console +console.log("hello"); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +const empty = 1; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +let dummy: any; + +// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types +export const getDummy = (param: unknown) => { + // eslint-disable-next-line no-console + console.log(`${dummy} and ${param}`); +}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..54ef2bc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "jsx": "react", + "module": "commonjs", + "moduleResolution": "node", + "noEmit": true, + "strict": true, + "sourceMap": true, + "target": "es6", + "lib": ["es6", "dom", "esnext"], + "baseUrl": ".", + "paths": { + "*": ["node_modules/@types/*", "*"] + }, + //not part of strict, but not ready for it + //"noImplicitReturns": true, + //"noUnusedParameters": true, + //help on integration tests + "forceConsistentCasingInFileNames": true, + "allowJs": true, + "checkJs": true, + // for other js/json files + "resolveJsonModule": true, + "esModuleInterop": true, + // decorators, e.g. for tsoa + "experimentalDecorators": true + }, + "exclude": ["node_modules", "tmp"] +}