Not all lintstagedrc.json files are found in the rush.js monorepo

100 Views Asked by At

Expected and behavior

In a rush.js monorepo, I expect lint-staged to report problems that eslint . --fix cannot solve independently and aborts the commit. Currently all commits go through and malformed code is committed.

I assume that the child configuration files are not taken into account because the following echo commands do not appear on the console. The echo string appears in the configuration file in the root directory. I suspect this is also because the message No staged files found. appears.

Steps to reproduce

I have a monorepo with rush.js that has a /frontend and a /backend repository under the apps/ directory. These two repos are integrated as git submodules in the monorepo.

lint-staged is implemented in an autoinstaller package under common/autoinstallers/rush-lint-staged and is executed via the rush command rush lint-staged-apps.

According to the faqs for monorepos, I have stored the first (nearest) lintstagedrc.json in the root directory, the second lintstagedrc.json in /apps/frontend and also in /apps/backend.

I try to avoid the part of writing the configuration files in js and merging them, because in the project almost all configuration files are written in .json or .yaml and I want to keep the TypeScript project as js-free as possible. In addition, merging is not necessary because no configuration cascade is needed. Unless it leads to the solution of my problem.

monorepo   <-- own github repo
│   lintstagedrc.json
│   ...
│
└───apps
│   │
│   └───frontend   <-- own github repo (submodule in monorepo)
│   |   │   lintstagedrc.json
│   |
│   └───backend   <-- own github repo (submodule in monorepo)
│       │   lintstagedrc.json

lintstagedrc.json (root)

{
  "*": "echo lint-staged config file found! Go ahead..."
}

lintstagedrc.json (frontend and backend)

{
 "*": "echo lint-staged config file found in submodule! Lets lint!",
  "**/*.{js|ts|vue}": "eslint . --fix"
}

The eslintrc.json and .eslintignore files are available in the submodules. If I execute the eslint command on the console, I get the expected behavior.

I have already tested with all configurations in lint-staged and different patterns (micromatch), but I am not able to create the expected setup.

The question

What else do I need to consider in my setup? Are there currently known problems that I have not yet recognized? Has anyone had experience with this setup or similar that could help at this point?

Debug Logs

  lint-staged:bin Running `[email protected]` on Node.js v18.18.2 (win32) +0ms
  lint-staged:bin Options parsed from command-line: {
  allowEmpty: false,
  concurrent: true,
  configPath: undefined,
  cwd: undefined,
  debug: true,
  diff: undefined,
  diffFilter: undefined,
  maxArgLength: undefined,
  quiet: false,
  relative: false,
  shell: false,
  stash: false,
  hidePartiallyStaged: false,
  verbose: false
} +1ms
  lint-staged:validateOptions Validating options... +0ms
  lint-staged:validateOptions Validated options! +1ms
  lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
  lint-staged:runAll Running all linter scripts... +0ms
  lint-staged:runAll Using working directory `D:\Development\Projects\Xsigns\Vacarema\App\v2\monorepo` +0ms
  lint-staged:resolveGitRepo Resolving git repo from `D:\Development\Projects\Xsigns\Vacarema\App\v2\monorepo` +0ms
  lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
  lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +0ms
  lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
  lint-staged:resolveGitRepo Resolved git directory to be `D:/Development/Projects/Xsigns/Vacarema/App/v2/monorepo` +54ms
  lint-staged:resolveGitRepo Resolved git config directory to be `D:/Development/Projects/Xsigns/Vacarema/App/v2/monorepo/.git` +0ms
  lint-staged:execGit Running git command [ 'log', '-1' ] +54ms
‼ Skipping backup because `--no-stash` was used.

‼ Skipping hiding unstaged changes from partially staged files because `--no-stash` was used.

  lint-staged:execGit Running git command [ 'diff', '--name-only', '-z', '--diff-filter=ACMR', '--staged' ] +53ms
  lint-staged:runAll Loaded list of staged files in git:
  lint-staged:runAll [] +161ms
  lint-staged Tasks were executed successfully! +162ms
→ No staged files found.

Environment

  • OS: Windows 11, WSL
  • Node.js: 18.18.2
  • lint-staged: 15.2.0
0

There are 0 best solutions below