-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Add support for TSLint #5697
Add support for TSLint #5697
Conversation
packages/react-scripts/template-typescript/src/serviceWorker.ts
Outdated
Show resolved
Hide resolved
@@ -9,4 +9,5 @@ ReactDOM.render(<App />, document.getElementById('root')); | |||
// If you want your app to work offline and load faster, you can change | |||
// unregister() to register() below. Note this comes with some pitfalls. | |||
// Learn more about service workers: http://bit.ly/CRA-PWA | |||
// tslint:disable-next-line:no-floating-promises |
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.
@Timer let me know how you feel about this. I refactored all the serviceWorker code to use async/await, which fixes all the TSLint errors.
@@ -0,0 +1,42 @@ | |||
{ | |||
"defaultSeverity": "warning", | |||
"rulesDirectory": "tslint-microsoft-contrib", |
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.
tslint-config-prettier and tslint-react would be nice defaults to have 👍
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.
@andyrichardson which rules were you thinking from tslint-react? A lot of the rules seemed to be style prefer nces which we try to avoid.
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.
Fair point - jsx-key
is already flagged by React so I guess the only other useful non-style option is jsx-self-close
.
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 will expose tslint.json to the root, so technically we can add our own rules to the project, correct? The current way create-react-app
does eslint, it exposes a package.json
config called eslintConfig
, we could do the same and name it tslintConfig
.
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.
@mohamedmansour just like ESLint, you will not be able to add your own rules. Added rules will strictly affect the editor output, not the build tools.
If you need to check linting on commit, I suggest you use a precommit hook.
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 is unfortunate, why couldn't we change that model and allow the users to override tslint.json? The beautiful thing about TypeScript is that it is a superset of JavaScript, each team can decide what kind of strictness they need or want. Once create-react-app
enforce this projects strictness for linting, then I cannot use the rules that I want to enforce in my own project.
For example, we are overriding many rules to fit our teams standard here https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/tslint-rules/tslint.json
And in my current project, I just do the following in tslint.json
:
{
"extends": [
"@uifabric/tslint-rules"
],
"rules": {
"jsx-no-lambda": false,
"jsx-ban-props": false,
"typedef": [false]
}
}
Having a choice on how linting works is more preferable than the way this PR does it.
@ianschmitz What's left to get this done? How can we help? |
This would be awesome: palantir/tslint-react#186 |
it's nice that someone already works on this!!! Today i also thought about mapping eslint to tslint ( tslint-eslint-rules ) or parsing typescript with eslint typescript-eslint-parser Unfortunately mapping eslint to tslint does not work with "extends" so we would have to create another project (e.g. tslint-config-react-app) and duplicate the ruleset. And my favourite: parsing typescript with eslint does not work on the IDE because of the fileextension. |
btw. will this PR cover IDE support? |
We should be able to follow the same pattern that we already have for ESLint to add a dummy tslint.json file to root of repo and extend our ruleset |
yes thats the only way i think (too bad there is no tslintConfig standard for package.json). then it would be the best to create another package like @Timer already reserved it on npm :) https://www.npmjs.com/package/tslint-config-react-app |
Yep we have that in this PR already 🙂 |
I created a solution to this problem. You can use your own TSLint instead of the built-in linting or fork-ts-checker by using the Rescripts framework and its use-tslint-config rescript (I just released it and would really love your feedback!) :) |
@harrysolovay Rescripts seems amazing, looking forward to test it, good job! |
@samuelcastro thank you so much! Please let me know your thoughts & any suggestions :) |
Based on the current roadmap that has been laid out over at microsoft/TypeScript#29288, it sounds like they will be standardizing on ESLint:
I will keep a close eye on this to see if this is the direction that we should follow as they make progress bringing ESLint up to snuff to support TypeScript. |
More information from ESLint team: |
Closing in favor of #6513 |
Closes #5641.
Adds support for TSLint via fork-ts-checker-webpack-plugin.
TODO:
tslint.json
should live