-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Eslint Plugin: Add TypeScript as peer dependency and make it optional #29942
Conversation
Huh, this is what I see at https://www.npmjs.com/package/typescript I guess we can't do much about it. |
Size Change: 0 B Total Size: 1.4 MB ℹ️ View Unchanged
|
Is it possible to create a config which treats *.js and *.ts files separately so we can make TS a peer dependency like eslint? Maybe at least until TS is more common in the project? Basically if a project has no *.ts files don't require TS to be installed. |
This is worth exploring, it seems like a straightforward way to address the issue. |
4ff7935
to
ae544e9
Compare
This is interesting way to declare peer dependencies: "peerDependenciesMeta": {
"typescript": {
"optional": true
}
}, |
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 would appreciate some sanity check from someone else since I added most of the code changes 😅
I plan to cherry-pick this PR and publish to npm as soon as it gets accepted.
Based on the comment npm/cli#1247 (comment), I think the This is different for |
Yes, it looks like you are correct and it was implemented as noted it npm/rfcs#221. Detailed documentation is here: |
bea9962
to
ef5c6ca
Compare
|
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.
Tested with and without TS and it's working as expected, should be good to merge.
Thank you all for help 🙇🏻 |
…#29942) * Add explicit dependency on TypeScript * Move typescript to a peer dependency * Run TypeScript validation only when it is installed * ESLint Pluging: Add the changelog entry * Clarify the TS integration in the README file * Mark typescript as an optional peer dependency Co-authored-by: Grzegorz Ziolkowski <[email protected]>
Description
Adds an explicit dependency on TypeScript to
eslint-plugin
.See #29940 for details.
Fixes #29940
How has this been tested?
npm run build
scripts
tofile:../gutenberg/packages/scripts
(assuminggutenberg
lives in the same repository as the test folder for the testpackage.json
)For example:
There should be no errors when running
npx wp-scripts lint-js index.js
You must
npm install
in your test directory before runningnpx ...
Types of changes
Bug fix
Checklist: