Comments (6)
If you want to run commands in the root of the repo, do you need multiple config files? You could just put the package specific globs in the root directory:
export default {
"packages/a/**/*.js": "eslint"
}
I don't think adding a new flag for "resetting" the cwd is necessary as that's already the default behavior.
from lint-staged.
If you want to run commands in the root of the repo, do you need multiple config files? You could just put the package specific globs in the root directory:
export default { "packages/a/**/*.js": "eslint" }I don't think adding a new flag for "resetting" the cwd is necessary as that's already the default behavior.
Hey @iiroj ! Not really, I want to have lint-staged.config.js
in each workspace:
Here is an example of package's lint-staged config
import { default as baseConfig } from "../../lint-staged.config.js";
/** @type {import('lint-staged').Config} */
const config = {
...baseConfig,
"**/*.{ts,tsx}": [() => "npm run lint:js", () => "npm run lint:type"],
"**/*.css": [() => "npm run lint:css"],
};
export default config;
Only npx lint-staged --cwd $PWD
helps to make it works correctly – #1381
from lint-staged.
Do the linter commands work correctly from the sub-packages' working directories when running directly, without lint-staged in the mix? If so, it sounds like a bug.
from lint-staged.
without lint-staged in the mix
In this case yes, but I want to extend it with a base (root) config.
Firstly I needed to remove --cwd $PWD
because I have Windows' users in the project. You can check it in this commit (BinaryStudioAcademy/bsa-winter-2023-2024-trackmates@5c06c5d)
But I really want to have an extend behaviour. Then I decided to use this approach, but honestly do not like it... - BinaryStudioAcademy/bsa-winter-2023-2024-trackmates@4a16b5c
This is a reason why I suggested a new flag.
from lint-staged.
But in #1381 your command is knip --config knip.config.js
which only works when the working directory contains the config file (in repo root).
IMHO this is not exactly a lint-staged but a configuration issue. Would it work if you give knip
an absolute config path? You could resolve it in the base config file.
FYI I'm not familiar with knip
.
from lint-staged.
But in #1381 your command is
knip --config knip.config.js
which only works when the working directory contains the config file (in repo root).IMHO this is not exactly a lint-staged but a configuration issue. Would it work if you give
knip
an absolute config path? You could resolve it in the base config file.FYI I'm not familiar with
knip
.
Hello @iiroj!
I'm sorry, I lost the notification about the reply in my email.
What I would like to achieve:
In the root lint-staged config, I usually have linters such as editorconfig checker, knip (checks for unused files), etc. All linters that can be used for general linting of files.
In each workspace folder, I have more specific linters. For example, in the backend workspace, lint-staged is responsible for checking eslint, and in the frontend workspace, lint-staged is responsible for checking eslint and stylelint.
Is it possible to configure it so that when using the lint-staged extension via spread operator, for example, for the frontend workspace, lint-staged first checks the code with what it has along the path frontend/lint-staged, and then with what we extend from what is in the root lint-staged config (editorconfig checker, knip, etc.)?
Here is the repo example: https://github.com/BinaryStudioAcademy/bsa-winter-2023-2024-trackmates
FYI I'm not familiar with knip.
Knip can be run as just a knip
command, the same as eslint, stylelint, etc
"lint:trash": "knip",
from lint-staged.
Related Issues (20)
- Commits from Github Desktop occur errors HOT 4
- Not all lintstagedrc.json files are found in the rush.js monorepo HOT 4
- Type '(filenames: string[]) => Commands | Promise<Commands>' is not assignable to type 'string' HOT 2
- There is a bug with bracketed folders HOT 5
- Importing a reusable json file to ESM JS config fails HOT 1
- Path for baseConfig HOT 2
- lint-staged is unable to resolve path to module in Monorepo with map imports HOT 9
- Many errors in standard output when using git sparse-checkout HOT 4
- `--all` flag HOT 3
- lint-staged repeat many time ,when commit in windows powershell,cmd HOT 2
- [feat] override the current pattern HOT 1
- Make lint-staged more compatible with git sparse checkout feature HOT 6
- How to `git reset $file` ? HOT 3
- How to output the print content of the script in lint-staged in real time?
- Hooks to know if the lint staged commands have completed HOT 4
- Prettier breaks when run through lint-staged on files with dollar sign ($) in the name HOT 6
- Consider allowing running of programatic tasks via Node API HOT 5
- Is it possible to run 2 different configurations for pre-commit and pre-push? HOT 1
- No staged files found. with command "npx lint-staged"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lint-staged.