Skip to content

Commit

Permalink
frontend: changed to eslint, removed deprecated tslint
Browse files Browse the repository at this point in the history
Removed tslint and configure eslint to lint js and ts files.
Added typescript-eslint and eslint react  modules and updated
eslint to latest, and a newer preact patch version.

Copied all rules from eslint-config-synacor and removed the
dependency, (wasnt updated in a year). The eslint rules now
contain the synacor merged with our own rules, marked with Shift.

Disabled all rules that warned or errored, so we can enable those
one by one in separate pull requests.
  • Loading branch information
thisconnect committed Oct 1, 2020
1 parent 0eff8c1 commit 3a1b71e
Show file tree
Hide file tree
Showing 5 changed files with 851 additions and 534 deletions.
25 changes: 0 additions & 25 deletions frontends/web/.eslintrc

This file was deleted.

214 changes: 214 additions & 0 deletions frontends/web/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
module.exports = {
"env": {
"browser": true
},
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaVersion": "8",
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
},
"project": require.resolve("./tsconfig.json"),
},
"settings": {
"react": {
"pragma": "h",
"version": "16"
},
},
"ignorePatterns": [
"*.css.d.ts"
],
"rules": {
"react/display-name": [2, { ignoreTranspilerName: false }],
// "react/jsx-equals-spacing": 2,
"react/jsx-equals-spacing": "off",
"react/jsx-no-comment-textnodes": 2,
"react/jsx-no-duplicate-props": 2,
// "react/jsx-no-target-blank": 2,
"react/jsx-no-target-blank": "off",
"react/jsx-no-undef": 2,
"react/jsx-pascal-case": 2,
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
// "react/jsx-wrap-multilines": 2,
"react/jsx-wrap-multilines": "off",
"react/no-danger": 2,
// "react/no-did-mount-set-state": 2,
"react/no-did-mount-set-state": "off",
// "react/no-did-update-set-state": 2,
"react/no-did-update-set-state": "off",
"react/no-find-dom-node": 2,
"react/no-is-mounted": 2,
"react/no-string-refs": 0,
"react/prefer-es6-class": 2,
// "react/prefer-stateless-function": 1,
"react/prefer-stateless-function": "off",
"react/require-render-return": 2,

"no-eval": 2,
"no-implied-eval": 2,
"no-new-func": 2,

"arrow-parens": [0, "always"],
"arrow-spacing": 2,
camelcase: [1, { properties: "never" }],
"comma-style": [2, "last"],
"constructor-super": 2,
curly: [0, "multi-line"],
"dot-notation": [2, { allowPattern: "^[a-z]+(_[a-z]+)+$" }],
eqeqeq: 2,
"func-style": [2, "declaration", { allowArrowFunctions: true }],
"guard-for-in": 2,
"handle-callback-err": 0,
"jsx-quotes": [2, "prefer-double"],
// "key-spacing": 2,
"key-spacing": "off",
"keyword-spacing": 2,
// "lines-around-comment": 2,
"lines-around-comment": "off",
"new-cap": 1,
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-cond-assign": 2,
// "no-console": [1, { allow: ["warn", "error"] }],
"no-console": "off",
"no-const-assign": 2,
"no-delete-var": 2,
"no-dupe-class-members": 2,
"no-dupe-keys": 2,
// "no-duplicate-imports": 2,
"no-duplicate-imports": "off",
// "no-else-return": 2,
"no-else-return": "off",
"no-empty-pattern": 0,
"no-empty": 0,
"no-extra-parens": 0, // we use extra parens in JSX ternaries, no way to disable that here.
"no-iterator": 2,
// "no-lonely-if": 2,
"no-lonely-if": "off",
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-multi-str": 2,
"no-multiple-empty-lines": [2, { max: 2 }],
"no-new-wrappers": 2,
"no-proto": 2,
"no-redeclare": 2,
"no-restricted-globals": [2, "find", "Text"],
"no-shadow-restricted-names": 2,
"no-shadow": 0,
"no-spaced-func": 2,
"no-this-before-super": 2,
"no-trailing-spaces": [2, { skipBlankLines: true }],
"no-undef-init": 2,
"no-unneeded-ternary": 2,
"no-unused-vars": [2, { args: "none", varsIgnorePattern: "^h$" }],
"no-useless-call": 2,
"no-useless-computed-key": 2,
"no-useless-concat": 2,
// "no-useless-constructor": 2,
"no-useless-constructor": "off",
"no-useless-escape": 2,
"no-useless-rename": 2,
"no-var": 2,
"no-with": 2,
"object-shorthand": 2,
"prefer-arrow-callback": 2,
"prefer-rest-params": 2,
"prefer-spread": 2,
"prefer-template": 0, // we can enable this when they add an option to allow concat for complex variables
// "quote-props": [2, "as-needed"],
"quote-props": "off",
radix: 2,
"rest-spread-spacing": 2,
semi: 2,
"space-before-function-paren": [0, "always"], // for fmt
"space-in-parens": [0, "never"],
strict: [2, "never"],
"unicode-bom": 2,
"valid-jsdoc": [0, { requireReturn: false }], // no way to turn this off for pure functional component

// Shift
"no-alert": "off",
"arrow-body-style": [0, "as-needed"],
// brace-style": [1, "1tbs"],
"brace-style": "off",
"comma-dangle": 0,
// "indent": ["warn", 4, {
// "SwitchCase": 1
// }],
"indent": "off",
"quotes": ["warn", "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}],
"quote-props": ["warn", "as-needed"],
"react/self-closing-comp": 0,
"react/jsx-curly-spacing": 0,
// "react/jsx-indent-props": ["warn", 4],
"react/jsx-indent-props": "off",
"react/sort-comp": 0,
"react/jsx-boolean-value": 0,
"react/jsx-closing-bracket-location": 0,
// "react/jsx-max-props-per-line": ["warn", { "maximum": 5, "when": "always" }],
"react/jsx-max-props-per-line": "off",
// "react/jsx-tag-spacing": ["warn"],
"react/jsx-tag-spacing": "off",
"react/jsx-no-bind": "off",
// "react/jsx-key": ["error"],
"react/jsx-key": "off",
"@typescript-eslint/no-empty-interface": "off",

"object-curly-spacing": "off",

// TODO: enable again
"no-undef": "off",
"react/no-unknown-property": "off",
"react/no-children-prop": "off",

// TODO: enable again
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/no-inferrable-types": "off"

},
overrides: [
{
files: ["*.jsx"],
rules: {
// keep
"react/prop-types": "off"
}
}, {
files: ["*.ts", "*.tsx"],
rules: {
"quote-props": "off",
// TODO: remvoe
"react/prop-types": "off"
}
}
]
};
26 changes: 11 additions & 15 deletions frontends/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,39 @@
"gen-ts-css": "tcm src --camelCase dashes",
"build": "yarn run gen-ts-css && preact build --no-sw --no-esm --no-inline-css --no-prerender --verbose",
"dev": "yarn run gen-ts-css && preact watch",
"lint": "yarn run gen-ts-css && eslint --max-warnings 0 --cache --ignore-path ../../.gitignore '**/*.{js,jsx}'",
"postlint": "yarn run gen-ts-css && tslint -e 'src/**/*.css.d.ts' 'src/**/*.ts?(x)'",
"prelint": "yarn run gen-ts-css",
"lint": "eslint --max-warnings 0 --cache --format unix --ignore-path ../../.gitignore 'src/**/*.{js,jsx,ts,tsx}'",
"fix": "eslint --fix --no-cache --ignore-path ../../.gitignore 'src/**/*.{js,jsx,ts,tsx}'",
"test": "yarn run gen-ts-css && jest",
"browserlist": "browserslist"
},
"eslintConfig": {
"extends": "eslint-config-synacor"
},
"eslintIgnore": [
"build/*"
],
"devDependencies": {
"@types/jest": "23.3.10",
"eslint": "5.1.0",
"eslint-config-synacor": "3.0.1",
"@typescript-eslint/eslint-plugin": "4.2.0",
"@typescript-eslint/parser": "4.2.0",
"eslint": "7.10.0",
"eslint-plugin-react": "7.21.2",
"identity-obj-proxy": "3.0.0",
"if-env": "1.0.4",
"jest": "23.6.0",
"preact-cli": "3.0.1",
"preact-cli-plugin-env-vars": "^1.2.1",
"preact-render-spy": "1.3.0",
"ts-jest": "23.10.5",
"tslint": "5.11.0",
"typed-css-modules": "0.3.5"
},
"dependencies": {
"@zxing/library": "0.11.0",
"i18next": "11.3.6",
"i18next-locize-backend": "1.6.0",
"lightweight-charts": "3.1.5",
"linkstate": "1.1.1",
"locize-editor": "1.7.0",
"preact": "8.5.2",
"preact-compat": "3.18.0",
"preact": "8.5.3",
"preact-compat": "3.19.0",
"preact-router": "2.6.1",
"react-i18next": "7.9.0",
"sortablejs": "^1.10.1",
"lightweight-charts": "3.1.5"
"sortablejs": "^1.10.1"
},
"browserslist": [
"last 2 Chrome versions"
Expand Down
4 changes: 2 additions & 2 deletions frontends/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"noUnusedParameters": true,
},
"include": [
"src/**/*",
],
"src/**/*"
]
}

0 comments on commit 3a1b71e

Please sign in to comment.