Skip to content

Improve lint-staged stages to ensure we only lint committed files #1455

Open
@reykjalin

Description

@reykjalin

As per @vbelolapotkov comment in #1442:

@reykjalin it works fine on local machine, so we can merged it. However, I've noticed that our config runs all the files through the linter instead of staged files only. That makes hooks a bit slow.

To my understanding the issues is caused by two things:

  1. Transpilation required for .ts files
  2. lint:js command runs with . as param.

My suggestion is:

  1. Update lint-stages.config.js as per docs
'**/*.ts?(x)': () => 'tsc -p tsconfig.json --noEmit',
  1. Update lint staged command for js/jsx files to "npx eslint" rather than npm run lint:js.

It works fine for js files, but I wasn't able to test it for ts files (somehow I didn't find any of them in this branch).
I also not sure if it will work for ts files when linting all of them with npm run lint:js.

Anyway, it's fine to ship as is and solve the issues in its own PR.

Unfortunately, we can't really test the hooks for TypeScript until we merge some of those PRs 🙂

Proposed Solution

I've attached a patch that I think will solve the issue, but I haven't tried it. You can apply the patch by downloading it, unzipping the file, cd <wcpay_repo> and git am <path_to_pach_file>.

lint-staged-proposed-fix.patch.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    category: devopsFeatures and tools supporting dev process.focus: devopsRelease processes, monitoring, automations, dev tools, CI/CD pipelinegood first issueThe issue is a good candidate for the first community contribution/for a newcomer to the team.size: smallThe issue is sized small.type: technical debtThis issue/PR represents/solves the technical debt of the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions