Skip to content

Commit 3fd6393

Browse files
jfmengelssindresorhus
authored andcommitted
Use new ESLint rule format (fixes #43) (#47)
1 parent f0249e0 commit 3fd6393

File tree

7 files changed

+48
-11
lines changed

7 files changed

+48
-11
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@
5151
"devDependencies": {
5252
"ava": "*",
5353
"coveralls": "^2.11.9",
54-
"eslint": "^2.7.0",
54+
"eslint": "^3.5.0",
5555
"eslint-ava-rule-tester": "^0.1.1",
5656
"nyc": "^6.4.0",
5757
"pify": "^2.3.0",
5858
"xo": "*"
5959
},
6060
"peerDependencies": {
61-
"eslint": ">=2"
61+
"eslint": ">=3"
6262
},
6363
"xo": {
6464
"esnext": true

rules/catch-error-name.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function isLintablePromiseCatch(node) {
2323
return arg0.type === 'FunctionExpression' || arg0.type === 'ArrowFunctionExpression';
2424
}
2525

26-
module.exports = function (context) {
26+
const create = context => {
2727
const opts = context.options[0];
2828
const name = (opts && opts.name) || 'err';
2929
const stack = [];
@@ -66,11 +66,18 @@ module.exports = function (context) {
6666
};
6767
};
6868

69-
module.exports.schema = [{
69+
const schema = [{
7070
type: 'object',
7171
properties: {
7272
name: {
7373
type: 'string'
7474
}
7575
}
7676
}];
77+
78+
module.exports = {
79+
create,
80+
meta: {
81+
schema
82+
}
83+
};

rules/explicit-length-check.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,15 @@ function checkExpression(context, node) {
2323
}
2424
}
2525

26-
module.exports = context => {
26+
const create = context => {
2727
return {
2828
IfStatement: node => {
2929
checkExpression(context, node.test);
3030
}
3131
};
3232
};
33+
34+
module.exports = {
35+
create,
36+
meta: {}
37+
};

rules/filename-case.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function splitFilename(filename) {
6666
};
6767
}
6868

69-
module.exports = context => {
69+
const create = context => {
7070
const chosenCase = cases[context.options[0].case || 'camelCase'];
7171
const filenameWithExt = context.getFilename();
7272

@@ -92,7 +92,7 @@ module.exports = context => {
9292
};
9393
};
9494

95-
module.exports.schema = [{
95+
const schema = [{
9696
type: 'object',
9797
properties: {
9898
case: {
@@ -105,3 +105,10 @@ module.exports.schema = [{
105105
}
106106
}
107107
}];
108+
109+
module.exports = {
110+
create,
111+
meta: {
112+
schema
113+
}
114+
};

rules/no-abusive-eslint-disable.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const disableRegex = /^eslint-disable(-next-line|-line)?($|(\s+([\w-]+))?)/;
44

5-
module.exports = context => ({
5+
const create = context => ({
66
Program: node => {
77
node.comments.forEach(comment => {
88
const value = comment.value.trim();
@@ -18,11 +18,16 @@ module.exports = context => ({
1818
line: 0,
1919
column: 0
2020
},
21-
// So specify it in the message
21+
// So specify the location in the message
2222
message: 'Specify the rules you want to disable at line {{line}}:{{column}}',
2323
data: comment.loc.start
2424
});
2525
}
2626
});
2727
}
2828
});
29+
30+
module.exports = {
31+
create,
32+
meta: {}
33+
};

rules/no-process-exit.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
2-
module.exports = context => {
2+
3+
const create = context => {
34
const startsWithHashBang = context.getSourceCode().lines[0].indexOf('#!') === 0;
45

56
if (startsWithHashBang) {
@@ -33,3 +34,8 @@ module.exports = context => {
3334
}
3435
};
3536
};
37+
38+
module.exports = {
39+
create,
40+
meta: {}
41+
};

rules/throw-new-error.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const errorTypes = [
1010
'URIError'
1111
];
1212

13-
module.exports = context => ({
13+
const create = context => ({
1414
ThrowStatement: node => {
1515
const arg = node.argument;
1616
const error = arg.callee;
@@ -24,3 +24,10 @@ module.exports = context => ({
2424
}
2525
}
2626
});
27+
28+
module.exports = {
29+
create,
30+
meta: {
31+
fixable: 'code'
32+
}
33+
};

0 commit comments

Comments
 (0)