Sha256: db73da06362963b64bb6e04c0b3a37b0ca0d1ebc2b2bd7bfdd6aa6a7a83b5eb1
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
/** * @fileoverview Require file to end with single newline. * @author Nodeca Team <https://github.com/nodeca> */ "use strict"; //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ module.exports = function(context) { //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { "Program": function checkBadEOF(node) { // Get the whole source code, not for node only. var src = context.getSource(), location = {column: 1}; if (src.length === 0) { return; } if (src[src.length - 1] !== "\n") { // file is not newline-terminated location.line = src.split(/\n/g).length; context.report({ node: node, loc: location, message: "Newline required at end of file but not found.", fix: function(fixer) { return fixer.insertTextAfterRange([0, src.length], "\n"); } }); } } }; }; module.exports.schema = [];
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
eslint_node_modules-1.6.0.1 | vendor/node_modules/eslint/lib/rules/eol-last.js |
eslint_node_modules-1.6.0 | vendor/node_modules/eslint/lib/rules/eol-last.js |