-
Notifications
You must be signed in to change notification settings - Fork 12k
Newly created project cannot lint environment.prod.ts file #17382
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
Comments
Discussed in the CLI meeting and this is a bit of a tricky one, as replacement files aren't really a part of any TypeScript compilation. For users experiencing this problem today, I think the workaround would be to include any file replacements in The best real solution we identified is to add a migration in a major version which takes all the file replacements in It does require a user to add a change in two places instead of one. Ideally, we would have some kind of automatic fixer when this warning is triggered, but I don't think we have infra to support that at the moment. One concern here is that we're somewhat arbitrarily choosing to add to @mgechev, how does this change with ESLint going forward? Does ESLint require its files to be part of a TypeScript compilation? Is it worth adding a migration in the next major version just to undo it in a subsequent version when we switch to ESLint? |
@dgp1130 |
Had some additional discussion on the CLI team this week as this issue gets quite tricky. Fundamentally, all dependent types are needed to lint a particular file (because many lint checks are type-aware). If a file is missing from the compilation, then those dependencies cannot be resolved intelligently and we can't effectively lint that file. This also means that ESLint won't help us here because it will suffer the same problem. There are three specific challenges which are addressed in this particular issue:
Unused files cannot be lintedThis is actually a TypeScript problem moreso than an Angular one. TSLint provides no means of linting files not in the project due to the aforementioned typing issues. If you create a non-Angular project with an unused file not include in
File replacements cannot be lintedWe previously suggested using a migration to include file replacements in Instead, the warning on its own may be the best for now. This warning can iterate over file replacements in Longer term, we should evaluate an alternative to file replacements, as it is some weird Angular magic that confuses the compiler/linter. If we could support multi-build use cases without rewriting imports, we could make this play much better with the compiler/linter. I'm thinking something similar to what https://dagger.dev/ does by injecting an interface and deferring the decision of importing a module to the very top-level main function, then generating a dev/prod version of that. We could also generate a
|
After I add the
Is there any workaround for hiding this warning but make the linting work at the same time? |
Any news on this one? We face the same problem where we have files that are only included (imported) when run/build with a specific environment by exporting them in the respective environment file. So those TS files look "unused" to the compilation and we get the same warning on the build. However, we need those file to be compiled as well to check for any errors. |
you can change
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Not sure
Description
Newly created project cannot lint
environment.prod.ts
file. After setting"include": [ "src/**/*.ts" ]
intsconfig.app.json
everything works fine.🔬 Minimal Reproduction
Create a new project with the CLI and run this command
ng lint --files src/environments/environment.prod.ts
in your terminal.🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: