-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Add support for TSLint #5697
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
Changes from 5 commits
666bc48
c7df1bb
36ef757
cec8d1e
c0e172f
c154fa6
6b2ce5c
4f1a814
9b45c83
baf4024
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"defaultSeverity": "warning", | ||
"rulesDirectory": "tslint-microsoft-contrib", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Fair point - There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 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
Having a choice on how linting works is more preferable than the way this PR does it. |
||
"rules": { | ||
// https://palantir.github.io/tslint/rules/ | ||
"await-promise": true, | ||
"new-parens": true, | ||
"no-angle-bracket-type-assertion": true, | ||
"no-conditional-assignment": true, | ||
"no-debugger": true, | ||
"no-duplicate-super": true, | ||
"no-duplicate-switch-case": true, | ||
"no-duplicate-variable": true, | ||
"no-eval": true, | ||
"no-floating-promises": true, | ||
"no-for-in-array": true, | ||
"no-implicit-dependencies": [true, "dev"], | ||
"no-invalid-template-strings": true, | ||
"no-invalid-this": true, | ||
"no-namespace": true, | ||
"no-sparse-arrays": true, | ||
"no-string-throw": true, | ||
"no-switch-case-fall-through": true, | ||
"no-unused-expression": [true, "allow-fast-null-checks"], | ||
// DEPRECATED. Recommended to use TS 'noUnusedLocals' for now | ||
// "no-unused-variable": true, | ||
"triple-equals": true, | ||
"use-isnan": true, | ||
|
||
// https://github.com/Microsoft/tslint-microsoft-contrib | ||
"react-a11y-anchors": true, | ||
"react-a11y-aria-unsupported-elements": true, | ||
"react-a11y-event-has-role": true, | ||
"react-a11y-image-button-has-alt": true, | ||
"react-a11y-img-has-alt": true, | ||
"react-a11y-props": true, | ||
"react-a11y-proptypes": true, | ||
"react-a11y-role": true, | ||
"react-a11y-role-has-required-aria-props": true, | ||
"react-a11y-role-supports-aria-props": true | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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. |
||
serviceWorker.unregister(); |
Uh oh!
There was an error while loading. Please reload this page.