Skip to content
This repository has been archived by the owner on Jan 26, 2019. It is now read-only.

Fails to recompile with custom tslint rules #250

Open
doomsower opened this issue Feb 10, 2018 · 14 comments
Open

Fails to recompile with custom tslint rules #250

doomsower opened this issue Feb 10, 2018 · 14 comments

Comments

@doomsower
Copy link

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

  1. npm ls react-scripts-ts (if you haven’t ejected): 2.13.0
  2. node -v: v8.9.4
  3. npm -v: 5.6.0
  4. yarn --version (if you use Yarn): 1.3.2
  5. npm ls react-scripts-ts (if you haven’t ejected): 2.13.0

Then, specify:

  1. Operating system: MacOS 10.13.3
  2. 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.)

@tugberkugurlu
Copy link

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

@runeh
Copy link

runeh commented 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:

"no-unused-variable": [true, "react"],

Removing that line makes everything else work as expected, even without setting the severity to warn.

@avohmincevs
Copy link

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
Copy link

tugberkugurlu commented Feb 27, 2018

I added baseUrl: ".", it made the error disappear.

@rrousselGit
Copy link

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.

@Jancat
Copy link

Jancat commented Mar 27, 2018

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

@code-hunger
Copy link

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.

@zheeeng
Copy link

zheeeng commented Apr 9, 2018

baseUrl: "." not works for me.

@JavadocMD
Copy link

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.

@ackvf
Copy link

ackvf commented Apr 26, 2018

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.

@zheeeng
Copy link

zheeeng commented 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
Copy link

zheeeng commented Jul 3, 2018

report: remove 'no-unused-variable' rule, everything works normal

@maxlang
Copy link

maxlang commented Jul 10, 2018

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.

@flushentitypacket
Copy link

@runeh How in the world did you figure out that no-unused-variable was the culprit? Genuinely curious.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests