Skip to content

Commit

Permalink
Add eslint-comments plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze committed Mar 22, 2017
1 parent 3d20212 commit c847665
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 2 deletions.
1 change: 1 addition & 0 deletions __tests__/base.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('base config', () => {

it('specifies plugins', () => {
const expected = [
'eslint-comments',
'import',
'wyze',
]
Expand Down
1 change: 1 addition & 0 deletions base.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = {
sourceType: 'module',
},
plugins: [
'eslint-comments',
'import',
'wyze',
],
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"babel-eslint": "^7.1.0",
"eslint": "^3.18.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-eslint-comments": "^1.0.0",
"eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
Expand All @@ -56,6 +57,7 @@
"changelog-maker": "^2.2.5",
"eslint": "^3.18.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-eslint-comments": "^1.0.0",
"eslint-plugin-flowtype": "^2.30.4",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Use `yarn add --dev <packages>` where `<packages>` are as follows:
### React/Preact

```
eslint eslint-config-airbnb eslint-config-wyze eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-wyze
eslint eslint-config-airbnb eslint-config-wyze eslint-plugin-eslint-comments eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-wyze
```

### Non-React

```
eslint eslint-config-airbnb eslint-config-wyze eslint-plugin-import eslint-plugin-wyze
eslint eslint-config-airbnb eslint-config-wyze eslint-plugin-eslint-comments eslint-plugin-import eslint-plugin-wyze
```

### Flow
Expand Down
12 changes: 12 additions & 0 deletions rules/__tests__/eslint-comments.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { rules } from '../eslint-comments'

describe('eslint-comments rules', () => {
it('contains only eslint-comments rules', () => {
const keys = Object.keys(rules)
const expected = Array.from(
keys, () => expect.stringMatching(/^eslint-comments\/.+$/),
)

expect(keys).toEqual(expected)
})
})
19 changes: 19 additions & 0 deletions rules/eslint-comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
rules: {
// requires a `eslint-enable` comment for every `eslint-disable` comment
// https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/disable-enable-pair.md
'eslint-comments/disable-enable-pair': 'warn',
// disallows duplicate `eslint-disable` comments
// https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-duplicate-disable.md
'eslint-comments/no-duplicate-disable': 'error',
// disallows `eslint-disable` comments without rule names
// https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unlimited-disable.md
'eslint-comments/no-unlimited-disable': 'error',
// disallows unused `eslint-disable` comments
// https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unused-disable.md
'eslint-comments/no-unused-disable': 'error',
// disallows unused `eslint-enable` comments
// https://github.com/mysticatea/eslint-plugin-eslint-comments/blob/master/docs/rules/no-unused-enable.md
'eslint-comments/no-unused-enable': 'error',
},
}
6 changes: 6 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,12 @@ eslint-module-utils@^2.0.0:
debug "2.2.0"
pkg-dir "^1.0.0"

eslint-plugin-eslint-comments@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-1.0.0.tgz#e36743d1b2c9389e6d484846a5b46d9ade36d69e"
dependencies:
escape-string-regexp "^1.0.5"

eslint-plugin-flowtype@^2.30.4:
version "2.30.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.4.tgz#771d6bb4578ab8598e9c58018fea2e1a22946249"
Expand Down

0 comments on commit c847665

Please sign in to comment.