Skip to content
This repository was archived by the owner on Mar 3, 2024. It is now read-only.
This repository was archived by the owner on Mar 3, 2024. It is now read-only.

Example without Lerna and global linter/formatter #48

@zirkelc

Description

@zirkelc

Here's another option to use lint-staged at the project root, but still calling linters at package-level. This respects the linter and formatter configs/ignore files of each package.

const package = require('./package.json');
const { workspaces } = package; // or manually define workspaces as ['package-a', 'package-b']
const pattern = '**/*.{js,jsx,ts,tsx}';
const linter = 'node_modules/.bin/eslint --fix';

const rules = Object.fromEntries(workspaces.map(workspace => [`${workspace}/${pattern}`, `./${workspace}/${linter}`]))

module.exports = {
  // results into...
  // 'package-a/**/*.{js,jsx,ts,tsx}': 'package-a/node_modules/.bin/eslint --fix',
  // 'package-b/**/*.{js,jsx,ts,tsx}': 'package-b/node_modules/.bin/eslint --fix'
  ...rules
}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions