@sasjs/lint 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.github/dependabot.yml +1 -1
  2. package/.github/reviewer-lottery.yml +0 -2
  3. package/.github/workflows/assign-reviewer.yml +2 -2
  4. package/format/formatFile.d.ts +1 -1
  5. package/format/formatFile.js +24 -72
  6. package/format/formatFile.js.map +1 -1
  7. package/format/formatFolder.d.ts +1 -1
  8. package/format/formatFolder.js +36 -104
  9. package/format/formatFolder.js.map +1 -1
  10. package/format/formatProject.js +10 -45
  11. package/format/formatProject.js.map +1 -1
  12. package/format/formatText.d.ts +1 -1
  13. package/format/formatText.js +6 -46
  14. package/format/formatText.js.map +1 -1
  15. package/format/index.js +5 -1
  16. package/format/index.js.map +1 -1
  17. package/format/shared.js +16 -16
  18. package/format/shared.js.map +1 -1
  19. package/formatExample.js +10 -6
  20. package/formatExample.js.map +1 -1
  21. package/index.js +5 -1
  22. package/index.js.map +1 -1
  23. package/lint/index.js +5 -1
  24. package/lint/index.js.map +1 -1
  25. package/lint/lintFile.d.ts +1 -1
  26. package/lint/lintFile.js +12 -76
  27. package/lint/lintFile.js.map +1 -1
  28. package/lint/lintFolder.d.ts +1 -1
  29. package/lint/lintFolder.js +23 -114
  30. package/lint/lintFolder.js.map +1 -1
  31. package/lint/lintProject.js +10 -45
  32. package/lint/lintProject.js.map +1 -1
  33. package/lint/lintText.js +6 -40
  34. package/lint/lintText.js.map +1 -1
  35. package/lint/shared.js +24 -45
  36. package/lint/shared.js.map +1 -1
  37. package/lintExample.js +45 -5
  38. package/lintExample.js.map +1 -1
  39. package/package.json +3 -3
  40. package/rules/file/hasDoxygenHeader.js +29 -29
  41. package/rules/file/hasDoxygenHeader.js.map +1 -1
  42. package/rules/file/hasMacroNameInMend.js +59 -59
  43. package/rules/file/hasMacroNameInMend.js.map +1 -1
  44. package/rules/file/hasMacroParentheses.js +25 -27
  45. package/rules/file/hasMacroParentheses.js.map +1 -1
  46. package/rules/file/hasRequiredMacroOptions.js +20 -20
  47. package/rules/file/hasRequiredMacroOptions.js.map +1 -1
  48. package/rules/file/lineEndings.js +27 -27
  49. package/rules/file/lineEndings.js.map +1 -1
  50. package/rules/file/noNestedMacros.js +23 -23
  51. package/rules/file/noNestedMacros.js.map +1 -1
  52. package/rules/file/strictMacroDefinition.js +52 -57
  53. package/rules/file/strictMacroDefinition.js.map +1 -1
  54. package/rules/line/indentationMultiple.js +16 -16
  55. package/rules/line/indentationMultiple.js.map +1 -1
  56. package/rules/line/maxLineLength.js +16 -16
  57. package/rules/line/maxLineLength.js.map +1 -1
  58. package/rules/line/noEncodedPasswords.js +18 -18
  59. package/rules/line/noEncodedPasswords.js.map +1 -1
  60. package/rules/line/noGremlins.js +29 -69
  61. package/rules/line/noGremlins.js.map +1 -1
  62. package/rules/line/noTabs.js +19 -19
  63. package/rules/line/noTabs.js.map +1 -1
  64. package/rules/line/noTrailingSpaces.js +16 -16
  65. package/rules/line/noTrailingSpaces.js.map +1 -1
  66. package/rules/path/lowerCaseFileNames.js +15 -15
  67. package/rules/path/lowerCaseFileNames.js.map +1 -1
  68. package/rules/path/noSpacesInFileNames.js +15 -15
  69. package/rules/path/noSpacesInFileNames.js.map +1 -1
  70. package/types/LintConfig.js +28 -68
  71. package/types/LintConfig.js.map +1 -1
  72. package/types/index.js +5 -1
  73. package/types/index.js.map +1 -1
  74. package/utils/asyncForEach.js +4 -46
  75. package/utils/asyncForEach.js.map +1 -1
  76. package/utils/getColumnNumber.js +3 -3
  77. package/utils/getColumnNumber.js.map +1 -1
  78. package/utils/getDataSectionsDetail.js +16 -38
  79. package/utils/getDataSectionsDetail.js.map +1 -1
  80. package/utils/getHeaderLinesCount.js +8 -30
  81. package/utils/getHeaderLinesCount.js.map +1 -1
  82. package/utils/getIndicesOf.js +3 -4
  83. package/utils/getIndicesOf.js.map +1 -1
  84. package/utils/getLintConfig.js +14 -52
  85. package/utils/getLintConfig.js.map +1 -1
  86. package/utils/getProjectRoot.js +22 -59
  87. package/utils/getProjectRoot.js.map +1 -1
  88. package/utils/index.js +5 -1
  89. package/utils/index.js.map +1 -1
  90. package/utils/isIgnored.d.ts +1 -1
  91. package/utils/isIgnored.js +20 -67
  92. package/utils/isIgnored.js.map +1 -1
  93. package/utils/listSasFiles.js +5 -39
  94. package/utils/listSasFiles.js.map +1 -1
  95. package/utils/parseMacros.d.ts +1 -1
  96. package/utils/parseMacros.js +29 -50
  97. package/utils/parseMacros.js.map +1 -1
  98. package/utils/splitText.js +4 -4
  99. package/utils/splitText.js.map +1 -1
  100. package/utils/trimComments.js +8 -10
  101. package/utils/trimComments.js.map +1 -1
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAwB;AACxB,yCAAsB;AACtB,0CAAuB;AACvB,0CAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,yCAAsB;AACtB,0CAAuB;AACvB,0CAAuB"}
package/lint/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
package/lint/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA0B;AAC1B,6CAA0B;AAC1B,+CAA4B;AAC5B,gDAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lint/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,6CAA0B;AAC1B,+CAA4B;AAC5B,gDAA6B"}
@@ -5,4 +5,4 @@ import { Diagnostic, LintConfig } from '../types';
5
5
  * @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
6
6
  * @returns {Promise<Diagnostic[]>} array of diagnostic objects, each containing a warning, line number and column number.
7
7
  */
8
- export declare const lintFile: (filePath: string, configuration?: LintConfig | undefined) => Promise<Diagnostic[]>;
8
+ export declare const lintFile: (filePath: string, configuration?: LintConfig) => Promise<Diagnostic[]>;
package/lint/lintFile.js CHANGED
@@ -8,89 +8,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
55
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
- to[j] = from[i];
57
- return to;
58
- };
59
11
  Object.defineProperty(exports, "__esModule", { value: true });
60
12
  exports.lintFile = void 0;
61
- var file_1 = require("@sasjs/utils/file");
62
- var utils_1 = require("../utils");
63
- var shared_1 = require("./shared");
13
+ const file_1 = require("@sasjs/utils/file");
14
+ const utils_1 = require("../utils");
15
+ const shared_1 = require("./shared");
64
16
  /**
65
17
  * Analyses and produces a set of diagnostics for the file at the given path.
66
18
  * @param {string} filePath - the path to the file to be linted.
67
19
  * @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
68
20
  * @returns {Promise<Diagnostic[]>} array of diagnostic objects, each containing a warning, line number and column number.
69
21
  */
70
- var lintFile = function (filePath, configuration) { return __awaiter(void 0, void 0, void 0, function () {
71
- var config, _a, text, fileDiagnostics, textDiagnostics;
72
- return __generator(this, function (_b) {
73
- switch (_b.label) {
74
- case 0: return [4 /*yield*/, utils_1.isIgnored(filePath, configuration)];
75
- case 1:
76
- if (_b.sent())
77
- return [2 /*return*/, []];
78
- _a = configuration;
79
- if (_a) return [3 /*break*/, 3];
80
- return [4 /*yield*/, utils_1.getLintConfig()];
81
- case 2:
82
- _a = (_b.sent());
83
- _b.label = 3;
84
- case 3:
85
- config = _a;
86
- return [4 /*yield*/, file_1.readFile(filePath)];
87
- case 4:
88
- text = _b.sent();
89
- fileDiagnostics = shared_1.processFile(filePath, config);
90
- textDiagnostics = shared_1.processText(text, config);
91
- return [2 /*return*/, __spreadArray(__spreadArray([], __read(fileDiagnostics)), __read(textDiagnostics))];
92
- }
93
- });
94
- }); };
22
+ const lintFile = (filePath, configuration) => __awaiter(void 0, void 0, void 0, function* () {
23
+ if (yield (0, utils_1.isIgnored)(filePath, configuration))
24
+ return [];
25
+ const config = configuration || (yield (0, utils_1.getLintConfig)());
26
+ const text = yield (0, file_1.readFile)(filePath);
27
+ const fileDiagnostics = (0, shared_1.processFile)(filePath, config);
28
+ const textDiagnostics = (0, shared_1.processText)(text, config);
29
+ return [...fileDiagnostics, ...textDiagnostics];
30
+ });
95
31
  exports.lintFile = lintFile;
96
32
  //# sourceMappingURL=lintFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lintFile.js","sourceRoot":"","sources":["../../src/lint/lintFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4C;AAE5C,kCAAmD;AACnD,mCAAmD;AAEnD;;;;;GAKG;AACI,IAAM,QAAQ,GAAG,UACtB,QAAgB,EAChB,aAA0B;;;;oBAEtB,qBAAM,iBAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAA;;gBAA5C,IAAI,SAAwC;oBAAE,sBAAO,EAAE,EAAA;gBAExC,KAAA,aAAa,CAAA;wBAAb,wBAAa;gBAAK,qBAAM,qBAAa,EAAE,EAAA;;gBAAtB,KAAA,CAAC,SAAqB,CAAC,CAAA;;;gBAAjD,MAAM,KAA2C;gBAC1C,qBAAM,eAAQ,CAAC,QAAQ,CAAC,EAAA;;gBAA/B,IAAI,GAAG,SAAwB;gBAE/B,eAAe,GAAG,oBAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAC/C,eAAe,GAAG,oBAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBAEjD,6DAAW,eAAe,WAAK,eAAe,IAAC;;;KAChD,CAAA;AAbY,QAAA,QAAQ,YAapB"}
1
+ {"version":3,"file":"lintFile.js","sourceRoot":"","sources":["../../src/lint/lintFile.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA4C;AAE5C,oCAAmD;AACnD,qCAAmD;AAEnD;;;;;GAKG;AACI,MAAM,QAAQ,GAAG,CACtB,QAAgB,EAChB,aAA0B,EACH,EAAE;IACzB,IAAI,MAAM,IAAA,iBAAS,EAAC,QAAQ,EAAE,aAAa,CAAC;QAAE,OAAO,EAAE,CAAA;IAEvD,MAAM,MAAM,GAAG,aAAa,IAAI,CAAC,MAAM,IAAA,qBAAa,GAAE,CAAC,CAAA;IACvD,MAAM,IAAI,GAAG,MAAM,IAAA,eAAQ,EAAC,QAAQ,CAAC,CAAA;IAErC,MAAM,eAAe,GAAG,IAAA,oBAAW,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IACrD,MAAM,eAAe,GAAG,IAAA,oBAAW,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAEjD,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,eAAe,CAAC,CAAA;AACjD,CAAC,CAAA,CAAA;AAbY,QAAA,QAAQ,YAapB"}
@@ -5,4 +5,4 @@ import { Diagnostic, LintConfig } from '../types';
5
5
  * @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
6
6
  * @returns {Promise<Map<string, Diagnostic[]>>} Resolves with a map with array of diagnostic objects, each containing a warning, line number and column number, and grouped by file path.
7
7
  */
8
- export declare const lintFolder: (folderPath: string, configuration?: LintConfig | undefined) => Promise<Map<string, Diagnostic[]>>;
8
+ export declare const lintFolder: (folderPath: string, configuration?: LintConfig) => Promise<Map<string, Diagnostic[]>>;
@@ -8,64 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
55
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
56
- to[j] = from[i];
57
- return to;
58
- };
59
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
60
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
61
13
  };
62
14
  Object.defineProperty(exports, "__esModule", { value: true });
63
15
  exports.lintFolder = void 0;
64
- var file_1 = require("@sasjs/utils/file");
65
- var path_1 = __importDefault(require("path"));
66
- var utils_1 = require("../utils");
67
- var lintFile_1 = require("./lintFile");
68
- var excludeFolders = [
16
+ const file_1 = require("@sasjs/utils/file");
17
+ const path_1 = __importDefault(require("path"));
18
+ const utils_1 = require("../utils");
19
+ const lintFile_1 = require("./lintFile");
20
+ const excludeFolders = [
69
21
  '.git',
70
22
  '.github',
71
23
  '.vscode',
@@ -79,66 +31,23 @@ var excludeFolders = [
79
31
  * @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
80
32
  * @returns {Promise<Map<string, Diagnostic[]>>} Resolves with a map with array of diagnostic objects, each containing a warning, line number and column number, and grouped by file path.
81
33
  */
82
- var lintFolder = function (folderPath, configuration) { return __awaiter(void 0, void 0, void 0, function () {
83
- var config, _a, diagnostics, fileNames, subFolders;
84
- return __generator(this, function (_b) {
85
- switch (_b.label) {
86
- case 0:
87
- _a = configuration;
88
- if (_a) return [3 /*break*/, 2];
89
- return [4 /*yield*/, utils_1.getLintConfig()];
90
- case 1:
91
- _a = (_b.sent());
92
- _b.label = 2;
93
- case 2:
94
- config = _a;
95
- diagnostics = new Map();
96
- return [4 /*yield*/, utils_1.isIgnored(folderPath, config)];
97
- case 3:
98
- if (_b.sent())
99
- return [2 /*return*/, diagnostics];
100
- return [4 /*yield*/, utils_1.listSasFiles(folderPath)];
101
- case 4:
102
- fileNames = _b.sent();
103
- return [4 /*yield*/, utils_1.asyncForEach(fileNames, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
104
- var filePath, _a, _b, _c;
105
- return __generator(this, function (_d) {
106
- switch (_d.label) {
107
- case 0:
108
- filePath = path_1.default.join(folderPath, fileName);
109
- _b = (_a = diagnostics).set;
110
- _c = [filePath];
111
- return [4 /*yield*/, lintFile_1.lintFile(filePath, config)];
112
- case 1:
113
- _b.apply(_a, _c.concat([_d.sent()]));
114
- return [2 /*return*/];
115
- }
116
- });
117
- }); })];
118
- case 5:
119
- _b.sent();
120
- return [4 /*yield*/, file_1.listSubFoldersInFolder(folderPath)];
121
- case 6:
122
- subFolders = (_b.sent()).filter(function (f) { return !excludeFolders.includes(f); });
123
- return [4 /*yield*/, utils_1.asyncForEach(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
124
- var subFolderPath, subFolderDiagnostics;
125
- return __generator(this, function (_a) {
126
- switch (_a.label) {
127
- case 0:
128
- subFolderPath = path_1.default.join(folderPath, subFolder);
129
- return [4 /*yield*/, exports.lintFolder(subFolderPath, config)];
130
- case 1:
131
- subFolderDiagnostics = _a.sent();
132
- diagnostics = new Map(__spreadArray(__spreadArray([], __read(diagnostics)), __read(subFolderDiagnostics)));
133
- return [2 /*return*/];
134
- }
135
- });
136
- }); })];
137
- case 7:
138
- _b.sent();
139
- return [2 /*return*/, diagnostics];
140
- }
141
- });
142
- }); };
34
+ const lintFolder = (folderPath, configuration) => __awaiter(void 0, void 0, void 0, function* () {
35
+ const config = configuration || (yield (0, utils_1.getLintConfig)());
36
+ let diagnostics = new Map();
37
+ if (yield (0, utils_1.isIgnored)(folderPath, config))
38
+ return diagnostics;
39
+ const fileNames = yield (0, utils_1.listSasFiles)(folderPath);
40
+ yield (0, utils_1.asyncForEach)(fileNames, (fileName) => __awaiter(void 0, void 0, void 0, function* () {
41
+ const filePath = path_1.default.join(folderPath, fileName);
42
+ diagnostics.set(filePath, yield (0, lintFile_1.lintFile)(filePath, config));
43
+ }));
44
+ const subFolders = (yield (0, file_1.listSubFoldersInFolder)(folderPath)).filter((f) => !excludeFolders.includes(f));
45
+ yield (0, utils_1.asyncForEach)(subFolders, (subFolder) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const subFolderPath = path_1.default.join(folderPath, subFolder);
47
+ const subFolderDiagnostics = yield (0, exports.lintFolder)(subFolderPath, config);
48
+ diagnostics = new Map([...diagnostics, ...subFolderDiagnostics]);
49
+ }));
50
+ return diagnostics;
51
+ });
143
52
  exports.lintFolder = lintFolder;
144
53
  //# sourceMappingURL=lintFolder.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lintFolder.js","sourceRoot":"","sources":["../../src/lint/lintFolder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0D;AAC1D,8CAAuB;AAEvB,kCAA+E;AAC/E,uCAAqC;AAErC,IAAM,cAAc,GAAG;IACrB,MAAM;IACN,SAAS;IACT,SAAS;IACT,cAAc;IACd,YAAY;IACZ,cAAc;CACf,CAAA;AAED;;;;;GAKG;AACI,IAAM,UAAU,GAAG,UACxB,UAAkB,EAClB,aAA0B;;;;;gBAEX,KAAA,aAAa,CAAA;wBAAb,wBAAa;gBAAK,qBAAM,qBAAa,EAAE,EAAA;;gBAAtB,KAAA,CAAC,SAAqB,CAAC,CAAA;;;gBAAjD,MAAM,KA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a,EAAE,MAAM,CAAC,CAAA;QACpE,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAA;IAClE,CAAC,CAAA,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA,CAAA;AA1BY,QAAA,UAAU,cA0BtB"}
@@ -8,56 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.lintProject = void 0;
40
- var getProjectRoot_1 = require("../utils/getProjectRoot");
41
- var lintFolder_1 = require("./lintFolder");
13
+ const getProjectRoot_1 = require("../utils/getProjectRoot");
14
+ const lintFolder_1 = require("./lintFolder");
42
15
  /**
43
16
  * Analyses and produces a set of diagnostics for the current project.
44
17
  * @returns {Promise<Map<string, Diagnostic[]>>} Resolves with a map with array of diagnostic objects, each containing a warning, line number and column number, and grouped by file path.
45
18
  */
46
- var lintProject = function () { return __awaiter(void 0, void 0, void 0, function () {
47
- var projectRoot;
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0: return [4 /*yield*/, getProjectRoot_1.getProjectRoot()];
51
- case 1:
52
- projectRoot = (_a.sent()) || process.currentDir;
53
- if (!projectRoot) {
54
- throw new Error('SASjs Project Root was not found.');
55
- }
56
- console.info("Linting all .sas files under " + projectRoot);
57
- return [4 /*yield*/, lintFolder_1.lintFolder(projectRoot)];
58
- case 2: return [2 /*return*/, _a.sent()];
59
- }
60
- });
61
- }); };
19
+ const lintProject = () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const projectRoot = (yield (0, getProjectRoot_1.getProjectRoot)()) || process.currentDir;
21
+ if (!projectRoot) {
22
+ throw new Error('SASjs Project Root was not found.');
23
+ }
24
+ console.info(`Linting all .sas files under ${projectRoot}`);
25
+ return yield (0, lintFolder_1.lintFolder)(projectRoot);
26
+ });
62
27
  exports.lintProject = lintProject;
63
28
  //# sourceMappingURL=lintProject.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lintProject.js","sourceRoot":"","sources":["../../src/lint/lintProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAwD;AACxD,2CAAyC;AAEzC;;;GAGG;AACI,IAAM,WAAW,GAAG;;;;oBACJ,qBAAM,+BAAc,EAAE,EAAA;;gBAArC,WAAW,GAAG,CAAC,SAAsB,CAAC,IAAI,OAAO,CAAC,UAAU;gBAClE,IAAI,CAAC,WAAW,EAAE;oBAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;iBACrD;gBAED,OAAO,CAAC,IAAI,CAAC,kCAAgC,WAAa,CAAC,CAAA;gBAEpD,qBAAM,uBAAU,CAAC,WAAW,CAAC,EAAA;oBAApC,sBAAO,SAA6B,EAAA;;;KACrC,CAAA;AATY,QAAA,WAAW,eASvB"}
1
+ {"version":3,"file":"lintProject.js","sourceRoot":"","sources":["../../src/lint/lintProject.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4DAAwD;AACxD,6CAAyC;AAEzC;;;GAGG;AACI,MAAM,WAAW,GAAG,GAAS,EAAE;IACpC,MAAM,WAAW,GAAG,CAAC,MAAM,IAAA,+BAAc,GAAE,CAAC,IAAI,OAAO,CAAC,UAAU,CAAA;IAClE,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;KACrD;IAED,OAAO,CAAC,IAAI,CAAC,gCAAgC,WAAW,EAAE,CAAC,CAAA;IAE3D,OAAO,MAAM,IAAA,uBAAU,EAAC,WAAW,CAAC,CAAA;AACtC,CAAC,CAAA,CAAA;AATY,QAAA,WAAW,eASvB"}
package/lint/lintText.js CHANGED
@@ -8,52 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.lintText = void 0;
40
- var getLintConfig_1 = require("../utils/getLintConfig");
41
- var shared_1 = require("./shared");
13
+ const getLintConfig_1 = require("../utils/getLintConfig");
14
+ const shared_1 = require("./shared");
42
15
  /**
43
16
  * Analyses and produces a set of diagnostics for the given text content.
44
17
  * @param {string} text - the text content to be linted.
45
18
  * @returns {Diagnostic[]} array of diagnostic objects, each containing a warning, line number and column number.
46
19
  */
47
- var lintText = function (text) { return __awaiter(void 0, void 0, void 0, function () {
48
- var config;
49
- return __generator(this, function (_a) {
50
- switch (_a.label) {
51
- case 0: return [4 /*yield*/, getLintConfig_1.getLintConfig()];
52
- case 1:
53
- config = _a.sent();
54
- return [2 /*return*/, shared_1.processText(text, config)];
55
- }
56
- });
57
- }); };
20
+ const lintText = (text) => __awaiter(void 0, void 0, void 0, function* () {
21
+ const config = yield (0, getLintConfig_1.getLintConfig)();
22
+ return (0, shared_1.processText)(text, config);
23
+ });
58
24
  exports.lintText = lintText;
59
25
  //# sourceMappingURL=lintText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lintText.js","sourceRoot":"","sources":["../../src/lint/lintText.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAsD;AACtD,mCAAsC;AAEtC;;;;GAIG;AACI,IAAM,QAAQ,GAAG,UAAO,IAAY;;;;oBAC1B,qBAAM,6BAAa,EAAE,EAAA;;gBAA9B,MAAM,GAAG,SAAqB;gBACpC,sBAAO,oBAAW,CAAC,IAAI,EAAE,MAAM,CAAC,EAAA;;;KACjC,CAAA;AAHY,QAAA,QAAQ,YAGpB"}
1
+ {"version":3,"file":"lintText.js","sourceRoot":"","sources":["../../src/lint/lintText.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,0DAAsD;AACtD,qCAAsC;AAEtC;;;;GAIG;AACI,MAAM,QAAQ,GAAG,CAAO,IAAY,EAAE,EAAE;IAC7C,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAa,GAAE,CAAA;IACpC,OAAO,IAAA,oBAAW,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;AAClC,CAAC,CAAA,CAAA;AAHY,QAAA,QAAQ,YAGpB"}
package/lint/shared.js CHANGED
@@ -1,62 +1,41 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20
- to[j] = from[i];
21
- return to;
22
- };
23
2
  Object.defineProperty(exports, "__esModule", { value: true });
24
3
  exports.processLine = exports.processFile = exports.processText = void 0;
25
- var utils_1 = require("../utils");
26
- var utils_2 = require("../utils");
27
- var processText = function (text, config) {
28
- var lines = utils_1.splitText(text, config);
29
- var headerLinesCount = utils_1.getHeaderLinesCount(text, config);
30
- var dataSections = utils_2.getDataSectionsDetail(text, config);
31
- var diagnostics = [];
32
- diagnostics.push.apply(diagnostics, __spreadArray([], __read(processContent(config, text))));
33
- lines.forEach(function (line, index) {
34
- var isHeaderLine = index + 1 <= headerLinesCount;
35
- var isDataLine = utils_2.checkIsDataLine(dataSections, index);
36
- diagnostics.push.apply(diagnostics, __spreadArray([], __read(exports.processLine(config, line, index + 1, { isHeaderLine: isHeaderLine, isDataLine: isDataLine }))));
4
+ const utils_1 = require("../utils");
5
+ const utils_2 = require("../utils");
6
+ const processText = (text, config) => {
7
+ const lines = (0, utils_1.splitText)(text, config);
8
+ const headerLinesCount = (0, utils_1.getHeaderLinesCount)(text, config);
9
+ const dataSections = (0, utils_2.getDataSectionsDetail)(text, config);
10
+ const diagnostics = [];
11
+ diagnostics.push(...processContent(config, text));
12
+ lines.forEach((line, index) => {
13
+ const isHeaderLine = index + 1 <= headerLinesCount;
14
+ const isDataLine = (0, utils_2.checkIsDataLine)(dataSections, index);
15
+ diagnostics.push(...(0, exports.processLine)(config, line, index + 1, { isHeaderLine, isDataLine }));
37
16
  });
38
17
  return diagnostics;
39
18
  };
40
19
  exports.processText = processText;
41
- var processFile = function (filePath, config) {
42
- var diagnostics = [];
43
- config.pathLintRules.forEach(function (rule) {
44
- diagnostics.push.apply(diagnostics, __spreadArray([], __read(rule.test(filePath, config))));
20
+ const processFile = (filePath, config) => {
21
+ const diagnostics = [];
22
+ config.pathLintRules.forEach((rule) => {
23
+ diagnostics.push(...rule.test(filePath, config));
45
24
  });
46
25
  return diagnostics;
47
26
  };
48
27
  exports.processFile = processFile;
49
- var processContent = function (config, content) {
50
- var diagnostics = [];
51
- config.fileLintRules.forEach(function (rule) {
52
- diagnostics.push.apply(diagnostics, __spreadArray([], __read(rule.test(content, config))));
28
+ const processContent = (config, content) => {
29
+ const diagnostics = [];
30
+ config.fileLintRules.forEach((rule) => {
31
+ diagnostics.push(...rule.test(content, config));
53
32
  });
54
33
  return diagnostics;
55
34
  };
56
- var processLine = function (config, line, lineNumber, options) {
57
- var diagnostics = [];
58
- config.lineLintRules.forEach(function (rule) {
59
- diagnostics.push.apply(diagnostics, __spreadArray([], __read(rule.test(line, lineNumber, config, options))));
35
+ const processLine = (config, line, lineNumber, options) => {
36
+ const diagnostics = [];
37
+ config.lineLintRules.forEach((rule) => {
38
+ diagnostics.push(...rule.test(line, lineNumber, config, options));
60
39
  });
61
40
  return diagnostics;
62
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/lint/shared.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,kCAAyD;AACzD,kCAAiE;AAE1D,IAAM,WAAW,GAAG,UAAC,IAAY,EAAE,MAAkB;IAC1D,IAAM,KAAK,GAAG,iBAAS,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACrC,IAAM,gBAAgB,GAAG,2BAAmB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAC1D,IAAM,YAAY,GAAG,6BAAqB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACxD,IAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,WAAW,CAAC,IAAI,OAAhB,WAAW,2BAAS,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,IAAC;IACjD,KAAK,CAAC,OAAO,CAAC,UAAC,IAAI,EAAE,KAAK;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,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;IAClD,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAVY,QAAA,WAAW,eAUvB;AAED,MAAM,cAAc,GAAG,CAAC,MAAkB,EAAE,OAAe,EAAgB,EAAE;IAC3E,MAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAA;IACjD,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAEM,MAAM,WAAW,GAAG,CACzB,MAAkB,EAClB,IAAY,EACZ,UAAkB,EAClB,OAA4B,EACd,EAAE;IAChB,MAAM,WAAW,GAAiB,EAAE,CAAA;IACpC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACpC,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;IACnE,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAZY,QAAA,WAAW,eAYvB"}
package/lintExample.js CHANGED
@@ -3,17 +3,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var lint_1 = require("./lint");
7
- var path_1 = __importDefault(require("path"));
6
+ const lint_1 = require("./lint");
7
+ const path_1 = __importDefault(require("path"));
8
8
  /**
9
9
  * Example which tests a piece of text with all known violations.
10
10
  */
11
- var text = "/**\n @file\n @brief Returns an unused libref\n @details Use as follows:\n \n libname mclib0 (work);\n libname mclib1 (work);\n libname mclib2 (work);\n \n %let libref=%mf_getuniquelibref({SAS001});\n %put &=libref;\n \n which returns:\n \n > mclib3\n \n @param prefix= first part of libref. Remember that librefs can only be 8 characters,\n so a 7 letter prefix would mean that maxtries should be 10.\n @param maxtries= the last part of the libref. Provide an integer value.\n \n @version 9.2\n @author Allan Bowe\n **/\n \n \n%macro mf_getuniquelibref(prefix=mclib,maxtries=1000);\n %local x libref;\n %let x={SAS002};\n %do x=0 %to &maxtries;\n\t%if %sysfunc(libref(&prefix&x)) ne 0 %then %do;\n %let libref=&prefix&x;\n %let rc=%sysfunc(libname(&libref,%sysfunc(pathname(work))));\n %if &rc %then %put %sysfunc(sysmsg());\n &prefix&x\n %*put &sysmacroname: Libref &libref assigned as WORK and returned;\n %return;\n %end;\n %end;\n %put unable to find available libref in range &prefix.0-&maxtries;\n %mend;\n";
12
- lint_1.lintText(text).then(function (diagnostics) {
11
+ const text = `/**
12
+ @file
13
+ @brief Returns an unused libref
14
+ @details Use as follows:
15
+
16
+ libname mclib0 (work);
17
+ libname mclib1 (work);
18
+ libname mclib2 (work);
19
+
20
+ %let libref=%mf_getuniquelibref({SAS001});
21
+ %put &=libref;
22
+
23
+ which returns:
24
+
25
+ > mclib3
26
+
27
+ @param prefix= first part of libref. Remember that librefs can only be 8 characters,
28
+ so a 7 letter prefix would mean that maxtries should be 10.
29
+ @param maxtries= the last part of the libref. Provide an integer value.
30
+
31
+ @version 9.2
32
+ @author Allan Bowe
33
+ **/
34
+
35
+
36
+ %macro mf_getuniquelibref(prefix=mclib,maxtries=1000);
37
+ %local x libref;
38
+ %let x={SAS002};
39
+ %do x=0 %to &maxtries;
40
+ %if %sysfunc(libref(&prefix&x)) ne 0 %then %do;
41
+ %let libref=&prefix&x;
42
+ %let rc=%sysfunc(libname(&libref,%sysfunc(pathname(work))));
43
+ %if &rc %then %put %sysfunc(sysmsg());
44
+ &prefix&x
45
+ %*put &sysmacroname: Libref &libref assigned as WORK and returned;
46
+ %return;
47
+ %end;
48
+ %end;
49
+ %put unable to find available libref in range &prefix.0-&maxtries;
50
+ %mend;
51
+ `;
52
+ (0, lint_1.lintText)(text).then((diagnostics) => {
13
53
  console.log('Text lint results:');
14
54
  console.table(diagnostics);
15
55
  });
16
- lint_1.lintFile(path_1.default.join(__dirname, 'Example File.sas')).then(function (diagnostics) {
56
+ (0, lint_1.lintFile)(path_1.default.join(__dirname, 'Example File.sas')).then((diagnostics) => {
17
57
  console.log('File lint results:');
18
58
  console.table(diagnostics);
19
59
  });
@@ -1 +1 @@
1
- {"version":3,"file":"lintExample.js","sourceRoot":"","sources":["../src/lintExample.ts"],"names":[],"mappings":";;;;;AAAA,+BAA2C;AAC3C,8CAAuB;AAEvB;;GAEG;AAEH,IAAM,IAAI,GAAG,mjCAwCZ,CAAA;AAED,eAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,UAAC,WAAW;IAC9B,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA;AAEF,eAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,UAAC,WAAW;IAClE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"lintExample.js","sourceRoot":"","sources":["../src/lintExample.ts"],"names":[],"mappings":";;;;;AAAA,iCAA2C;AAC3C,gDAAuB;AAEvB;;GAEG;AAEH,MAAM,IAAI,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwCZ,CAAA;AAED,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;IAClC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA;AAEF,IAAA,eAAQ,EAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,EAAE;IACtE,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;IACjC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;AAC5B,CAAC,CAAC,CAAA"}