diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/lib/main.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/lib/main.js index 31247ef0ee9c..9d2c96648f1b 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/lib/main.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/lib/main.js @@ -49,8 +49,23 @@ function main(context) { context.report({ 'node': null, 'message': 'Empty comments are not allowed', - 'loc': comment.loc + 'loc': comment.loc, + 'fix': fix }); + + /** + * Fixes the lint error. + * + * @private + * @param {Function} fixer - ESLint fixer + * @returns {(Object|null)} fix or null + */ + function fix( fixer ) { + if ( comment.type === 'Block' || comment.type === 'Line' ) { + return fixer.removeRange( comment.range ); + } + return null; + } } /** @@ -98,11 +113,12 @@ function main(context) { rule = { 'meta': { + 'type': 'layout', 'docs': { 'description': 'enforce that comments are not empty' }, - 'schema': [], - 'fixable': null + 'fixable': 'code', + 'schema': [] }, 'create': main }; diff --git a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/test/fixtures/invalid.js b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/test/fixtures/invalid.js index 6598a329ac6e..b3f04f444444 100644 --- a/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/test/fixtures/invalid.js +++ b/lib/node_modules/@stdlib/_tools/eslint/rules/no-empty-comments/test/fixtures/invalid.js @@ -33,7 +33,13 @@ test = { 'message': 'Empty comments are not allowed', 'type': null } - ] + ], + 'output': [ + 'function pow2( x ) {', + ' ', + ' return x*x;', + '}' + ].join( '\n' ) }; invalid.push( test ); @@ -55,7 +61,19 @@ test = { 'message': 'Empty comments are not allowed', 'type': null } - ] + ], + 'output': [ + 'function fizzBuzz() {', + ' var out;', + ' var i;', + '', + ' for ( i = 1; i <= 100; i++ ) {', + ' out = ( i % 5 === 0 ) ? "Buzz" : ( i % 3 === 0 ) ? "Fizz" : i;', + ' ', + ' console.log( out );', + ' }', + '}' + ].join( '\n' ) }; invalid.push( test ); @@ -81,7 +99,19 @@ test = { 'message': 'Empty comments are not allowed', 'type': null } - ] + ], + 'output': [ + 'function makePerson() {', + ' var person = {', + ' ', + ' \'title\': \'engineer\',', + '', + ' ', + ' \'name\': \'Susan\'', + ' };', + ' return person;', + '}' + ].join( '\n' ) }; invalid.push( test ); @@ -102,7 +132,18 @@ test = { 'message': 'Empty comments are not allowed', 'type': null } - ] + ], + 'output': [ + 'function square( x ) {', + ' var out;', + ' var x;', + '', + ' out = x*x;', + ' ', + '', + ' return out;', + '}' + ].join( '\n' ) }; invalid.push( test );