UNPKG

@sasjs/lint

Version:

Linting and formatting for SAS code

60 lines (52 loc) 1.76 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const lint_1 = require("./lint"); const path_1 = __importDefault(require("path")); /** * Example which tests a piece of text with all known violations. */ const text = `/** @file @brief Returns an unused libref @details Use as follows: libname mclib0 (work); libname mclib1 (work); libname mclib2 (work); %let libref=%mf_getuniquelibref({SAS001}); %put &=libref; which returns: > mclib3 @param prefix= first part of libref. Remember that librefs can only be 8 characters, so a 7 letter prefix would mean that maxtries should be 10. @param maxtries= the last part of the libref. Provide an integer value. @version 9.2 @author Allan Bowe **/ %macro mf_getuniquelibref(prefix=mclib,maxtries=1000); %local x libref; %let x={SAS002}; %do x=0 %to &maxtries; %if %sysfunc(libref(&prefix&x)) ne 0 %then %do; %let libref=&prefix&x; %let rc=%sysfunc(libname(&libref,%sysfunc(pathname(work)))); %if &rc %then %put %sysfunc(sysmsg()); &prefix&x %*put &sysmacroname: Libref &libref assigned as WORK and returned; %return; %end; %end; %put unable to find available libref in range &prefix.0-&maxtries; %mend; `; (0, lint_1.lintText)(text).then((diagnostics) => { console.log('Text lint results:'); console.table(diagnostics); }); (0, lint_1.lintFile)(path_1.default.join(__dirname, 'Example File.sas')).then((diagnostics) => { console.log('File lint results:'); console.table(diagnostics); }); //# sourceMappingURL=lintExample.js.map