Giter VIP home page Giter VIP logo

Comments (4)

trusktr avatar trusktr commented on June 16, 2024

Is lint-staged not matching against deleted files?

Yep, that's the problem. lint-staged is not matching against files that have been deleted. I verified by making a modification to another file in src/, and then it runs the scripts for src/**/*.

This is not good because it means if I delete files in src/ they lint-staged is silently failing to run needed scripts (f.e. a build script needs to update dist/ based on src/).

This can lead to unexpectedly publishing versions of packages on npm with dist/ folder in incorrect state (and most people are probably not going to test deletion-only commits to realize lint-staged is ignoring them).

from lint-staged.

trusktr avatar trusktr commented on June 16, 2024

For now the workaround is I found some other file I could make a change to (without deleting). Now I just need to try and remember this each time I commit; the only reason I discovered it was because I was investigating why the build wasn't outputting certain files, then I decided to test the commit to ensure a version update would include files and discovered the additional lint-staged issue (first my build was discluding some files).

from lint-staged.

iiroj avatar iiroj commented on June 16, 2024

You can try overriding the default --diff-filter option to also include deleted files.

EDIT: from the readme:

--diff-filter: By default only files that are added, copied, modified, or renamed are included. Use this flag to override the default ACMR value with something else: added (A), copied (C), deleted (D), modified (M), renamed (R), type changed (T), unmerged (U), unknown (X), or pairing broken (B). See also the git diff docs for --diff-filter.

from lint-staged.

iiroj avatar iiroj commented on June 16, 2024

We don't include deleted files by default because the most common linters ESLint and Prettier don't really work when supplied paths that don't exist anymore.

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.