UNPKG

eclint

Version:

Validate or fix code that doesn't adhere to EditorConfig settings or infer settings from existing code.

39 lines 1.17 kB
"use strict"; var _ = require("lodash"); var EditorConfigError = require("../editor-config-error"); function resolve(settings) { if (_.isBoolean(settings.trim_trailing_whitespace)) { return settings.trim_trailing_whitespace; } return void (0); } function check(settings, line) { var configSetting = resolve(settings); if (configSetting && !infer(line)) { var error = new EditorConfigError('unexpected trailing whitespace'); error.lineNumber = line.number; error.columnNumber = line.prefix.length + line.string.length + 1; error.rule = 'trim_trailing_whitespace'; error.source = line.text; return error; } } function fix(settings, line) { var configSetting = resolve(settings); if (configSetting) { line.suffix = ''; } return line; } function infer(line) { return !line.suffix || void (0); } var TrimTrailingWhitespaceRule = { check: check, fix: fix, infer: infer, resolve: resolve, type: 'LineRule', }; module.exports = TrimTrailingWhitespaceRule; //# sourceMappingURL=trim_trailing_whitespace.js.map