Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diff-cleaner

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff-cleaner

De-noisify git diffs.

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

diff-cleaner

De-noisify git diffs.

npm version

Features

Reading through git diffs should be a straightforward experience. Unfortunately, meaningless differences in trailing whitespace and end-of-file newlines clutters up diffs. diff-cleaner removes this noise.

  • Adds a git pre-commit hook which checks for trailing whitespace and an EOF newline, failing the commit as-necessary with a message to use npm run trim
  • Provides an npm run trim command which fixes the errors found in the pre-commit hook

Usage

Get started

  • npm install --save-dev diff-cleaner
  • npm install --save-dev husky
  • Add the following to your gulpfile.js:
require('diff-cleaner/precommit.js');
require('diff-cleaner/trim.js');
  • Add the following to your package.json scripts:
"precommit": "gulp precommit",
"trim": "gulp trim"

Options

Check out config.js for full options. A selection are shown below.

To change e.g. the included filetypes to just html and css, add the following to your gulpfile.js:

require('diff-cleaner').config.filetypes = '(html|css)';
  • filetypes. The file extensions that will be linted and updated. Must be in the form e.g. '(js|py|txt)'. Defaults to '(ts|js|css|scss|html|json)'.
  • logErrors. When truthy, log the full issue report on precommit linting errors.
  • specificGitignore. Use a .gitignore other than in the root directory.
  • customGlobs. Any custom globs to consider during precommit and trim.

Notes

Overriding pre-commit hook

To override the pre-commit hook, use git commit --no-verify.

Standardizing newlines

See dealing with line endings for how to standardize line endings using a .gitattributes file.

VS Code

Add "files.trimTrailingWhitespace": true to your user settings document to strip trailing whitespace automatically.

FAQs

Package last updated on 20 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc