Code Monkey home page Code Monkey logo

Comments (5)

okonet avatar okonet commented on June 13, 2024

I really like it! Do you want to create a PR for that? @iiroj wdyt?

from lint-staged.

iiroj avatar iiroj commented on June 13, 2024

Is the functionality essentially the same as creating a separate Node.js script file, and having that be the linter? What benefit is there for defining it directly in the config?

It sounds doable, but is a separate pipeline to the existing thing being based on spawning processes with execa.

from lint-staged.

iiroj avatar iiroj commented on June 13, 2024

To answer myself: one benefit is that file names would be passed directly so there's less need for escaping etc.

from lint-staged.

iiroj avatar iiroj commented on June 13, 2024

This might be a good use of node:worker_threads so that we can run them in parallel and capture console output similar to execa.

from lint-staged.

iiroj avatar iiroj commented on June 13, 2024

Since we execute the current "function config" functions before running actual tasks and also validate the output to be string | string[], the only way to handle this in a backwards-compatible way would be to return more functions:

// lint-staged.config.js
export default {
  "*.js": (stagedFiles) => {
    return () => lintJsFiles(stagedFiles)
  }
}

the syntax of the returned functions could be:

type TaskFunction = (stagedMatchedFiles: string[]) => Promise<void>

but since they're returned from inside a config function, one could of course handle the matched filenames in there as well.

what do you think?

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.