npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-trimtrailingspaces

v6.0.0

Published

Trim trailing spaces from each line of the selected files

Downloads

295

Readme

grunt-trimtrailingspaces

Trim trailing spaces from each line of the selected files

Build Status Maintainability

Built with Grunt

Getting Started

This plugin requires Grunt ^1.1 and Node.js version to be minimum of 14.15.0, which is the active Long Term Support (LTS) version.

Add this to your project's Gruntfile.js configuration:

grunt.loadNpmTasks('grunt-trimtrailingspaces');

Then add grunt-trimtrailingspaces to your "package.json" dependencies. This can be done with:

npm install grunt-trimtrailingspaces --save-dev

Or by manually editing the package.json file by adding the following line inside devDependencies object:

  "grunt-trimtrailingspaces": "^5.0.0"

Later on it would be possible to install the plugin with the command npm install

It can be updated with the command npm update, in case there is a newer version in the npm registry.

The name to use in your own task definitions is trimtrailingspaces.

Documentation

Add an entry to your Gruntfile.js, within the initConfig object, which will define the files of which will the trailing spaces to be removed.

By using the src property for selecting files to be processed, they are replaced by the ones processed.

By setting the failIfTrimmed option to true, the grunt task will fail after trimming all files if any whitespace was removed. This is very useful for running trimtrailingspaces as a pre-commit task (in combination with grunt-githooks), because it will prevent the commit from going through which would not include the trimming changes.

The examples below are using the built-in custom filter property.

  ...

  trimtrailingspaces: {
    main: {
      src: ['public_html/js/**/*.js'],
      options: {
        filter: 'isFile',
        encoding: 'utf8',
        failIfTrimmed: false
      }
    }
  }

  ...

It is possible to save the processed files to a different location by using the files property, as shown below. The destination (key) should be a directory path in which the src files (array value) are stored. No trailing slash needed.

Please note that this method will create a flat directory of the result.

  ...

  trimtrailingspaces: {
    main: {
      files: {
        'public_html/js/trimmed': ['public_html/js/**/*.js']
      },
      filter: 'isFile',
      encoding: 'utf8'
    }
  }

  ...

For further information on how files are matched, please see the documentation of the minimatch package, as it is used underneath Grunt.

To run it:

grunt trimtrailingspaces

Contributing

"A Beginner's Guide to Open Source: The Best Advice for Making your First Contribution".

Also there is a blog post about "45 Github Issues Dos and Don’ts".

Linting is done with ESLint and can be executed with npm run lint. There should be no errors appearing after any JavaScript file changes.

Version history

Changes happening across different versions and upcoming changes are tracked in the CHANGELOG.md file.

License

Copyright (c) Juga Paazmaya [email protected]

Licensed under the MIT license.