Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tslint.json files in sub directories are ignored. #5770

Closed
james-schwartzkopf opened this issue Mar 30, 2017 · 3 comments · Fixed by #5792
Closed

tslint.json files in sub directories are ignored. #5770

james-schwartzkopf opened this issue Mar 30, 2017 · 3 comments · Fixed by #5792

Comments

@james-schwartzkopf
Copy link

Bug Report or Feature Request (mark with an x)

- [ X ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ △ \ | '
\ / _ | | | | |/ _ | '
| | | | | | |
/ ___ | | | | (
| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
@angular/cli: 1.0.0
node: 6.9.2
os: win32 x64
@angular/common: 4.0.1
@angular/compiler: 4.0.1
@angular/core: 4.0.1
@angular/forms: 4.0.1
@angular/http: 4.0.1
@angular/platform-browser: 4.0.1
@angular/platform-browser-dynamic: 4.0.1
@angular/router: 4.0.1
@angular/cli: 1.0.0
@angular/compiler-cli: 4.0.1

Repro steps.

Add a tslint.json file in a directory under src that has rules different than the
cli defaults (see log below).

The log given by the failure.

$ ng new ng-lint-issue > /dev/null

$ cd ng-lint-issue

$ mkdir src/app/new-rules

$ cat > src/app/new-rules/tslint.json <<EOL

{ "rules": { "quotemark": [ true, "double" ] } }
EOL

$ cat > src/app/new-rules/test.ts <<EOL

const doubleQuotes = "double quotes should be allowed";
const singleQuotes = 'single quotes should cause lint error';
EOL

$ ng lint

src/app/new-rules/test.ts[1, 22]: " should be '

Lint errors found in the listed files.

$ ./node_modules/.bin/tslint --project src/tsconfig.app.json

src/app/new-rules/test.ts[2, 22]: ' should be "

Desired functionality.

We are using multiple tslint.json files because we have modified versions of code from other projects in our src directory and do not want to rewrite them to conform to the angular-cli tslint rules. With the previous version we just included the tslint.json from the original project in the sub directory. This worked in earlier versions (1.0.0-beta.26).

We are also thinking about using them to override the default component/directive prefix in feature modules as a workaround for #3452.

Mention any other details that might be useful.

@clydin
Copy link
Member

clydin commented Mar 30, 2017

You should get the desired behavior by removing the reference to the tslint config file from angular-cli.json

@james-schwartzkopf
Copy link
Author

I don't see any reference to tslint.json in the .angular-cli.json?

$ cat .angular-cli.json
{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "ng-lint-issue"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    },
    {
      "project": "e2e/tsconfig.e2e.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "component": {}
  }
}

filipesilva pushed a commit that referenced this issue Apr 3, 2017
TSLint includes logic to find the most relevant config per linted file. Unfortunately, by defaulting the config filename this behavior was being disabled.

Fixes #5770
dond2clouds pushed a commit to d2clouds/speedray-cli that referenced this issue Apr 23, 2018
…ar#5792)

TSLint includes logic to find the most relevant config per linted file. Unfortunately, by defaulting the config filename this behavior was being disabled.

Fixes angular#5770
cj-wang added a commit to cj-wang/mean-start-2 that referenced this issue Feb 6, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants