-
-
Notifications
You must be signed in to change notification settings - Fork 217
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
feat(eslint-plugin): add fixer for use-pipe-transform-interface #260
feat(eslint-plugin): add fixer for use-pipe-transform-interface #260
Conversation
bfb2ec7
to
c5e5ffd
Compare
if (!importDeclaration?.specifiers.length) { | ||
return fixer.insertTextAfterRange( | ||
[0, 0], | ||
`import { ${PIPE_TRANSFORM} } from '${ANGULAR_CORE_MODULE_PATH}';\n`, | ||
); | ||
} |
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.
This case should not happen as in a pipe file you may already have the import from @angular/core
, however I prefer to let it here to avoid something strange.
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.
Nice work!
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.
Nice work! This changes the output of the integration tests, so the snapshots will need to be updated.
You can just run the integration tests with -u
set for jest and then review the changes before committing
Hello @JamesHenry, sorry to ask here, but do you still have access to the email address james@nrwl.io? If not, could you give me your new email address? I'm trying to contact you there, thanks. |
@rafaelss95 No problem, please could you use james@henry.sc instead? |
I ran
Could you point out to me what I'm missing? |
2ba8b6f
to
261fcd9
Compare
261fcd9
to
519e1ef
Compare
Sorry for the amended commits, I messed up with the rebase. |
Hmm I have never used npm 7, possibly that? Can you try using yarn as that is what the workspace uses in CI You did a full install and build of the monorepo before running right? |
@@ -1,45 +1,106 @@ | |||
import { TSESTree } from '@typescript-eslint/experimental-utils'; | |||
import { RuleFixer } from '@typescript-eslint/experimental-utils/dist/ts-eslint'; |
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.
@JamesHenry Could we have RuleFixer
exported directly from the main entry point? This deep import just doesn't feels good for me.
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.
Yeah, very true, please could you open an issue on typescript-eslint, and add a TODO comment referencing it so we don't forget in future?
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.
I created the issue typescript-eslint/typescript-eslint#2931 and put a comment here, take a look please.
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.
I've seen Brad's response, shows how rusty I am :) Please can we update this accordingly
@rafaelss95 Ah no, just the snapshot updates - the other parts of the diff are just the results of the integration tests doing their thing and should not be committed |
Linting \\"robot-websites\\"... | ||
All files pass linting. | ||
" | ||
Linting \\"v1014-multi-project-manual-config\\"..." |
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.
This snapshot is clearly broken, you can debug by cd'ing into the relevant workspace in the integration-tests package fixtures and running normal ng lint
commands
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.
I did and I discovered that the problem is that the ng lint
is not running for this folder (v1014-multi-project-manual-config). When I try to run it, I get the following error:
[error] Error: Failed to load plugin '@angular-eslint' declared in '.eslintrc.json#overrides[0]': Cannot find module '/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:
- /PATH/angular-eslint/packages/integration-tests/fixtures/v1014-multi-project-manual-config/__placeholder__.js
Referenced from: /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 (/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 (/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 (/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 (/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 (/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>)
I also noticed that this happens only for this fixture, the others ran normally.
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.
@JamesHenry I would appreciate your help on this to move forward with this PR, thanks.
@@ -90,15 +90,15 @@ Object { | |||
"@angular-eslint/component-selector": Array [ | |||
"error", | |||
Object { | |||
"prefix": "customprefix", | |||
"prefix": "app", |
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.
These prefixes should not have been changed
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.
Idk why it has changed, but after revert everything and do a fresh build/run, it didn't change anymore.
@@ -149,15 +149,15 @@ Object { | |||
"@angular-eslint/component-selector": Array [ | |||
"error", | |||
Object { | |||
"prefix": "customprefix", | |||
"prefix": "app", |
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.
These prefixes should not have been changed
570c8a5
to
ef60817
Compare
6:35 error Invalid binding syntax. Use [(expr)] instead @angular-eslint/template/banana-in-box | ||
14:48 error Invalid binding syntax. Use [(expr)] instead @angular-eslint/template/banana-in-box | ||
4:13 error Strings must use singlequote @typescript-eslint/quotes | ||
9:14 error Pipes should implement PipeTransform interface @angular-eslint/use-pipe-transform-interface |
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.
Hmm, please make sure you actually verify all these changes, it is a red flag that adding a fixer would cause so many changes to the integration-tests and I think most of them are regressions.
The source of this file I have commented on (multiple-inline-templates.page.ts
) is:
import { Component } from '@angular/core';
@Component({
selector: "app-one-inline-template",
template: `
<input type="text" name="foo" ([ngModel])="foo">
`,
})
export class OneInlineTemplateComponent {}
@Component({
selector: "app-two-inline-template",
template: `
<div [oneWay]="oneWay" (emitter)="emitter" ([twoWay])="twoWay"></div>
`,
})
export class TwoInlineTemplateComponent {}
The use-pipe-transform-interface
rule should not be erroring for that source, right?
I believe this is the case for a number of these changes
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.
Ups, it should be fine now.
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.
Thanks a lot!
No description provided.