canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS and CSS.
60 lines (48 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _js = require('./linters/js/');
var _scss = require('./linters/scss/');
/**
* @typedef lintText~message
* @property {string} ruleId
* @property {number} severity
* @property {string} message
* @property {number} line
* @property {number} column
* @property {string} nodeType
* @property {string} source
*/
/**
* @typedef lintText~result
* @property {string} filePath
* @property {lintFiles~message[]} messages
* @property {number} errorCount
* @property {number} warningCount
*/
/**
* @typedef lintText~options
* @property {string} linter (supported linters: 'js', 'scss').
* @property {string} filePath (optional) (default: '<text>')
*/
/**
* @param {string} text
* @param {lintText~options} options
* @return {lintText~result}
*/
exports.default = (text, options) => {
let result;
if (options.linter === 'js') {
result = (0, _js.lintText)(text);
} else if (options.linter === 'scss') {
result = (0, _scss.lintText)(text);
} else {
throw new Error('Unknown linter "' + options.linter + '".');
}
if (options.filePath) {
result.filePath = options.filePath;
}
return result;
};
//# sourceMappingURL=lintText.js.map