typescript-tslint-plugin icon indicating copy to clipboard operation
typescript-tslint-plugin copied to clipboard

a tslint.json placed in a directory above tsconfig.json is not applied

Open xaviergonz opened this issue 6 years ago • 11 comments

Say there is a monorepo structure such as this one

- tslint.json
- node_modules/...
- packages/a/tsconfig.json
- packages/a/src/...

then tslint.json is not automatically found and applied (it is with the "old" tslint plugin)

if a tslint.json is placed in packages/a/tslint.json that just extends the root one then it will work

xaviergonz avatar Feb 07 '19 19:02 xaviergonz

In that example, which folder have you opened in the editor?

mjbvz avatar Feb 07 '19 20:02 mjbvz

A source file inside packages/a/src

xaviergonz avatar Feb 07 '19 21:02 xaviergonz

Did you only open a single file in your editor? Or an entire subfolder?

mjbvz avatar Feb 07 '19 21:02 mjbvz

a single .ts file

xaviergonz avatar Feb 07 '19 22:02 xaviergonz

Also, maybe unrelated, when the tslint.json location is set in the plugins section of the tsconfig.json pointing to the root folder, if vscode is closed and reopened again then tslint won't work until such tsconfig.json file is resaved.

When using the extends trick it is ok.

xaviergonz avatar Feb 07 '19 22:02 xaviergonz

Btw, what I mean by a single .ts file is that the workspace is pointing to the root, and then I double click on that single .ts file to open it.

xaviergonz avatar Feb 07 '19 22:02 xaviergonz

If you want a proper example just clone this repo for example: https://github.com/mobxjs/mobx-state-tree then open the folder with vscode, run yarn and open any ts file inside packages\mobx-state-tree\src

xaviergonz avatar Feb 07 '19 22:02 xaviergonz

A commit was just done to use tslint.json that extends to the root one, so if you clone that repo you may want to use this branch for example instead: https://github.com/mobxjs/mobx-state-tree/tree/better-liveliness-warning

xaviergonz avatar Feb 08 '19 15:02 xaviergonz

I am also experiencing this with descending tslint files

Project is an ASP.NET Core project with Angular 6.X.X

/tsconfig.json /ClientApp/tsconfig.json (A) /ClientApp/src/tsconfig.json (B)


/ClientApp/tsconfig.json (A)

{
  "defaultSeverity": "error",
  "extends": "tslint:recommended",
  "jsRules": {},
  "rules": {  },
  "rulesDirectory": []
}

/ClientApp/tsconfig.json (B)

{
  "extends": "../tslint.json",
  "rules": {
    "component-selector": [
      true,
      "element",
      "app",
      "kebab-case"
    ],
    "directive-selector": [
      true,
      "attribute",
      "app",
      "camelCase"
    ]
  },
  "linterOptions": {
    "exclude": [
      "test.ts",
      "main.ts",
      "polyfills.ts"
    ]
  }
}

When I run the CLI or through Visual Studio with tslint-microsoft-contrib the excluded files are not excluded as expected. Which leads me to believe it is not being loaded in reference to the directory it sits in.

itanex avatar Feb 12 '19 22:02 itanex

@xaviergonz Looks like that branch no longer exists. Do you have a link to version of that project where it doesn't work?

mjbvz avatar Jun 27 '19 23:06 mjbvz

Same issue here, but I'm opening the whole monorepo in vscode

tslint.json
packages/
  package1/
    tsconfig.json   

linter is not working and it did with the old extension

marcosfede avatar Aug 06 '19 19:08 marcosfede

Closing as TSLint has been deprecated in favor of ESLint. We are archiving this repo as this project is no longer maintained

mjbvz avatar May 01 '23 20:05 mjbvz