{"id":16281109,"url":"https://github.com/schorfes/node-lintspaces","last_synced_at":"2025-04-04T15:10:13.323Z","repository":{"id":15659468,"uuid":"18396873","full_name":"schorfES/node-lintspaces","owner":"schorfES","description":"A validator for checking different kinds of whitespaces in your files.","archived":false,"fork":false,"pushed_at":"2024-10-16T16:00:29.000Z","size":3157,"stargazers_count":30,"open_issues_count":5,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-19T00:44:10.351Z","etag":null,"topics":["automation","checker","cli","code-analysis","code-analyzer","editorconfig","javascript","linter","lintspaces","nodejs","quality-assurance","testing","validation","whitespace"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/lintspaces","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"allenhwkim/angularjs-google-maps","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schorfES.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-03T08:54:03.000Z","updated_at":"2024-10-16T16:00:33.000Z","dependencies_parsed_at":"2024-06-08T21:21:28.354Z","dependency_job_id":"1dcdbeb2-75fa-4340-a65a-26d9ce067e06","html_url":"https://github.com/schorfES/node-lintspaces","commit_stats":{"total_commits":445,"total_committers":15,"mean_commits":"29.666666666666668","dds":0.5887640449438203,"last_synced_commit":"a3ee54daa3b9285677df1857120de5de743e0fd4"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schorfES%2Fnode-lintspaces","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schorfES%2Fnode-lintspaces/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schorfES%2Fnode-lintspaces/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schorfES%2Fnode-lintspaces/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schorfES","download_url":"https://codeload.github.com/schorfES/node-lintspaces/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198463,"owners_count":20900080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","checker","cli","code-analysis","code-analyzer","editorconfig","javascript","linter","lintspaces","nodejs","quality-assurance","testing","validation","whitespace"],"created_at":"2024-10-10T19:05:03.294Z","updated_at":"2025-04-04T15:10:13.300Z","avatar_url":"https://github.com/schorfES.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lintspaces\n\nA node module for checking spaces in files.\n\n[![CI Status](https://github.com/schorfES/node-lintspaces/actions/workflows/ci.yml/badge.svg)](https://github.com/schorfES/node-lintspaces/actions)\n[![Coverage Status on Codecov](https://codecov.io/gh/schorfES/node-lintspaces/branch/main/graph/badge.svg)](https://codecov.io/gh/schorfES/node-lintspaces)\n[![Known Vulnerabilities](https://snyk.io/test/github/schorfES/node-lintspaces/badge.svg)](https://snyk.io/test/github/schorfES/node-lintspaces)\n\n### Tasks\n\nIf you're looking for a\n[gruntjs](http://gruntjs.com/) or\n[gulpjs](http://gulpjs.com/)\ntask to validate your files, take a look at these ones:\n\n- [grunt-lintspaces](https://github.com/schorfES/grunt-lintspaces)\n- [gulp-lintspaces](https://github.com/AlbertoElias/gulp-lintspaces) by [AlbertoElias](https://github.com/AlbertoElias)\n\n### CLI\n\nThere is also a [lintspaces CLI](https://github.com/evanshortiss/lintspaces-cli)\navailable written by [evanshortiss](https://github.com/evanshortiss).\n\n## Installation\n\nThis package is available on [npm](https://www.npmjs.org/package/lintspaces)\nas: `lintspaces`\n\n```sh\nnpm install lintspaces\n```\n\n## Usage\n\nTo run the lintspaces validator on one or multiple files take a look at the\nfollowing example:\n\n```javascript\nvar Validator = require('lintspaces');\n\nvar validator = new Validator({\n  /* options */\n});\nvalidator.validate('/path/to/file.ext');\nvalidator.validate('/path/to/other/file.ext');\n\nvar results = validator.getInvalidFiles();\n```\n\nThe response of `getInvalidFiles()` contains an object. Each key of this\nobject is a filepath which contains validation errors.\n\nUnder each filepath there is an other object with at least one key. Those key(s)\nare the specific linenumbers of the file containing an array with errors.\n\nThe following lines shows the structure of the validation result in JSON\nnotation:\n\n```json\n{\n  \"/path/to/file.ext\": {\n    \"3\": [\n      {\n        \"line\": 3,\n        \"code\": \"INDENTATION_TABS\",\n        \"type\": \"warning\",\n        \"message\": \"Unexpected spaces found.\"\n      },\n      {\n        \"line\": 3,\n        \"code\": \"TRAILINGSPACES\",\n        \"type\": \"warning\",\n        \"message\": \"Unexpected trailing spaces found.\"\n      }\n    ],\n    \"12\": [\n      {\n        \"line\": 12,\n        \"code\": \"NEWLINE\",\n        \"type\": \"warning\",\n        \"message\": \"Expected a newline at the end of the file.\"\n      }\n    ]\n  },\n  \"/path/to/other/file.ext\": {\n    \"5\": [\n      {\n        \"line\": 5,\n        \"code\": \"NEWLINE_AMOUNT\",\n        \"type\": \"warning\",\n        \"message\": \"Unexpected additional newlines at the end of the file.\"\n      }\n    ]\n  }\n}\n```\n\n## Options\n\n### newline at end of file option\n\nTests for newlines at the end of all files. Default value is `false`.\n\n```javascript\nnewline: true;\n```\n\n- returns code `NEWLINE`, when missing a newline at the end of the file.\n- returns code `NEWLINE_AMOUNT`, when found unexpected additional newlines\n  at the end of a file.\n- returns type `warning`\n\n### maximum newlines option\n\nTest for the maximum amount of newlines between code blocks. Default value is\n`false`. To enable this validation a number larger than `0` is expected.\n\n```javascript\nnewlineMaximum: 2;\n```\n\n- returns code `NEWLINE_MAXIMUM`, when maximum amount of newlines exceeded\n  between code blocks.\n- returns type `warning`\n\n### endOfLine option\n\nLintspaces fails with incorrect end of line errors when files contain lines that\nend in the wrong sequence. Default value is `false`. To enable end of line checks\nuse any of the following values: `'LF'` or `'CRLF'` or `'CR'`. Values are\ncase-insensitive. Note that this option checks all lines; even \"ignored\" lines.\n\n```javascript\nendOfLine: 'lf';\n```\n\n- returns code `END_OF_LINE`, when the wrong line ending sequence is found.\n- returns type `warning`\n\n### trailingspaces option\n\nTests for useless whitespaces (trailing whitespaces) at each lineending of all\nfiles. Default value is `false`.\n\n```javascript\ntrailingspaces: true;\n```\n\n- returns code `TRAILINGSPACES`, when unexpected trailing spaces were found.\n- returns type `warning`\n\n**Note:** If you like to to skip empty lines from reporting (for whatever\nreason), use the option `trailingspacesSkipBlanks` and set them to `true`.\n\n### indentation options\n\nTests for correct indentation using tabs or spaces. Default value is `false`.\nTo enable indentation check use the value `'tabs'` or `'spaces'`.\n\n```javascript\nindentation: 'tabs';\n```\n\n- returns code `INDENTATION_TABS`, when spaces are used instead of tabs.\n- returns type `warning`\n\nIf the indentation option is set to `'spaces'`, there is also the possibility\nto set the amount of spaces per indentation using the `spaces` option. Default\nvalue is `4`.\n\n```javascript\n  indentation: 'spaces',\n  spaces: 2\n```\n\n- returns code `INDENTATION_SPACES`, when tabs are used instead of spaces.\n- returns code `INDENTATION_SPACES_AMOUNT`, when spaces are used but the\n  amound is not as expected.\n- returns type `warning`\n\n### guess indentation option\n\nThis `indentationGuess` option _tries to guess_ the indention of a line\ndepending on previous lines. The report of this option can be incorrect,\nbecause the _correct_ indentation depends on the actual programming language\nand styleguide of the certain file. The default value is `false` - disabled.\n\nThis feature follows the following rules: _The indentation of the current\nline is correct when:_\n\n- the amount of indentations is equal to the previous or\n- the amount of indentations is less than the previous line or\n- the amount of indentations is one more than the previous line\n- the amount of indentations is zero and the lines length is also zero which\n  is an empty line without trailing whitespaces\n\n```javascript\nindentationGuess: true;\n```\n\n- returns code `NEWLINE_GUESS`\n- returns type `hint`\n\n### allowsBOM option\n\nLintspaces fails with incorrect indentation errors when files contain Byte Order\nMarks (BOM). If you don't want to give false positives for inconsistent tabs or\nspaces, set the `allowsBOM` option to `true`. The default value is\n`false` - disabled.\n\n```javascript\nallowsBOM: true;\n```\n\n### ignores option\n\nUse the `ignores` option when special lines such as comments should be ignored.\nProvide an array of regular expressions to the `ignores` property.\n\n```javascript\nignores: [/\\/\\*[\\s\\S]*?\\*\\//g, /foo bar/g];\n```\n\nThere are some _**build in**_ ignores for comments which you can apply by using\nthese strings:\n\n- 'js-comments'\n- 'c-comments'\n- 'java-comments'\n- 'as-comments'\n- 'xml-comments'\n- 'html-comments'\n- 'python-comments'\n- 'ruby-comments'\n- 'applescript-comments'\n\n_(build in strings and userdefined regular expressions are mixable in the\n`ignores` array)_\n\n```javascript\nignores: ['js-comments', /foo bar/g];\n```\n\n_Feel free to contribute some new regular expressions as build in!_\n\n**Note:** Trailing spaces are not ignored by default, because they are always\nevil!! If you still want to ignore them use the `trailingspacesToIgnores`\noption and set them to `true`.\n\n**Note:** If endOfLine checking is enabled, then all lines (including\n\"ignored\" lines will be checked for appropriate end of line sequences.\n\n### .editorconfig option\n\nIt's possible to overwrite the default and given options by setting up a path\nto an external editorconfig file by using the `editorconfig` option. For a basic\nconfiguration of a _.editorconfig_ file check out the\n[EditorConfig Documentation](http://editorconfig.org/).\n\n```javascript\neditorconfig: '.editorconfig';\n```\n\nThe following .editorconfig values are supported:\n\n- `insert_final_newline` will check if a newline is set\n- `indent_style` will check the indentation\n- `indent_size` will check the amount of spaces\n- `trim_trailing_whitespace` will check for useless whitespaces\n- `end_of_line` will check the end of line character sequence\n\n### .rcconfig option\n\nLoad all settings from a RC configuration file. The configuration can be defined\nin `ini` or `json` format. When setting this option to `true` the\nconfiguration from a `.lintspacesrc` in the\n[RC standards load paths](https://github.com/dominictarr/rc#standards)\nwill be taken.\n\n```javascript\nrcconfig: true;\n```\n\nDefine a custom path to a RC configuration file of your choice by setting the\noption to the desired path.\n\n```javascript\nrcconfig: 'path/to/.customrc';\n```\n\n## Functions\n\nAn instance of the _Lintspaces validator_ has the following methods\n\n### `validate(path)`\n\nThis function runs the check for a given file based on the validator settings.\n\n- **Parameter `path`** is the path to the file as `String`.\n- **Throws** an error when given `path` is not a valid path.\n- **Throws** an error when given `path` is not a file.\n- **Returns** `undefined`.\n\n### `getProcessedFiles()`\n\nThis returns the amount of files processed through the validator.\n\n- **Returns** the amount as `Number`.\n\n### `getInvalidFiles()`\n\nThis returns all invalid lines and messages from processed files.\n\n- **Returns** each key in the returned `Object` represents a path of a\n  processed invalid file. Each value is an other object containing the validation\n  result. For more informations about the returned format see [Usage](#usage).\n\n### `getInvalidLines(path)`\n\nThis returns all invalid lines and messages from the file of the given\n`path`. This is just a shorter version of `getInvalidFiles()[path]`.\n\n- **Parameter `path`** is the file path\n- **Returns** each key in the returned `Object` represents a line from the\n  file of the given path, each value an exeption message of the current line. For\n  more informations about the returned format see [Usage](#usage).\n\n## Contribution\n\nFeel free to contribute. Please run all the tests and validation tasks before\nyou offer a pull request.\n\n### Tests \u0026 validation\n\nRun `npm run test \u0026\u0026 npm run lint` to run the tests and validation tasks.\n\n### Readme\n\nThe readme chapters are located in the _docs_ directory as Markdown. All\nMarkdown files will be concatenated through a grunt task `'docs'`. Call\n`grunt docs` or run it fully by call `grunt` to validate, test and\nupdate the _README.md_.\n\n**Note:** Do not edit the _README.md_ directly, it will be overwritten!\n\n### Contributors\n\n- [ck86](https://github.com/ck86)\n- [itsananderson](https://github.com/itsananderson)\n- [chandlerkent](https://github.com/chandlerkent)\n- [crabbkw](https://github.com/crabbkw)\n- [dpagini](https://github.com/dpagini)\n- [ben-eb](https://github.com/ben-eb) via [grunt-lintspaces](https://github.com/schorfES/grunt-lintspaces/)\n- [yurks](https://github.com/yurks) via [grunt-lintspaces](https://github.com/schorfES/grunt-lintspaces/)\n- [evanshortiss](https://github.com/evanshortiss) via [lintspaces-cli](https://github.com/evanshortiss/lintspaces-cli)\n\n## License\n\n[LICENSE (MIT)](https://github.com/schorfES/node-lintspaces/blob/main/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschorfes%2Fnode-lintspaces","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschorfes%2Fnode-lintspaces","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschorfes%2Fnode-lintspaces/lists"}