create-react-app-typescript
create-react-app-typescript copied to clipboard
Fails to recompile with custom tslint rules
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 [email protected] 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.)
I am getting the same:
> react-scripts-ts build
Failed to load tsconfig.json: Missing baseUrl in compilerOptions
Creating an optimized production build...
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 1 worker with 2048MB memory limit
I'm having the same issue with my custom tslint file. The only rule that triggers the bug for me is this one:
"no-unused-variable": [true, "react"],
Removing that line makes everything else work as expected, even without setting the severity to warn.
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
I added baseUrl: ".", it made the error disappear.
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 from tslin.json removed the error.
I added "semicolon": [true, "never"] in the tslint.json. And remove the semicolon in the files.
Then the terminal outputs:
Failed to compile.
xxx/my-app/src/App.tsx
(1,31): Missing semicolon
Adding baseUrl: "." to compilerOptions in tsconfig.json works for me, too. But it still needs full server restart in order to incorporate new changes to tslint.json.
baseUrl: "." not works for me.
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.
[email protected] [email protected] [email protected] (also tried 8.11.0) [email protected] Windows 10; Firefox
Removing no-unused-variable: { "severity": "warning" } from tslint.json is a work-around.
Nice catch with the tslint.json file. I wonder how you figured that out. Removing no-unused-variable fixed my issue too. For reference I had this error Failed 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.
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
report: remove 'no-unused-variable' rule, everything works normal
I had the same issue with https://github.com/manuelbieh/Geolib
I tried switching to using noUnusedParams and noUnusedLocals in tsconfig.json and at first I think I got some errors but now it seems to work. Not sure if this is a partial workaround.
@runeh How in the world did you figure out that no-unused-variable was the culprit? Genuinely curious.