@sasjs/lint
Version:
Linting and formatting for SAS code
32 lines • 1.87 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.lintFile = void 0;
const file_1 = require("@sasjs/utils/file");
const utils_1 = require("../utils");
const shared_1 = require("./shared");
/**
* Analyses and produces a set of diagnostics for the file at the given path.
* @param {string} filePath - the path to the file to be linted.
* @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
* @returns {Promise<Diagnostic[]>} array of diagnostic objects, each containing a warning, line number and column number.
*/
const lintFile = (filePath, configuration) => __awaiter(void 0, void 0, void 0, function* () {
if (yield (0, utils_1.isIgnored)(filePath, configuration))
return [];
const config = configuration || (yield (0, utils_1.getLintConfig)());
const text = yield (0, file_1.readFile)(filePath);
const fileDiagnostics = (0, shared_1.processFile)(filePath, config);
const textDiagnostics = (0, shared_1.processText)(text, config);
return [...fileDiagnostics, ...textDiagnostics];
});
exports.lintFile = lintFile;
//# sourceMappingURL=lintFile.js.map