
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
grunt-trimtrailingspaces
Advanced tools
Trim trailing spaces from each line of the selected files
This plugin requires Grunt ~0.4 and Node.js
version to be 4.2.0, which is the 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": "^2.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.
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
Please refer to a GitHub blog post on how to create somewhat perfect pull request.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
v2.1.0 (2016-02-15)
4.2.0 (LTS)v2.0.0 (2015-10-20)
v1.1.0 (2014-11-29)
v1.0.0 (2014-11-10)
v0.4.0 (2013-12-20)
v0.3.2 (2013-11-07)
filter in examplesv0.3.1 (2013-08-28)
0.10 from 0.8v0.3.0 (2013-07-31)
v0.2.1 (2013-07-25)
string.js dependency and use grunt.file APIv0.2.0 (2013-07-11)
src files arrayv0.1.0 (2013-07-05)
Copyright (c) Juga Paazmaya paazmaya@yahoo.com
Licensed under the MIT license.
FAQs
Trim trailing spaces from each line of the selected files
The npm package grunt-trimtrailingspaces receives a total of 79 weekly downloads. As such, grunt-trimtrailingspaces popularity was classified as not popular.
We found that grunt-trimtrailingspaces demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.