Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[change] Migrate tslint to eslint #396

Closed
wants to merge 6 commits into from

Conversation

peaceiris
Copy link
Contributor

@peaceiris
Copy link
Contributor Author

@nwtgck

The Node CI / build (8.x) failed due to eslint no longer support Node.js 8. I'm waiting for your opinion.

IMO: It is time to drop Node.js v8 and add v14.

cf. Node.js 8 is no longer supported | Migrating to v7.0.0 - ESLint - Pluggable JavaScript linter

@nwtgck
Copy link
Owner

nwtgck commented Oct 13, 2020

@peaceiris
What kind of tool did you use to write .eslintrc.json? Or you wrote by yourself?

@peaceiris
Copy link
Contributor Author

By myself. I referred to my project setting: actions-gh-pages/.eslintrc.json at main · peaceiris/actions-gh-pages

Since I am using jest as a testing library in the project, I do not know my changes are suitable for mocha.

@nwtgck
Copy link
Owner

nwtgck commented Oct 13, 2020

Thanks. I'd like to preserve the original tslint.json setting as possible and migrate to eslint.
I'll drop Node.js 8 and add v14.

@nwtgck
Copy link
Owner

nwtgck commented Oct 13, 2020

Run npm run lintin CI for Windows and drop Node.js 8 and add 14.

edit: I'm not sure that Windows recognize ./{src,test}/**/*.ts, so I added npm run lint in CI for Windows.

@nwtgck
Copy link
Owner

nwtgck commented Oct 13, 2020

In my opinion, a favor setting of lint-related technology highly depends on a project author. It might be better to write the author or use auto-migrating from TSLint to ESLint programmatically such as tslint-to-eslint-config. But I'm not sure whether tslint-to-eslint-config became matured or not.

@peaceiris
Copy link
Contributor Author

peaceiris commented Oct 14, 2020

My changes just follow the recommendation: https://github.com/typescript-eslint/typescript-eslint/blob/c41dbe56e0514846e4d21fc5fcd8847da50e92c6/docs/getting-started/linting/README.md

If you want to use any migration tool, tell me. I will close this.

Also, I tried tslint-to-eslint-config.

$ git checkout develop
$ npm ci
$ npx tslint-to-eslint-config --comments
$ cat .eslintrc.js | wc -l
163
👉 Click to expand .eslintrc.js
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config

It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.

We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint. 
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md

Happy linting! 💖
*/
module.exports = {
    "env": {
        "es6": true,
        "node": true
    },
    "extends": [
        "plugin:@typescript-eslint/recommended",
        "plugin:@typescript-eslint/recommended-requiring-type-checking"
    ],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "project": "tsconfig.json",
        "sourceType": "module"
    },
    "plugins": [
        "eslint-plugin-jsdoc",
        "eslint-plugin-prefer-arrow",
        "@typescript-eslint"
    ],
    "rules": {
        "@typescript-eslint/adjacent-overload-signatures": "error",
        "@typescript-eslint/array-type": [
            "error",
            {
                "default": "array"
            }
        ],
        "@typescript-eslint/ban-types": [
            "error",
            {
                "types": {
                    "Object": {
                        "message": "Avoid using the `Object` type. Did you mean `object`?"
                    },
                    "Function": {
                        "message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
                    },
                    "Boolean": {
                        "message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
                    },
                    "Number": {
                        "message": "Avoid using the `Number` type. Did you mean `number`?"
                    },
                    "String": {
                        "message": "Avoid using the `String` type. Did you mean `string`?"
                    },
                    "Symbol": {
                        "message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
                    }
                }
            }
        ],
        "@typescript-eslint/consistent-type-assertions": "error",
        "@typescript-eslint/consistent-type-definitions": "off",
        "@typescript-eslint/dot-notation": "error",
        "@typescript-eslint/naming-convention": "error",
        "@typescript-eslint/no-empty-function": "error",
        "@typescript-eslint/no-empty-interface": "error",
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/no-misused-new": "error",
        "@typescript-eslint/no-namespace": "error",
        "@typescript-eslint/no-parameter-properties": "off",
        "@typescript-eslint/no-unused-expressions": "error",
        "@typescript-eslint/no-use-before-define": "off",
        "@typescript-eslint/no-var-requires": "error",
        "@typescript-eslint/prefer-for-of": "error",
        "@typescript-eslint/prefer-function-type": "error",
        "@typescript-eslint/prefer-namespace-keyword": "error",
        "@typescript-eslint/triple-slash-reference": [
            "error",
            {
                "path": "always",
                "types": "prefer-import",
                "lib": "always"
            }
        ],
        "@typescript-eslint/unified-signatures": "error",
        "comma-dangle": "error",
        "complexity": "off",
        "constructor-super": "error",
        "eqeqeq": [
            "error",
            "always"
        ],
        "guard-for-in": "error",
        "id-blacklist": [
            "error",
            "any",
            "Number",
            "number",
            "String",
            "string",
            "Boolean",
            "boolean",
            "Undefined",
            "undefined"
        ],
        "id-match": "error",
        "jsdoc/check-alignment": "error",
        "jsdoc/check-indentation": "error",
        "jsdoc/newline-after-description": "error",
        "max-classes-per-file": [
            "error",
            1
        ],
        "new-parens": "error",
        "no-bitwise": "error",
        "no-caller": "error",
        "no-cond-assign": "error",
        "no-console": "error",
        "no-debugger": "error",
        "no-empty": "error",
        "no-eval": "error",
        "no-fallthrough": "off",
        "no-invalid-this": "off",
        "no-new-wrappers": "error",
        "no-shadow": [
            "error",
            {
                "hoist": "all"
            }
        ],
        "no-throw-literal": "error",
        "no-trailing-spaces": "error",
        "no-undef-init": "error",
        "no-underscore-dangle": "error",
        "no-unsafe-finally": "error",
        "no-unused-labels": "error",
        "no-var": "error",
        "object-shorthand": "off",
        "one-var": [
            "error",
            "never"
        ],
        "prefer-arrow/prefer-arrow-functions": "error",
        "prefer-const": "error",
        "radix": "error",
        "spaced-comment": [
            "error",
            "always",
            {
                "markers": [
                    "/"
                ]
            }
        ],
        "use-isnan": "error",
        "valid-typeof": "off"
    }
};

@peaceiris
Copy link
Contributor Author

edit: I'm not sure that Windows recognize ./{src,test}/**/*.ts, so I added npm run lint in CI for Windows.

It works well.
https://github.com/peaceiris/actions-gh-pages/runs/1251360281#step:11:15

@nwtgck
Copy link
Owner

nwtgck commented Oct 17, 2020

Thanks. Auto-generated config file should be long, but I can adjust it. I'll try to generate automatically by tslint-to-eslint-config and consider.

@peaceiris peaceiris closed this Oct 17, 2020
@peaceiris peaceiris deleted the migrate-tslint-to-eslint branch October 17, 2020 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate TSLint to ESLint
2 participants