-
Notifications
You must be signed in to change notification settings - Fork 67
[frontend] Switch to TSLint #154
Comments
@kwasi: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/area front-end |
/priority p2 |
/area frontend
/kind feature
Background: We have a
tslint.json
but lint witheslint
due toreact-scripts
webpackI added some generated protocol buffers in 13794fc and broke frontend
webpack
compile due to lint failures for the no-undef rule. I was thrown off by the fact that there is atslint.json
configuration file but the failures were aneslint
rule.Adding the generated file path to an
eslintIgnore
block inpackage.json
didn’t work and adding the path totslint.json
didn’t fix the webpack compile either.How does
eslint
get run?When scripts run by
create-react-app
launchwebpack
the linting phase useseslint-loader
with theeslint-config-react-app
configuration [1], which uses @typescript-eslint to provide linting rules for TypeScript files to ESlint [2] without adding a dependency ontslint
.This configuration also ignores any
eslintIgnore
oreslintConfig
blocks inpackage.json
unless the EXTEND_ESLINT environment variable is set [3].Proposal: Modify the project to use TSLint through
react-scripts-ts
tslint
will prevent programmer error when trying to make lint changes intslint.json
react-scripts-ts
usestslint
directly instead ofeslint
with TypeScript support [4]react-scripts-ts
doesn't require environment variables to apply TSLint configkubeflow/pipelines
which usestslint
Tasks for implementation:
react-scripts
toreact-scripts-ts
inpackage.json
to pick uptslint.json
tslint
Caveats
There are a lot of existing files in the codebase that don’t match the rules declared in
tslint.json
, so addingtslint
will break the webpack compile until the lint errors are fixed. If we do this in conjunction with using adding prettier for code styles (#141), we can do both as one large-scale reformatting and reduce the merge overhead.References
[1] https://github.com/facebook/create-react-app/blob/6d6dfa9ba5a6042ab5690fe2a38b3ee54e644c9f/packages/react-scripts/config/webpack.config.js#L349
[2] https://github.com/facebook/create-react-app/blob/6d6dfa9ba5a6042ab5690fe2a38b3ee54e644c9f/packages/eslint-config-react-app/index.js#L57
[3]
https://github.com/facebook/create-react-app/blob/6d6dfa9ba5a6042ab5690fe2a38b3ee54e644c9f/packages/react-scripts/config/webpack.config.js#L359
[4] https://github.com/jpavon/react-scripts-ts/blob/d80cda5b72d17aeb217b23b331d9eba225319b3c/config/paths.js#L62
The text was updated successfully, but these errors were encountered: