Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wisniewski94/eslint-plugin-no-comments
Prevents leaving comment blocks in the file. This plugin will ignore all comments starting from string global or eslint in order to keep eslint local settings safe.
https://github.com/wisniewski94/eslint-plugin-no-comments
eslint eslint-plugin javascript
Last synced: 3 months ago
JSON representation
Prevents leaving comment blocks in the file. This plugin will ignore all comments starting from string global or eslint in order to keep eslint local settings safe.
- Host: GitHub
- URL: https://github.com/wisniewski94/eslint-plugin-no-comments
- Owner: wisniewski94
- License: mit
- Created: 2021-08-26T18:04:45.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-08T13:53:51.000Z (over 1 year ago)
- Last Synced: 2024-07-01T14:19:28.161Z (4 months ago)
- Topics: eslint, eslint-plugin, javascript
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
- awesome-eslint - no-comments - Prevents leaking comments into production if bundler is not used and stops developers from commenting out old lines of code. (Plugins / Practices and Specific ES Features)
README
# eslint-plugin-no-comments
Prevents leaving comment blocks in the file. This plugin will ignore all comments starting from string `global` or `eslint` in order to keep eslint local settings safe.
## Why?
If the source code is not being processed by a bundler or any other tool, there is a risk of shipping some notes, old code blocks or sensitive information to production environment.
## Installation
```sh
npm install eslint-plugin-no-comments --save-dev
```## Configuration
```js
// eslintrc.js
{
"plugins": ["no-comments"],
"rules": {
"no-comments/disallowComments": [
"error",
{
"allow": ["TODO", "FIXME", "NOTE", "DEBUG"],
}
]
}
}
```### [How to add JSDoc to allowlist?](https://github.com/wisniewski94/eslint-plugin-no-comments/issues/7)
If allow is not specified, all comments will be disallowed except for `eslint` and `global` comments.
## Rule details
### Fail
```js
// import {Text} from 'react-native'
const {Text, Image} = require('react-native')
``````js
/* var price1 = 5;
* var price2 = 6;
var total = price1 + price2;
*/
``````js
const {Text, Image} = require('cool-package') // TO-DO fix vulnerability
```### Pass
```js
/* global MyClass */
// eslint-disable-next-line no-unused-varsvar price1 = 5;
var price2 = 6;
var total = price1 + price2;
```if allow is specified, e.g.: `["TODO", "FIXME", "NOTE", "DEBUG"]`
```js
const {Text, Image} = require('cool-package') // TODO fix vulnerability
```## Author
- [Wiktor Wiśniewski](https://wiktorwisniewski.dev)## MIT License