We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 372fc54 commit 60de719Copy full SHA for 60de719
lib/rules/no-const-outside-module-scope.js
@@ -22,7 +22,18 @@ module.exports = {
22
23
context.report({
24
node: node,
25
- message: '`const` should only be used in module scope (not inside functions/blocks).'
+ message: '`const` should only be used in module scope (not inside functions/blocks).',
26
+ fix(fixer) {
27
+ // Get node's text content
28
+ let nodeSourceCode = context.getSourceCode();
29
+ let nodeText = nodeSourceCode.getText(node);
30
+
31
+ // Transform the `const` to a `let` declaration
32
+ let fixed = nodeText.replace('const', 'let')
33
34
+ // // Apply and return the fix
35
+ return fixer.replaceText(node, fixed);
36
+ }
37
});
38
}
39
};
0 commit comments