Giter VIP home page Giter VIP logo

Comments (6)

iiroj avatar iiroj commented on June 1, 2024

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.

what1s1ove avatar what1s1ove commented on June 1, 2024

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:

image

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.

iiroj avatar iiroj commented on June 1, 2024

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.

what1s1ove avatar what1s1ove commented on June 1, 2024

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.

iiroj avatar iiroj commented on June 1, 2024

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.

what1s1ove avatar what1s1ove commented on June 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.