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

plugin doesn't work with NX #142

Open
kosiakMD opened this issue Jan 10, 2024 · 4 comments
Open

plugin doesn't work with NX #142

kosiakMD opened this issue Jan 10, 2024 · 4 comments

Comments

@kosiakMD
Copy link

kosiakMD commented Jan 10, 2024

"@darraghor/eslint-plugin-nestjs-typed": "^4.4.0",

either files not found or are ignored - blocks other rules to go forward even with warn

Screenshot 2024-01-10 at 15 31 33 Screenshot 2024-01-10 at 15 31 49

ALSO:

I have next rule:

'@darraghor/nestjs-typed/injectable-should-be-provided': [
  'error',
  {
    src: ['src/**/*.ts'],
    filterFromPaths: ['node_modules', '.test.', '.spec.', 'jest.config.ts', 'tsconfig.spec.json', 'tsconfig.scripts.json'],
  },
],

and got next error

> nx run api:lint


Linting "api"...

 >  NX   Error while loading rule '@darraghor/nestjs-typed/injectable-should-be-provided': No files matching 'src/**/*.ts' were found.

   Occurred while linting /..****../..[projectRootfolder]../apps/api/jest.config.ts
   Pass --verbose to see the stacktrace.

--verbose add stacktrace, here is first lines:

Error: Error while loading rule '@darraghor/nestjs-typed/injectable-should-be-provided': All files matched by '**/*.ts' are ignored.
Occurred while linting /..****../..[projectRootfolder]../apps/api/jest.config.ts
    at FileEnumerator.iterateFiles (/..****../..[projectRootfolder]../node_modules/eslint/lib/cli-engine/file-enumerator.js:326:27)
@roderik
Copy link

roderik commented Jan 15, 2024

I struggled too, but if you define a full path for src in the local folder, it works fine. I manage our monorepo libs folder with a script to update everything everywhere https://gist.github.com/roderik/c83efef5412b7bbd7d76329c02a28338 (specific to us, do not just copy it, but the logic to get the path and update the files is usable

@kosiakMD kosiakMD changed the title plugin doesn't work (at least with NX) plugin doesn't work with NX Jan 22, 2024
@darraghoriordan
Copy link
Owner

darraghoriordan commented Feb 3, 2024

i don't use NX sorry. I imagine it does all sorts of things with caching and file locations. If you get a chance to investigate and fix with a PR, it would help all nx users.

otherwise you should able to turn off this rule with '@darraghor/nestjs-typed/injectable-should-be-provided': "off"

@ivan-shaban
Copy link

ivan-shaban commented Aug 6, 2024

Big thanks to @roderik, so as i understand we can add next:

{
  "extends": ["../../.eslintrc.json"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["**/*.ts"],
      "extends": ["plugin:@darraghor/nestjs-typed/recommended"],
      "plugins": ["@darraghor/nestjs-typed"],
      "rules": {
        "@darraghor/nestjs-typed/injectable-should-be-provided": [
          "error",
          {
            "src": ["apps/server/src/**/*.ts"],
            "filterFromPaths": ["node_modules"]
          }
        ]
      },
      "parserOptions": {
        "project": ["apps/server/tsconfig.*?.json"]
      }
    },
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {}
    },
    {
      "files": ["*.ts", "*.tsx"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "rules": {}
    }
  ]
}

Where apps/server path to your module.

Also i think it could be added to basic docs, because it is not obvious.

@darraghoriordan
Copy link
Owner

Big thanks to @roderik, so as i understand we can add next:

{
  "extends": ["../../.eslintrc.json"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["**/*.ts"],
      "extends": ["plugin:@darraghor/nestjs-typed/recommended"],
      "plugins": ["@darraghor/nestjs-typed"],
      "rules": {
        "@darraghor/nestjs-typed/injectable-should-be-provided": [
          "error",
          {
            "src": ["apps/server/src/**/*.ts"],
            "filterFromPaths": ["node_modules"]
          }
        ]
      },
      "parserOptions": {
        "project": ["apps/server/tsconfig.*?.json"]
      }
    },
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {}
    },
    {
      "files": ["*.ts", "*.tsx"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "rules": {}
    }
  ]
}

Where apps/server path to your module.

Also i think it could be added to basic docs, because it is not obvious.

Do you use this in a commercial settings? If so can you get some of your paid time to submit a PR to update docs? 🙏

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

No branches or pull requests

4 participants