-
Notifications
You must be signed in to change notification settings - Fork 488
Fails to recompile with custom tslint rules #250
Description
It's either something wrong with my tslint.json
(which used to work before I upgraded many packages) or it's a bug.
Is this a bug report?
Yes
Can you also reproduce the problem with npm 4.x?
Yes
Which terms did you search for in User Guide?
(Write your answer here if relevant.)
Environment
npm ls react-scripts-ts
(if you haven’t ejected): 2.13.0node -v
: v8.9.4npm -v
: 5.6.0yarn --version
(if you use Yarn): 1.3.2npm ls react-scripts-ts
(if you haven’t ejected): 2.13.0
Then, specify:
- Operating system: MacOS 10.13.3
- Browser and version (if relevant):
Steps to Reproduce
I tried to reproduce this with blank project, but was unable to do so. Here is what's going on in my project:
I have custom tslint.json
file:
{
"extends": ["tslint:latest", "tslint-react", "tslint-eslint-rules"],
"rules": {
"arrow-parens": false,
"arrow-return-shorthand": [false],
"brace-style": [ true, "1tbs", { "allowSingleLine": true}],
"comment-format": [true, "check-space"],
"import-blacklist": [true, "rxjs"],
"interface-name": false,
"jsx-boolean-value": [true, "never"],
"jsx-no-multiline-js": false,
"member-access": false,
"member-ordering": [true, {"order": "statics-first"}],
"newline-before-return": false,
"no-any": false,
"no-empty": [true, "allow-empty-catch"],
"no-console": [true, "log"],
"no-inferrable-types": [true],
"no-implicit-dependencies": [true, "dev"],
"no-import-side-effect": [true, {"ignore-module": "(\\.html|\\.css)$"}],
"no-invalid-this": [true, "check-function-in-method"],
"no-null-keyword": false,
"no-require-imports": false,
"no-submodule-imports": [true, "material-ui", "lodash", "raf", "redux-persist"],
"no-switch-case-fall-through": true,
"no-trailing-whitespace": true,
"no-unused-variable": [true, "react"],
"object-curly-spacing": [true, "always"],
"object-literal-sort-keys": false,
"only-arrow-functions": [true, "allow-declarations"],
"ordered-imports": [ true, { "import-sources-order": "case-insensitive", "named-imports-order": "case-insensitive"}],
"prefer-method-signature": false,
"prefer-template": [true, "allow-single-concat"],
"quotemark": [true, "single", "jsx-double"],
"semicolon": [true, "always", "ignore-bound-class-methods"],
"triple-equals": [true, "allow-null-check"],
"typedef": [true,"parameter", "property-declaration", "member-variable-declaration"],
"variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case", "allow-leading-underscore"]
},
"defaultSeverity": "warning"
}
and in devDependencies
i have
"ts-jest": "^22.0.3",
"tslint": "^5.8.0",
"tslint-eslint-rules": "^4.1.1",
"tslint-react": "^3.2.0",
"typescript": "2.7.1",
Expected Behavior
I run yarn start
, the project compiles. Then I add newline to some .ts file, project recompiles without errors.
Actual Behavior
Here is the output of yarn start > log.txt
:
yarn run v1.3.2
$ react-scripts-ts start
Failed to load tsconfig.json: Missing baseUrl in compilerOptions
Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
Found no baseUrl in tsconfig.json, not applying tsconfig-paths-webpack-plugin
Starting type checking and linting service...
Using �[1m1 worker�[22m with �[1m2048MB�[22m memory limit
Watching: �[90m/Users/doomsower/projects/porjectname/web/src�[39m
Starting the development server...
ts-loader: Using typescript@2.7.1 and /Users/doomsower/projects/porjectname/web/tsconfig.json
Compiled with warnings.
... warnings
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
Compiling...
Failed to compile.
/Users/doomsower/projects/porjectname/web/node_modules/@types/draft-js/index.d.ts
(14,28): Cannot find module 'immutable'.
The project compiles and starts at first, but any change leads to recompile failure.
However, if I change content of tslint.json
to default that comes with create-react-app-typescript
and add "defaultSeverity": "warning"
, everything compiles and recompiles just fine.
Reproducible Demo
(Paste the link to an example project and exact instructions to reproduce the issue.)
Activity
tugberkugurlu commentedon Feb 20, 2018
I am getting the same:
runeh commentedon Feb 22, 2018
I'm having the same issue with my custom tslint file. The only rule that triggers the bug for me is this one:
Removing that line makes everything else work as expected, even without setting the severity to
warn
.avohmincevs commentedon Feb 27, 2018
Upgraded from 2.8.0 to 2.13.0 and facing the same error. Tried adding baseUrl: "" to tsconfig.json but that didn't help.
Environment
npm ls react-scripts-ts (if you haven’t ejected): 2.13.0
node -v: v9.6.1
yarn --version (if you use Yarn): 1.3.2
npm ls react-scripts-ts (if you haven’t ejected): 2.13.0
tugberkugurlu commentedon Feb 27, 2018
I added
baseUrl: "."
, it made the error disappear.rrousselGit commentedon Mar 1, 2018
Same errror too.
Whenever I edit a css file, during recompile it "break". As soon as I save a ts file, it recompile again.
For weird reasons, removing the
no-unused-variable
fromtslin.json
removed the error.Jancat commentedon Mar 27, 2018
I added
"semicolon": [true, "never"]
in the tslint.json. And remove the semicolon in the files.Then the terminal outputs:
code-hunger commentedon Apr 1, 2018
Adding
baseUrl: "."
tocompilerOptions
intsconfig.json
works for me, too. But it still needs full server restart in order to incorporate new changes totslint.json
.zheeeng commentedon Apr 9, 2018
baseUrl: "."
not works for me.JavadocMD commentedon Apr 18, 2018
Experiencing the same issue: initial compile works fine. CSS hot loads cause "Failed to compile" ("Can't find module" reported in index.tsx); TS hot loads work fine.
react-scripts-ts@2.15.1
npm@5.6.0
node@9.11.1 (also tried 8.11.0)
yarn@1.6.0
Windows 10; Firefox
Removing
no-unused-variable: { "severity": "warning" }
from tslint.json is a work-around.ackvf commentedon Apr 26, 2018
Nice catch with the
tslint.json
file. I wonder how you figured that out. Removingno-unused-variable
fixed my issue too. For reference I had this errorFailed to compile: Cannot find module 'firebaseui'
.Initial compile worked fine, file changes in
.tsx
were also OK.NOT OK: changes in
.css
and.ts
files.Remove no-unused-variable rule to fix CSS hot-reloading
zheeeng commentedon Jul 3, 2018
My problem is the initial compile fails, it reports some false positive errors, once re-save the file with "errors", the re-compile works fine
zheeeng commentedon Jul 3, 2018
report: remove 'no-unused-variable' rule, everything works normal
maxlang commentedon Jul 10, 2018
I had the same issue with https://github.com/manuelbieh/Geolib
I tried switching to using
noUnusedParams
andnoUnusedLocals
intsconfig.json
and at first I think I got some errors but now it seems to work. Not sure if this is a partial workaround.flushentitypacket commentedon Sep 4, 2018
@runeh How in the world did you figure out that
no-unused-variable
was the culprit? Genuinely curious.