A Grunt task for checking spaces in files
A Grunt task for checking spaces in files depending on the node module lintspaces.
If you're looking for a gulpjs task to validate your files, take a look at this one:
This grunt task is just a wrapper for the node module called lintspaces. If you have any issues or feature requests, please consider if this may belongs to the node module its self.
From the same directory as your project's Gruntfile and package.json, install this plugin with the following command:
npm install grunt-lintspaces --save-dev
Once that's done, add this line to your project's Gruntfile:
grunt.js file add a section named
lintspaces. This section
specifies the tasks. Each task takes sources and options as parameters.
This sets the path of the files to be checked.
Tests for newlines at the end of all files. Default value is
NEWLINE, when a missing a newline at the end of the file.
NEWLINE_AMOUNT, when found unexpected additional newlines at the end of a file.
Test for the maximum amount of newlines between code blocks. Default value is
false. To enable this validation a number larger than
0 is expected.
NEWLINE_MAXIMUM, when maximum amount of newlines exceeded between code blocks.
Tests for useless whitespaces (trailing whitespaces) at each lineending of all
files. Default value is
TRAILINGSPACES, when unexpected trailing spaces were found.
Note: If you like to to skip empty lines from reporting (for whatever
reason), use the option
trailingspacesSkipBlanks and set them to
Tests for correct indentation using tabs or spaces. Default value is
To enable indentation check use the value
INDENTATION_TABS, when spaces are used instead of tabs.
If the indentation option is set to
'spaces', there is also the possibility
to set the amount of spaces per indentation using the
spaces option. Default
indentation: 'spaces'spaces: 2
INDENTATION_SPACES, when tabs are used instead of spaces.
INDENTATION_SPACES_AMOUNT, when spaces are used but the amound is not as expected.
indentationGuess option tries to guess the indention of a line
depending on previous lines. The report of this option can be incorrect,
because the correct indentation depends on the actual programming language
and styleguide of the certain file. The default value is
false - disabled.
This feature follows the following rules: The indentation of the current line is correct when:
Lintspaces fails with incorrect indentation errors when files contain Byte Order
Marks (BOM). If you don't want to give false positives for inconsistent tabs or
spaces, set the
allowsBOM option to
true. The default value is
false - disabled.
ignores option when special lines such as comments should be ignored.
Provide an array of regular expressions to the
There are some build in ignores for comments which you can apply by using these strings:
(build in strings and userdefined regular expressions are mixable in the
Feel free to contribute some new regular expressions as build in!
Note: Trailing spaces are not ignored by default, because they are always
evil!! If you still want to ignore them use the
option and set them to
It's possible to overwrite the default and given options by setting up a path
to an external editorconfig file by using the
editorconfig option. For a basic
configuration of a .editorconfig file check out the
The following .editorconfig values are supported:
insert_final_newlinewill check if a newline is set
indent_stylewill check the indentation
indent_sizewill check the amount of spaces
trim_trailing_whitespacewill check for useless whitespaces
This is a specific option related to this task. When active all valid processed
files will be logged. Default value is
This is a specific option related to this task. By default the type of each
message is shown by the color of the message text. To show at the beginning of
the message set this to
true. Default value is
This is a specific option related to this task. When active all reporting codes
will appear at the end of each message. Default value is
grunt to lint and run the tests.