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

Add eslint #7

Closed
jaredpalmer opened this issue Jan 26, 2019 · 8 comments
Closed

Add eslint #7

jaredpalmer opened this issue Jan 26, 2019 · 8 comments
Labels
kind: feature New feature or request

Comments

@jaredpalmer
Copy link
Owner

No description provided.

@diegohaz
Copy link
Contributor

Why not eslint? Even TS is migrating to it: microsoft/TypeScript#30553

@jaredpalmer
Copy link
Owner Author

Yeah made issue before the announcement

@swyxio swyxio changed the title Add tslint Add eslint Apr 30, 2019
@bbugh
Copy link
Contributor

bbugh commented Jul 24, 2019

I just started using tsdx and found the lack of linting surprising!

I've added linting with @typescript-eslint with prettier integrated, using lint-staged with husky for running on staged files, and it's worked out very well.

Does that sound useful for a patch?

@swyxio
Copy link
Collaborator

swyxio commented Jul 24, 2019

we have a tsdx lint command that is a bit stale - #99 i havent been involved with the discussion tho and am not sure what @jaredpalmer's plan is here

@bbugh
Copy link
Contributor

bbugh commented Aug 27, 2019

@jaredpalmer @skvale #99 was shipped, thank you! 🌟 But there are some issues with it...

  1. Even if the "basic" template is selected, the react-app package is added to the .eslintrc.js file when the yarn lint --write-file command is run:

    module.exports = {
      "extends": [
        "react-app",
        "prettier/@typescript-eslint",
        "plugin:prettier/recommended"
      ]
    }
  2. Another react issue, when running yarn lint src (or any path), eslint prints:

    Warning: React version was set to "detect" in eslint-plugin-react settings, but the "react" package is not installed. Assuming latest React version for linting.

  3. husky is still only running prettier, not the eslint + prettier package. This should call the new lint command. (This would also eliminate the need to include prettier and prettier-quick in the library's own devDependencies)

  4. yarn lint without files incorrectly reports success ✨ Done in 2.20s.. When running eslint or prettier without any inputs, it returns the help and in prettier's case, an error code 1. The lint should not fail silently, because that's the same result as a success. If no files are specified, I think it should follow the standard CLI behavior and print the help message.

Thanks for reading!

@jaredpalmer
Copy link
Owner Author

Can you submit a PR with these changes?

@bbugh
Copy link
Contributor

bbugh commented Aug 28, 2019

Sure thing. I pushed #189 to fix 3 and 4. 1 and 2 require some extra attention.

  1. I'm not sure how best to handle this issue, as the lint command doesn't know if the template was basic or react. I was thinking either: 1) changing the write-files flag from boolean to string, so you'd do --write-files basic or --write-files react, or 2) checking package.json for the react dependency. Any preference or other ideas?
  2. There's no way to suppress the ESLint React warning - it was requested and rejected. If eslint-plugin-react has detect turned on, it will warn. Is there a silent version of "detect" ? jsx-eslint/eslint-plugin-react#2276 Not sure how to address this, as it seems internal to tsdx. Removing the react line from the project's .eslintrc.js file doesn't disable the eslint react rules.
  3. This is fixed by Fix lint command usage by husky and required files #189
  4. This is fixed by Fix lint command usage by husky and required files #189

jaredpalmer pushed a commit that referenced this issue Sep 2, 2019
- Fixes the husky pre-commit hook not using the `tsdx lint` command
- Fixes `tsdx lint` without any input files failing with a help message instead of silently appearing to succeed.

Related to #7
@agilgur5 agilgur5 added the kind: feature New feature or request label Sep 6, 2020
@robphoenix
Copy link

In a basic tsdx project, to deal with 1. @bbugh mentioned

Even if the "basic" template is selected, the react-app package is added to the .eslintrc.js file when the yarn lint --write-file command is run:

we have to directly call eslint rather than tsdx lint, in package.json:

"lint": "eslint --fix \"./src/**/*.ts\""

Is there a way to override/ignore the tsdx eslint config? Or document this as a recommended option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants