-
-
Notifications
You must be signed in to change notification settings - Fork 243
feat(schematics): new convert-tslint-to-eslint schematic #173
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
Conversation
], | ||
"@typescript-eslint/consistent-type-assertions": "error", | ||
"@typescript-eslint/dot-notation": "error", | ||
"@typescript-eslint/member-delimiter-style": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
member-delimiter-style
is covered by Prettier, I think, as well as a few others -- e.g. space-before-function-paren
. Is that intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial work is about being as close to what the Angular CLI ships OOTB today. The Angular CLI does not use prettier.
For sure I would encourage anyone I speak to personally to use prettier, and I will also trend this config away from stylistic rules completely over time, but for now parity is the main objective
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshuaKGoldberg FYI in a follow up PR I have increased the clarity around compatibility with Angular CLI's TSLint setup vs "recommended" and also split out formatting related rules into their own named config (and added in a note in the manual config example I have in the integration tests):
angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/.eslintrc.json
Line 47 in 456c166
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on", |
packages/schematics/src/convert-tslint-to-eslint/convert-to-eslint-config.ts
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #173 +/- ##
===========================================
- Coverage 91.58% 60.56% -31.02%
===========================================
Files 50 8 -42
Lines 1141 317 -824
Branches 214 50 -164
===========================================
- Hits 1045 192 -853
- Misses 54 104 +50
+ Partials 42 21 -21
|
The next two priorities on this (in order) are:
|
For the inline comment conversion: typescript-eslint/tslint-to-eslint-config#820 -> typescript-eslint/tslint-to-eslint-config#821. |
Thanks a lot for this! I just tested with v0.7.0-alpha.12, and here is some feedback as requested. What works:
What doesn't work:
|
After checking my last point, it's more complicated than I thought: Angular TSLint configuration was indeed reporting errors on |
3dece37
to
6079eb8
Compare
Naturally you will have to provide more information about your setup than this, or it cannot be looked into. The integration-tests (because they are full Angular CLI workspaces) also provide a great resource for you to create a reproduction of the issue yourself, which will be most time efficient. Regarding the editor behaviour, thank you for bringing that to my attention, I was not aware of that having not really used the TSLint extension in VSCode. I will take a look into the experience so that I can better understand where folks are coming from. |
So after some investigation, it works on a newly generated Angular CLI app, but not on an existing app I have. I didn't manage to find what is the issue, because I checked the config was exactly the same between the 2 projects (same Both apps are configured with inline templates. My general config: Mac (last v10 yesterday and now v11), Node 14.15.0, all project dependencies totally up to date. However, I was able to fix the issue by changing I suppose you choose |
Thanks a lot for looking into it more - one really useful thing you can do when investigating this is invoke the command with E.g. DEBUG=typescript-eslint:* npx ng lint You will then see what typescript-eslint is doing for each file (which programs are being built and looked up etc) |
76cb32f
to
e0bcf13
Compare
I confirm with the debug command the issue is because of 2 solutions work:
|
Cool, thanks this has been really useful. For now, I'm just going to create a line in the sand at Angular CLI 10.1 and just say that is where support in this toolset currently starts. The schematics will now throw if they see you are using the ill-fated I have adjusted the logic to only look at the @cyrilletuzi Please could you try the same project and operations with |
This is great, thank you! I just went through the process so hopefully this feedback is useful. A few minor issues I found upgrading an existing project:
And one question I had at the end:
|
@textbook thanks for providing some feedback. Is there a reason why you are deviating from the standard Angular CLI structure and file layout? Are you not running ng update to automatically keep yourself in sync with the latest? It looks like you might just be patching versions manually (eg on v11) which is not recommended. All of your issues seem to be arising for this reason, and I don’t think it’s going to be possible to support these kinds of customisations... |
I have been using It wasn't super difficult to figure out what was going on and fix it anyway. Might be worth showing |
alpha.17 test: Working:
Doesn't work:
The right solution would be to detect the
|
Even better solution: each project in |
Thanks folks! @textbook - wow that's a long journey for that project! It wouldn't surprise me if the tooling let you down at some point, ng update was a little shaky at first. You can see what brand new (but v10 because done before 2 days ago) Angular CLI workspaces look like in the integration-test fixtures and how they differ in layout to your project. @cyrilletuzi good call out, I am adding coverage for libraries. Can you please clarify what you mean by spec not being good for performance? Without spec you will not have a program available for linting your spec files, which means when you do run lint the createDefaultProgram logic has to kick in, which is really not good for performance. We need to include spec in the patterns in all cases to cover all .ts files
Again this is correctly describing doing less but it therefore isn't doing enough - we can't just set the source code files up for linting, we need to set all relevant files up |
With |
@JamesHenry You're right, without However, the glob expression is also catching |
Ok ha I should have tested the .prod. one - I was lazily just hoping it wouldn't catch it. I'll make it an explicit lib and spec |
And a fixed |
Yeah sounds good, I'll make everything explicit |
Published |
Migration is working well with alpha.14, thanks a lot @JamesHenry! Now that configuration is OK, I would like to discuss another topic: while all my projets were passing lint, after the migration, there are a lot of lint errors (and it's just small projects). It means that the default rules of I've identified several causes:
I think an important discussion should happen here, on multiple topics:
I have my own opinion, but I'm not sure if you want to discuss about that here or in another issue. While technically it can be separated, for your own sake, I really think you should not ship the migration schematics before this topics are resolved, otherwise the repo will for sure be overwhelmed by issues. |
Hmm this is surprising because as of this PR, @angular-eslint/recommended is entirely based on the converted OOTB tslint.json from the Angular CLI. Please could you provide the tslint.json you are referring to and what ESLint you are ending up with? It is also not expected that max-len would apply in templates based on the recommended config from the template plugin, so again something seems to be misconfigured there vs what is intended by the toolset... |
There's a lot of important work in this PR so I'm merging it now and turning it into We can make further improvements and tweaks in follow up PRs |
This PR adds the long awaited
convert-tslint-to-eslint
schematic for automatically converting an Angular CLI project from using TSLint to using an ESLint setup which most closely mirrors it.This PR contains breaking changes around the recommended config from
@angular-eslint/eslint-plugin
to bring it more inline with what the latest Angular CLI generates out of the box. It is therefore going to become thev0.7.0-beta.0
release when it is complete.For now, the work on this PR is being published to the
next
tag on npm and usingalpha
as the suffix to differentiate it from the betas onlatest
.To use this code today (you can find the value for
{{YOUR_PROJECT_NAME}}
in yourangular.json
):ng add @angular-eslint/schematics@next npx ng g @angular-eslint/schematics:convert-tslint-to-eslint --project {{YOUR_PROJECT_NAME}} # This is now powered by ESLint! Check out your new root level .eslintrc.json config that the schematic created npx ng lint
Real-world feedback wanted
Please, please, please use this on your single-project Angular CLI workspaces today and report any issues or rough edges you may encounter 🙏 This is just static analysis tooling after all, there is no risk to your users by you trying this out. If things don't look or function quite right you can also just not commit the changes that the schematic makes!
We are never going to be able to make something which handles every case, but we are already at a point where things are looking pretty good for the common case!
PS Thank you to @JoshuaKGoldberg for his openness to collaboration and to making the necessary changes to
tslint-to-eslint-config
to make it useable in the schematic context