Skip to content

Commit 372fc54

Browse files
author
Joao
committed
Add meta object containing fixable options
1 parent 7ee3feb commit 372fc54

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed
Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
'use strict';
22

3-
module.exports = function(context) {
4-
return {
5-
VariableDeclaration: function(node) {
6-
if (node.kind !== 'const') {
7-
return;
8-
}
3+
module.exports = {
4+
meta: { fixable: 'code', schema: [] },
5+
create(context) {
6+
return {
7+
VariableDeclaration: function(node) {
8+
if (node.kind !== 'const') {
9+
return;
10+
}
911

10-
if (node.parent && node.parent.type === 'Program') {
11-
// Declaration is in root of module.
12-
return;
13-
}
12+
if (node.parent && node.parent.type === 'Program') {
13+
// Declaration is in root of module.
14+
return;
15+
}
1416

15-
if (node.parent && node.parent.type === 'ExportNamedDeclaration' &&
16-
node.parent.parent && node.parent.parent.type === 'Program') {
17-
// Declaration is a `export const foo = 'asdf'` in root of the module.
18-
return;
19-
}
17+
if (node.parent && node.parent.type === 'ExportNamedDeclaration' &&
18+
node.parent.parent && node.parent.parent.type === 'Program') {
19+
// Declaration is a `export const foo = 'asdf'` in root of the module.
20+
return;
21+
}
2022

21-
context.report({
22-
node: node,
23-
message: '`const` should only be used in module scope (not inside functions/blocks).'
24-
});
25-
}
26-
};
23+
context.report({
24+
node: node,
25+
message: '`const` should only be used in module scope (not inside functions/blocks).'
26+
});
27+
}
28+
};
29+
}
2730
};
2831

2932
module.exports.schema = []; // no options

0 commit comments

Comments
 (0)