-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-plugin-typescript): Supports linting #18721
feat(gatsby-plugin-typescript): Supports linting #18721
Conversation
Hey @ThewBear this is looking great. Please merge master branch in (failing node 12 test was a problem some time ago in master and was fixed there, and it's not related to your code change) |
In core we do check if user has their own eslint config before adding eslint rule (which is opinionated, so this is a way for users to disable builtin one if they have their own config) - gatsby/packages/gatsby/src/utils/webpack.config.js Lines 305 to 307 in 3c8623c
And addition to that we only apply this loader in In current implementation in this PR this part is missing, and it's not obvious how we could re-implement it (as Some quick code that could be clean up to check it: const hasBuiltInEslintRule = webpackConfig => {
try {
return webpackConfig.module.rules.some(rule => {
if (rule.enforce === `pre`) {
return rule.use.some(use => {
return /eslint-loader/.test(use.loader)
})
}
return false
})
} catch {
return false
}
}
exports.onCreateWebpackConfig = ({ stage, getConfig }) => {
console.log(`stage ${stage}: ${hasBuiltInEslintRule(getConfig())}`)
} will output:
So this is something you could use to determine wether to add eslint rule for .tsx? files or not |
All right, I was testing it and few notes: We do need to add Pretty confusingly, you can use |
@ThewBear Hey 👋 Do you have time to address the requested changes? |
@ThewBear Hey 👋 Kind reminder of the above ping 😊 |
@LekoArts Will address this weekend. |
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 one! This is great for typescript users. Could you perhaps add typescript as an optional dependency.
I've added 2 comments about variable names but besides that this is 👌
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 and works! :) Thanks for adding this one and for your patience!
Fixed in |
Looks like in some cases (at least one) user configs are not considered after all --> #21913 |
)" This reverts commit d28a0bd.
Description
Splitted from #16168 (comment)
eslint-config-react-app
has supported linting Typescript since version 3.0.0 (facebook/create-react-app#6513).It would be great if Gatsby also supports this.
Related Issues
#15976
#16168