diff --git a/lib/rules/disallow-const-outside-module-scope.js b/lib/rules/disallow-const-outside-module-scope.js index c25d93d..fb91f83 100644 --- a/lib/rules/disallow-const-outside-module-scope.js +++ b/lib/rules/disallow-const-outside-module-scope.js @@ -1,4 +1,5 @@ var assert = require('assert'); +var cst = require('cst'); module.exports = function() { }; @@ -35,5 +36,11 @@ module.exports.prototype = { } } }); + }, + + _fix: function(_, error) { + var element = error.element.firstChild; + var token = new cst.Token(element.type, element.getSourceCode().replace('const', 'let')); + element.parentElement.replaceChild(token, element); } };