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

Fails to recompile with custom tslint rules #250

@doomsower

Description

@doomsower

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

tugberkugurlu commented on Feb 20, 2018

@tugberkugurlu

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

runeh commented on Feb 22, 2018

@runeh

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

avohmincevs commented on Feb 27, 2018

@avohmincevs

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

tugberkugurlu commented on Feb 27, 2018

@tugberkugurlu

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

rrousselGit

rrousselGit commented on Mar 1, 2018

@rrousselGit

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

Jancat commented on Mar 27, 2018

@Jancat

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

code-hunger commented on Apr 1, 2018

@code-hunger

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

zheeeng commented on Apr 9, 2018

@zheeeng

baseUrl: "." not works for me.

JavadocMD

JavadocMD commented on Apr 18, 2018

@JavadocMD

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

ackvf commented on Apr 26, 2018

@ackvf

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

zheeeng commented on Jul 3, 2018

@zheeeng

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

zheeeng commented on Jul 3, 2018

@zheeeng

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

maxlang

maxlang commented on Jul 10, 2018

@maxlang

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

flushentitypacket commented on Sep 4, 2018

@flushentitypacket

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @runeh@tugberkugurlu@zheeeng@flushentitypacket@avohmincevs

        Issue actions

          Fails to recompile with custom tslint rules · Issue #250 · wmonk/create-react-app-typescript