I have a legacy codebase without eslint/prettier. I want to introduce formatting on pre-commit hooks. Lint staged will let you run prettier for only changed files. Is it possible to only run the prettier just for changed lines? Like IntelliJ's inbuild formatting allows for only VCS changed text formatting.
Prettier: Run for only the changed lines of the file
6k views Asked by sreejith At
2
There are 2 answers
1
AsankaJ
On
Hope you have solved the issue by now. For others, A fix for this was introduced in the August 2020 (version 1.49) update. Check out this link for more info. link
Related Questions in JAVASCRIPT
- Using Puppeteer to scrape a public API only when the data changes
- inline SVG text (js)
- An array of images and a for loop display the buttons. How to assign each button to open its own block by name?
- Storing the preferred font-size in localStorage
- Simple movie API request not showing up in the console log
- Authenticate Flask rest API
- Deploying sveltekit app with gunjs on vercel throws cannot find module './lib/text-encoding'
- How to request administrator rights?
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- In Datatables, start value resets to 0, when column sorting
- How do I link two models in mongoose?
- parameter values only being sent to certain columns in google sheet?
- Run main several times of wasm in browser
- Variable inside a Variable, not updating
Related Questions in ESLINT
- Eslint rule to prevent space around a typescript generic
- multiple file components and false positives with eslint
- ESLint rules for var / let and/or uninitialised variables
- Unknown word (CssSyntaxError) in JSX File (react js)
- Is it possible to auto-import files with webpack or React so that I don't need to `import` every time
- Is there a way to lint event listener types in JS/TS?
- Why does typescript infer the type of SVG imports as "any" in NextJs 14
- Error: Failed to load plugin 'unicorn' declared in '.eslintrc.js': Cannot find module 'eslint/use-at-your-own-risk'
- ESlint Plugin That Enforces Function Parameter Names
- ESLint rule for preventing exports that match a pattern
- @typescript-eslint/no-unsafe-assignment with conf library
- VSCode eslint and nx rules not highlighting errors in the code
- SyntaxError: Cannot use import statement outside a module on importing MuiOtpInput
- Deploying v2 cloud functions 'unable to resolve path to module ...'
- Problems migrating ESLint code formatting rules to @stylistic/eslint-plugin
Related Questions in PRETTIER
- Prettier formatting
- prettier formatWithCursor very slowed when use with *.min.js
- How can i solve "loading error module" for Prettier?
- New Line in prettier when more then one attribute and content
- How to use 4 spaces formatting for indentation in VSCode for Volar through Vue - Official extension in .vue files?
- Prettier Format Document
- In VSCode, is there an Angular component.html formatter with an option for spacing the new built-in control flow contents away from the block opening?
- Prettier automatically adds {" "}
- I am creating a custom preprocess for prettier plugin, which rearrange the import order, but it is not working properly
- VS-code prettier extension removing perentheses
- Issue: Replace `··` with `↹`eslintprettier/prettier
- Prettier insert blank line after list item in Markdown file
- Prettier formatter not working for .sol files, but works with .js, .css, etc
- Code formatting not working properly in prettier-eslint
- Prettier code formatter does not work like what I want
Related Questions in LINT-STAGED
- Linting, Formatting in an Nx Monorepo with Husky
- Lint-Staged configuration issues an error in a JavaScript monorepo environment
- What are the possible causes of Lint-staged Chinese garbled characters in Windows shell?
- Lintstaged process is stuck when running rubocop command
- Not all lintstagedrc.json files are found in the rush.js monorepo
- How to ignore a folder in lint-staged?
- How to restore changed file in to git workspace when lint-staged lint error?
- Lint-staged + vitest - running related tests as precommit hook takes too much time
- Husky pre-commit hook not running
- Husky pre-commit hook not ignoring node_modules
- Is it possible to lint only modified part(s) of staged files with the use of lint-staged?
- Explicitly specified file was ignored due to negative glob patterns in lint stage
- Pre-commit Husky doesn't run npx lint-staged
- How to setup lint-staged with turbo monorepo?
- Does Playwright have equivalent functionality to "--findRelatedTests" in Jest?
Related Questions in PRETTIER-ESLINT
- Code formatting not working properly in prettier-eslint
- VSCode Saving causes code to appear on newline and adds double quotes
- Problem when trying to add Prettier's Git Hook: husky install error `install command is deprecated`
- prettier extension not Working in VS_Code...?
- Prettier plugin tailwindcss not working in the visual code
- Node_ Modules/qualifier/standalone. js 418:11
- ESlint --config option not working and still uses the same root file config
- VSCode producing wrong ESLint Prettier error
- Setting up Auto Format on Save easily in VS Code (Visual Studio Code) for Expo React-Native
- Usage of @eslint/config tool with airbnb and prettier plugins
- How do I change eslint styling organization from alphabetical?
- eslint ignores one specific file and doesn't show any warnings or errors
- ERROR: Invalid configuration for file "/Users/hello/Documents/projects/hello_world/.eslintrc.json"
- How to Set Up ESLint, Prettier, and TypeScript in React Native - Initial Configuration
- Prettier formats files specified in .prettierignore
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Not a solution here, but can I ask why do you want to do this?
What you want to do would end up with messy files just like the ones you have now. You will not be adding real value to the codebase.
I assume the problem you are trying to avoid are those gigantic diffs on every merge request. I think is better to make a style / linting MR first and start from there.