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

fix(eslint-plugin): handle DoBootstrap correctly in lifecycle rules #243

Merged
merged 13 commits into from
Jan 11, 2021

Conversation

rafaelss95
Copy link
Member

@rafaelss95 rafaelss95 commented Dec 20, 2020

This:

  • Handles DoBootstrap/ngDoBootstrap for all 4 lifecycle rules correctly now;
  • no-empty-lifecycle-method handles all decorators. Before it was caring only about Component and Directive;
  • no-empty-lifecycle -method now ignores non-angular classes;
  • use-lifecycle-interface now ignores non-angular classes.

@rafaelss95 rafaelss95 changed the title fix(eslint-plugin): contextual-lifecycle doesn't handle DoBootstrap fix(eslint-plugin): handle DoBootstrap correctly in lifecycle rules Dec 20, 2020
@rafaelss95 rafaelss95 force-pushed the fix/contextual-lifecycle branch 2 times, most recently from 559c7a5 to e0ddc05 Compare December 20, 2020 21:41
@rafaelss95
Copy link
Member Author

Btw, while I was implementing this I noticed a strange behavior and reported in #246. I'll fix it after this PR gets merged.

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you work on reducing the noise in this PR, there seem to be a lot of changed unit tests for no obvious reason or benefit? E.g. whitespacing, ordering etc

It's currently hard to judge the overall impact of the changes in this PR

@rafaelss95
Copy link
Member Author

rafaelss95 commented Dec 22, 2020

Hey @JamesHenry I agree that there are a lot of noise and the reason for this is that there are really really amount of tests unneeded.

For example, in no-empty-lifecycle and no-lifecycle-call we have 300+ and 700+ respectively lines of tests and I do believe that most of these are really unnecessary as we are interested in lifecycle calls/empty lifecycle methods, not in a specific decorator context (I believe that was an bad-copy from contextual-lifecycle — where it does makes sense).

In a nutshell, I was trying to rework the tests in this specific PR (you can notice by the amount of deletion), but it's surely a bad idea. I'll try to reduce the amount of changes in tests to just cover the DoBootstrap hook and try to submit another one restructuring the tests. WDYT?

@JamesHenry
Copy link
Member

That would be perfect, thanks @rafaelss95

@rafaelss95 rafaelss95 force-pushed the fix/contextual-lifecycle branch 3 times, most recently from a243007 to 4301093 Compare December 23, 2020 04:16
@@ -134,7 +140,7 @@ ruleTester.run(RULE_NAME, rule, {
@Component()
class Test {
ngAfterContentChecked() { }
~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was the reason for this change in reporting style?

In other rules we tend to go for the method name I think (e.g. even in this same PR you have a mixture)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the confusion. Everything should be fine now.

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legitimate integration tests failures to fix

Also please do not force push on an open PR that is already in review - it forces the reviewer to have to start from scratch instead of seeing what changes over time in a PR.

You can achieve everything with merge commits and the history is maintained, unlike with rebasing. Plus the commit history is all squashed and cleaned up on merge to master anyway.

Rebasing is an awesome tool, but should only be used before a PR is already in review IMO.

@rafaelss95
Copy link
Member Author

rafaelss95 commented Jan 4, 2021

Legitimate integration tests failures to fix

I don't know if it's my setup or what, but as in #260 (comment), I'm unable to run the command successfully. It always output a blank snap file and after try to ng lint manually, as you suggested, I got this error:

[error] Error: Failed to load plugin '@angular-eslint' declared in '.eslintrc.json#overrides[0]': Cannot find module '/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@angular-eslint/eslint-plugin/dist/index.js'. Please verify that the package.json has a valid "main" entry
Require stack:
- /Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/__placeholder__.js
Referenced from: /Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/.eslintrc.json
    at tryPackage (node:internal/modules/cjs/loader:338:19)
    at Function.Module._findPath (node:internal/modules/cjs/loader:551:18)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:905:27)
    at Function.resolve (node:internal/modules/cjs/helpers:98:19)
    at Object.resolve (/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js:28:50)
    at ConfigArrayFactory._loadPlugin (/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@eslint/eslintrc/lib/config-array-factory.js:1011:39)
    at ConfigArrayFactory._loadExtendedPluginConfig (/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@eslint/eslintrc/lib/config-array-factory.js:831:29)
    at ConfigArrayFactory._loadExtends (/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@eslint/eslintrc/lib/config-array-factory.js:778:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/node_modules/@eslint/eslintrc/lib/config-array-factory.js:719:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)

PS: I removed node_modules, installed everything again, run yarn build + yarn integration-tests and I still got this error.

@JamesHenry
Copy link
Member

@rafaelss95 Sorry, that's strange... Not sure what to suggest. Glad you were able to work around it on this one, if it happens again I'll try pulling down the branch and see if I can reproduce

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.

None yet

2 participants