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(create-vite): strict checks on vite.config.ts #14270

Closed

Conversation

nekketsuuu
Copy link

Description

After creating a project using create-vite with React and TypeScript, and adding plugin:@typescript-eslint/strict-type-checked according to README.md, rule @typescript-eslint/no-unnecessary-condition throws an error on vite.config.ts when running lint.

/path/to/my-project/vite.config.ts
  0:1  error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/no-unnecessary-condition

Here is a small project to reproduce this error: nekketsuuu/vite-config-js-strict@380208d.

That error is because TS strict mode is not enabled at tsconfig.node.json. So, this patch enables the same linting config at tsconfig.node.json as that of https://github.com/vitejs/vite/blob/cd6bf29ca4b677ff0d6e2bf36416a65b1a6ffa21/packages/create-vite/template-react-ts/tsconfig.json.

Also see: 4ffaeee #12604
Follow-up: 2ad78aa #13749

Additional context

Nothing.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

After adding `plugin:@typescript-eslint/strict-type-checked`
according to README.md, rule `@typescript-eslint/no-unnecessary-condition`
throws an error on vite.config.ts.

```
/path/to/my-project/vite.config.ts
  0:1  error  This rule requires the `strictNullChecks` compiler option to be turned on to function correctly  @typescript-eslint/no-unnecessary-condition
```

This is because TS strict mode is not enabled at tsconfig.node.json.

Also see: 4ffaeee
Follow-up: 2ad78aa
@stackblitz
Copy link

stackblitz bot commented Sep 3, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@ArnaudBarre
Copy link
Member

Hi!
I think this good to improve this small TS config but it will be better to make it more consistent with the rest

  • The structure should follow the main one and only diverge for what makes sense for node
  • The change should be made too all TS templates

@nekketsuuu
Copy link
Author

Hi. Thanks for your advise! Unfortunately, I cannot afford the time to improve all other TS templates. So I'm closing this pr, but feel free to change these configs later.

@nekketsuuu nekketsuuu closed this Oct 7, 2023
@nekketsuuu nekketsuuu deleted the nekketsuuu-tsconfig-node-lint branch October 7, 2023 15:24
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