@sasjs/lint 2.4.1 → 2.4.3
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.
- package/.github/dependabot.yml +1 -1
- package/.github/reviewer-lottery.yml +0 -2
- package/.github/workflows/assign-reviewer.yml +2 -2
- package/.github/workflows/build.yml +2 -0
- package/.github/workflows/publish.yml +2 -0
- package/format/formatFile.d.ts +1 -1
- package/format/formatFile.js +24 -72
- package/format/formatFile.js.map +1 -1
- package/format/formatFolder.d.ts +1 -1
- package/format/formatFolder.js +36 -104
- package/format/formatFolder.js.map +1 -1
- package/format/formatProject.js +10 -45
- package/format/formatProject.js.map +1 -1
- package/format/formatText.d.ts +1 -1
- package/format/formatText.js +6 -46
- package/format/formatText.js.map +1 -1
- package/format/index.js +5 -1
- package/format/index.js.map +1 -1
- package/format/shared.js +16 -16
- package/format/shared.js.map +1 -1
- package/formatExample.js +10 -6
- package/formatExample.js.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/lint/index.js +5 -1
- package/lint/index.js.map +1 -1
- package/lint/lintFile.d.ts +1 -1
- package/lint/lintFile.js +12 -76
- package/lint/lintFile.js.map +1 -1
- package/lint/lintFolder.d.ts +1 -1
- package/lint/lintFolder.js +23 -114
- package/lint/lintFolder.js.map +1 -1
- package/lint/lintProject.js +10 -45
- package/lint/lintProject.js.map +1 -1
- package/lint/lintText.js +6 -40
- package/lint/lintText.js.map +1 -1
- package/lint/shared.js +24 -45
- package/lint/shared.js.map +1 -1
- package/lintExample.js +45 -5
- package/lintExample.js.map +1 -1
- package/package.json +3 -5
- package/rules/file/hasDoxygenHeader.js +29 -29
- package/rules/file/hasDoxygenHeader.js.map +1 -1
- package/rules/file/hasMacroNameInMend.js +59 -59
- package/rules/file/hasMacroNameInMend.js.map +1 -1
- package/rules/file/hasMacroParentheses.js +25 -27
- package/rules/file/hasMacroParentheses.js.map +1 -1
- package/rules/file/hasRequiredMacroOptions.js +20 -20
- package/rules/file/hasRequiredMacroOptions.js.map +1 -1
- package/rules/file/lineEndings.js +27 -27
- package/rules/file/lineEndings.js.map +1 -1
- package/rules/file/noNestedMacros.js +23 -23
- package/rules/file/noNestedMacros.js.map +1 -1
- package/rules/file/strictMacroDefinition.js +52 -57
- package/rules/file/strictMacroDefinition.js.map +1 -1
- package/rules/line/indentationMultiple.js +16 -16
- package/rules/line/indentationMultiple.js.map +1 -1
- package/rules/line/maxLineLength.js +16 -16
- package/rules/line/maxLineLength.js.map +1 -1
- package/rules/line/noEncodedPasswords.js +18 -18
- package/rules/line/noEncodedPasswords.js.map +1 -1
- package/rules/line/noGremlins.js +29 -69
- package/rules/line/noGremlins.js.map +1 -1
- package/rules/line/noTabs.js +19 -19
- package/rules/line/noTabs.js.map +1 -1
- package/rules/line/noTrailingSpaces.js +16 -16
- package/rules/line/noTrailingSpaces.js.map +1 -1
- package/rules/path/lowerCaseFileNames.js +15 -15
- package/rules/path/lowerCaseFileNames.js.map +1 -1
- package/rules/path/noSpacesInFileNames.js +15 -15
- package/rules/path/noSpacesInFileNames.js.map +1 -1
- package/types/LintConfig.js +28 -68
- package/types/LintConfig.js.map +1 -1
- package/types/index.js +5 -1
- package/types/index.js.map +1 -1
- package/utils/asyncForEach.js +4 -46
- package/utils/asyncForEach.js.map +1 -1
- package/utils/getColumnNumber.js +3 -3
- package/utils/getColumnNumber.js.map +1 -1
- package/utils/getDataSectionsDetail.js +16 -38
- package/utils/getDataSectionsDetail.js.map +1 -1
- package/utils/getHeaderLinesCount.js +8 -30
- package/utils/getHeaderLinesCount.js.map +1 -1
- package/utils/getIndicesOf.js +3 -4
- package/utils/getIndicesOf.js.map +1 -1
- package/utils/getLintConfig.js +14 -52
- package/utils/getLintConfig.js.map +1 -1
- package/utils/getProjectRoot.js +22 -59
- package/utils/getProjectRoot.js.map +1 -1
- package/utils/index.js +5 -1
- package/utils/index.js.map +1 -1
- package/utils/isIgnored.d.ts +1 -1
- package/utils/isIgnored.js +20 -67
- package/utils/isIgnored.js.map +1 -1
- package/utils/listSasFiles.js +5 -39
- package/utils/listSasFiles.js.map +1 -1
- package/utils/parseMacros.d.ts +1 -1
- package/utils/parseMacros.js +29 -50
- package/utils/parseMacros.js.map +1 -1
- package/utils/splitText.js +4 -4
- package/utils/splitText.js.map +1 -1
- package/utils/trimComments.js +8 -10
- package/utils/trimComments.js.map +1 -1
package/utils/asyncForEach.js
CHANGED
|
@@ -8,58 +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
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
12
|
exports.asyncForEach = void 0;
|
|
40
13
|
/**
|
|
41
14
|
* Executes an async callback for each item in the given array.
|
|
42
15
|
*/
|
|
43
16
|
function asyncForEach(array, callback) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
case 0:
|
|
49
|
-
index = 0;
|
|
50
|
-
_a.label = 1;
|
|
51
|
-
case 1:
|
|
52
|
-
if (!(index < array.length)) return [3 /*break*/, 4];
|
|
53
|
-
return [4 /*yield*/, callback(array[index], index, array)];
|
|
54
|
-
case 2:
|
|
55
|
-
_a.sent();
|
|
56
|
-
_a.label = 3;
|
|
57
|
-
case 3:
|
|
58
|
-
index++;
|
|
59
|
-
return [3 /*break*/, 1];
|
|
60
|
-
case 4: return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
for (let index = 0; index < array.length; index++) {
|
|
19
|
+
yield callback(array[index], index, array);
|
|
20
|
+
}
|
|
63
21
|
});
|
|
64
22
|
}
|
|
65
23
|
exports.asyncForEach = asyncForEach;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asyncForEach.js","sourceRoot":"","sources":["../../src/utils/asyncForEach.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"asyncForEach.js","sourceRoot":"","sources":["../../src/utils/asyncForEach.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;GAEG;AACH,SAAsB,YAAY,CAChC,KAAY,EACZ,QAAiE;;QAEjE,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;SAC3C;IACH,CAAC;CAAA;AAPD,oCAOC"}
|
package/utils/getColumnNumber.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getColumnNumber = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const getColumnNumber = (line, text) => {
|
|
5
|
+
const index = line.split('\n').pop().indexOf(text);
|
|
6
6
|
if (index < 0) {
|
|
7
|
-
throw new Error(
|
|
7
|
+
throw new Error(`String '${text}' was not found in line '${line}'`);
|
|
8
8
|
}
|
|
9
9
|
return line.split('\n').pop().indexOf(text) + 1;
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getColumnNumber.js","sourceRoot":"","sources":["../../src/utils/getColumnNumber.ts"],"names":[],"mappings":";;;AAAO,
|
|
1
|
+
{"version":3,"file":"getColumnNumber.js","sourceRoot":"","sources":["../../src/utils/getColumnNumber.ts"],"names":[],"mappings":";;;AAAO,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAY,EAAU,EAAE;IACpE,MAAM,KAAK,GAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9D,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,4BAA4B,IAAI,GAAG,CAAC,CAAA;KACpE;IACD,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAa,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7D,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
|
|
@@ -1,29 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.checkIsDataLine = exports.getDataSectionsDetail = void 0;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
lines.forEach(
|
|
4
|
+
const splitText_1 = require("./splitText");
|
|
5
|
+
const getDataSectionsDetail = (text, config) => {
|
|
6
|
+
const dataSections = [];
|
|
7
|
+
const lines = (0, splitText_1.splitText)(text, config);
|
|
8
|
+
const dataSectionStartRegex1 = new RegExp('^(datalines;)|(cards;)|(parmcards;)');
|
|
9
|
+
const dataSectionEndRegex1 = new RegExp(';');
|
|
10
|
+
const dataSectionStartRegex2 = new RegExp('^(datalines4;)|(cards4;)|(parmcards4;)');
|
|
11
|
+
const dataSectionEndRegex2 = new RegExp(';;;;');
|
|
12
|
+
let dataSectionStarted = false;
|
|
13
|
+
let dataSectionStartIndex = -1;
|
|
14
|
+
let dataSectionEndRegex = dataSectionEndRegex1;
|
|
15
|
+
lines.forEach((line, index) => {
|
|
27
16
|
if (dataSectionStarted) {
|
|
28
17
|
if (dataSectionEndRegex.test(line)) {
|
|
29
18
|
dataSections.push({ start: dataSectionStartIndex, end: index });
|
|
@@ -46,21 +35,10 @@ var getDataSectionsDetail = function (text, config) {
|
|
|
46
35
|
return dataSections;
|
|
47
36
|
};
|
|
48
37
|
exports.getDataSectionsDetail = getDataSectionsDetail;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var dataSection = dataSections_1_1.value;
|
|
54
|
-
if (lineIndex >= dataSection.start && lineIndex <= dataSection.end)
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
59
|
-
finally {
|
|
60
|
-
try {
|
|
61
|
-
if (dataSections_1_1 && !dataSections_1_1.done && (_a = dataSections_1.return)) _a.call(dataSections_1);
|
|
62
|
-
}
|
|
63
|
-
finally { if (e_1) throw e_1.error; }
|
|
38
|
+
const checkIsDataLine = (dataSections, lineIndex) => {
|
|
39
|
+
for (const dataSection of dataSections) {
|
|
40
|
+
if (lineIndex >= dataSection.start && lineIndex <= dataSection.end)
|
|
41
|
+
return true;
|
|
64
42
|
}
|
|
65
43
|
return false;
|
|
66
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDataSectionsDetail.js","sourceRoot":"","sources":["../../src/utils/getDataSectionsDetail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDataSectionsDetail.js","sourceRoot":"","sources":["../../src/utils/getDataSectionsDetail.ts"],"names":[],"mappings":";;;AACA,2CAAuC;AAOhC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAAE,MAAkB,EAAE,EAAE;IACxE,MAAM,YAAY,GAAyB,EAAE,CAAA;IAC7C,MAAM,KAAK,GAAG,IAAA,qBAAS,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAErC,MAAM,sBAAsB,GAAG,IAAI,MAAM,CACvC,qCAAqC,CACtC,CAAA;IACD,MAAM,oBAAoB,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAA;IAC5C,MAAM,sBAAsB,GAAG,IAAI,MAAM,CACvC,wCAAwC,CACzC,CAAA;IACD,MAAM,oBAAoB,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAA;IAE/C,IAAI,kBAAkB,GAAG,KAAK,CAAA;IAC9B,IAAI,qBAAqB,GAAG,CAAC,CAAC,CAAA;IAC9B,IAAI,mBAAmB,GAAG,oBAAoB,CAAA;IAE9C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,IAAI,kBAAkB,EAAE;YACtB,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAClC,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;gBAC/D,kBAAkB,GAAG,KAAK,CAAA;aAC3B;SACF;aAAM;YACL,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBACrC,kBAAkB,GAAG,IAAI,CAAA;gBACzB,qBAAqB,GAAG,KAAK,CAAA;gBAC7B,mBAAmB,GAAG,oBAAoB,CAAA;aAC3C;iBAAM,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;gBAC5C,kBAAkB,GAAG,IAAI,CAAA;gBACzB,qBAAqB,GAAG,KAAK,CAAA;gBAC7B,mBAAmB,GAAG,oBAAoB,CAAA;aAC3C;SACF;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,YAAY,CAAA;AACrB,CAAC,CAAA;AArCY,QAAA,qBAAqB,yBAqCjC;AAEM,MAAM,eAAe,GAAG,CAC7B,YAAkC,EAClC,SAAiB,EACjB,EAAE;IACF,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;QACtC,IAAI,SAAS,IAAI,WAAW,CAAC,KAAK,IAAI,SAAS,IAAI,WAAW,CAAC,GAAG;YAChE,OAAO,IAAI,CAAA;KACd;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAVY,QAAA,eAAe,mBAU3B"}
|
|
@@ -1,42 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.getHeaderLinesCount = void 0;
|
|
15
|
-
|
|
4
|
+
const splitText_1 = require("./splitText");
|
|
16
5
|
/**
|
|
17
6
|
* This function returns the number of lines the header spans upon.
|
|
18
7
|
* The file must start with "/*" and the header will finish with ⇙
|
|
19
8
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var count = 0;
|
|
9
|
+
const getHeaderLinesCount = (text, config) => {
|
|
10
|
+
let count = 0;
|
|
23
11
|
if (text.trimStart().startsWith('/*')) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (line.match(/\*\//)) {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
-
finally {
|
|
36
|
-
try {
|
|
37
|
-
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
12
|
+
const lines = (0, splitText_1.splitText)(text, config);
|
|
13
|
+
for (const line of lines) {
|
|
14
|
+
count++;
|
|
15
|
+
if (line.match(/\*\//)) {
|
|
16
|
+
break;
|
|
38
17
|
}
|
|
39
|
-
finally { if (e_1) throw e_1.error; }
|
|
40
18
|
}
|
|
41
19
|
}
|
|
42
20
|
return count;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHeaderLinesCount.js","sourceRoot":"","sources":["../../src/utils/getHeaderLinesCount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getHeaderLinesCount.js","sourceRoot":"","sources":["../../src/utils/getHeaderLinesCount.ts"],"names":[],"mappings":";;;AACA,2CAAuC;AAEvC;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,MAAkB,EAAE,EAAE;IACtE,IAAI,KAAK,GAAG,CAAC,CAAA;IAEb,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACrC,MAAM,KAAK,GAAG,IAAA,qBAAS,EAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAErC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,KAAK,EAAE,CAAA;YACP,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;gBACtB,MAAK;aACN;SACF;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAfY,QAAA,mBAAmB,uBAe/B"}
|
package/utils/getIndicesOf.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getIndicesOf = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var searchStrLen = searchStr.length;
|
|
4
|
+
const getIndicesOf = (searchStr, str, caseSensitive = true) => {
|
|
5
|
+
const searchStrLen = searchStr.length;
|
|
7
6
|
if (searchStrLen === 0) {
|
|
8
7
|
return [];
|
|
9
8
|
}
|
|
10
|
-
|
|
9
|
+
let startIndex = 0, index, indices = [];
|
|
11
10
|
if (!caseSensitive) {
|
|
12
11
|
str = str.toLowerCase();
|
|
13
12
|
searchStr = searchStr.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIndicesOf.js","sourceRoot":"","sources":["../../src/utils/getIndicesOf.ts"],"names":[],"mappings":";;;AAAO,
|
|
1
|
+
{"version":3,"file":"getIndicesOf.js","sourceRoot":"","sources":["../../src/utils/getIndicesOf.ts"],"names":[],"mappings":";;;AAAO,MAAM,YAAY,GAAG,CAC1B,SAAiB,EACjB,GAAW,EACX,gBAAyB,IAAI,EAC7B,EAAE;IACF,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAA;IACrC,IAAI,YAAY,KAAK,CAAC,EAAE;QACtB,OAAO,EAAE,CAAA;KACV;IAED,IAAI,UAAU,GAAG,CAAC,EAChB,KAAK,EACL,OAAO,GAAG,EAAE,CAAA;IAEd,IAAI,CAAC,aAAa,EAAE;QAClB,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;QACvB,SAAS,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;KACpC;IAED,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE;QACxD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACnB,UAAU,GAAG,KAAK,GAAG,YAAY,CAAA;KAClC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAzBY,QAAA,YAAY,gBAyBxB"}
|
package/utils/getLintConfig.js
CHANGED
|
@@ -8,47 +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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.getLintConfig = exports.DefaultLintConfiguration = exports.getDefaultHeader = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return "/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/";
|
|
51
|
-
};
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
18
|
+
const LintConfig_1 = require("../types/LintConfig");
|
|
19
|
+
const file_1 = require("@sasjs/utils/file");
|
|
20
|
+
const getProjectRoot_1 = require("./getProjectRoot");
|
|
21
|
+
const LineEndings_1 = require("../types/LineEndings");
|
|
22
|
+
const getDefaultHeader = () => `/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/`;
|
|
52
23
|
exports.getDefaultHeader = getDefaultHeader;
|
|
53
24
|
/**
|
|
54
25
|
* Default configuration that is used when a .sasjslint file is not found
|
|
@@ -70,7 +41,7 @@ exports.DefaultLintConfiguration = {
|
|
|
70
41
|
hasMacroParentheses: true,
|
|
71
42
|
strictMacroDefinition: true,
|
|
72
43
|
noGremlins: true,
|
|
73
|
-
defaultHeader: exports.getDefaultHeader()
|
|
44
|
+
defaultHeader: (0, exports.getDefaultHeader)()
|
|
74
45
|
};
|
|
75
46
|
/**
|
|
76
47
|
* Fetches the config from the .sasjslint file (at project root or home directory) and creates a LintConfig object.
|
|
@@ -78,22 +49,13 @@ exports.DefaultLintConfiguration = {
|
|
|
78
49
|
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
|
79
50
|
*/
|
|
80
51
|
function getLintConfig() {
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
case 1:
|
|
87
|
-
projectRoot = _a.sent();
|
|
88
|
-
lintFileLocation = projectRoot || os_1.default.homedir();
|
|
89
|
-
return [4 /*yield*/, file_1.readFile(path_1.default.join(lintFileLocation, '.sasjslint')).catch(function (_) {
|
|
90
|
-
return JSON.stringify(exports.DefaultLintConfiguration);
|
|
91
|
-
})];
|
|
92
|
-
case 2:
|
|
93
|
-
configuration = _a.sent();
|
|
94
|
-
return [2 /*return*/, new LintConfig_1.LintConfig(JSON.parse(configuration))];
|
|
95
|
-
}
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const projectRoot = yield (0, getProjectRoot_1.getProjectRoot)();
|
|
54
|
+
const lintFileLocation = projectRoot || os_1.default.homedir();
|
|
55
|
+
const configuration = yield (0, file_1.readFile)(path_1.default.join(lintFileLocation, '.sasjslint')).catch((_) => {
|
|
56
|
+
return JSON.stringify(exports.DefaultLintConfiguration);
|
|
96
57
|
});
|
|
58
|
+
return new LintConfig_1.LintConfig(JSON.parse(configuration));
|
|
97
59
|
});
|
|
98
60
|
}
|
|
99
61
|
exports.getLintConfig = getLintConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,4CAAmB;AACnB,oDAAgD;AAChD,4CAA4C;AAC5C,qDAAiD;AACjD,sDAAkD;AAE3C,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,gHAAgH,CAAA;AADrG,QAAA,gBAAgB,oBACqF;AAElH;;GAEG;AACU,QAAA,wBAAwB,GAAG;IACtC,WAAW,EAAE,yBAAW,CAAC,GAAG;IAC5B,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,IAAI;IACzB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,EAAE;IACjB,mBAAmB,EAAE,EAAE;IACvB,iBAAiB,EAAE,EAAE;IACrB,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,CAAC;IACtB,kBAAkB,EAAE,IAAI;IACxB,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,IAAI;IAC3B,UAAU,EAAE,IAAI;IAChB,aAAa,EAAE,IAAA,wBAAgB,GAAE;CAClC,CAAA;AAED;;;;GAIG;AACH,SAAsB,aAAa;;QACjC,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAc,GAAE,CAAA;QAC1C,MAAM,gBAAgB,GAAG,WAAW,IAAI,YAAE,CAAC,OAAO,EAAE,CAAA;QACpD,MAAM,aAAa,GAAG,MAAM,IAAA,eAAQ,EAClC,cAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC1C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,gCAAwB,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;IAClD,CAAC;CAAA;AATD,sCASC"}
|
package/utils/getProjectRoot.js
CHANGED
|
@@ -8,77 +8,40 @@ 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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.getProjectRoot = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
18
|
+
const file_1 = require("@sasjs/utils/file");
|
|
46
19
|
/**
|
|
47
20
|
* Returns the absolute path to the location of the .sasjslint file.
|
|
48
21
|
* Traverses the folder tree until the .sasjslint file is found.
|
|
49
22
|
* @returns {Promise<string>} the path to the folder containing the lint config.
|
|
50
23
|
*/
|
|
51
24
|
function getProjectRoot() {
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (isRoot) {
|
|
70
|
-
rootFound = true;
|
|
71
|
-
root = currentLocation;
|
|
72
|
-
return [3 /*break*/, 3];
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
currentLocation = path_1.default.join(currentLocation, '..');
|
|
76
|
-
i++;
|
|
77
|
-
}
|
|
78
|
-
return [3 /*break*/, 1];
|
|
79
|
-
case 3: return [2 /*return*/, root];
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
let root = '';
|
|
27
|
+
let rootFound = false;
|
|
28
|
+
let i = 1;
|
|
29
|
+
let currentLocation = process.cwd();
|
|
30
|
+
const homeDir = os_1.default.homedir();
|
|
31
|
+
const maxLevels = currentLocation.split(path_1.default.sep).length;
|
|
32
|
+
while (i <= maxLevels && !rootFound && currentLocation !== homeDir) {
|
|
33
|
+
const isRoot = yield (0, file_1.fileExists)(path_1.default.join(currentLocation, '.sasjslint'));
|
|
34
|
+
if (isRoot) {
|
|
35
|
+
rootFound = true;
|
|
36
|
+
root = currentLocation;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
currentLocation = path_1.default.join(currentLocation, '..');
|
|
41
|
+
i++;
|
|
80
42
|
}
|
|
81
|
-
}
|
|
43
|
+
}
|
|
44
|
+
return root;
|
|
82
45
|
});
|
|
83
46
|
}
|
|
84
47
|
exports.getProjectRoot = getProjectRoot;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectRoot.js","sourceRoot":"","sources":["../../src/utils/getProjectRoot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getProjectRoot.js","sourceRoot":"","sources":["../../src/utils/getProjectRoot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,4CAAmB;AACnB,4CAA8C;AAE9C;;;;GAIG;AACH,SAAsB,cAAc;;QAClC,IAAI,IAAI,GAAG,EAAE,CAAA;QACb,IAAI,SAAS,GAAG,KAAK,CAAA;QACrB,IAAI,CAAC,GAAG,CAAC,CAAA;QACT,IAAI,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QACnC,MAAM,OAAO,GAAG,YAAE,CAAC,OAAO,EAAE,CAAA;QAE5B,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,cAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAA;QAExD,OAAO,CAAC,IAAI,SAAS,IAAI,CAAC,SAAS,IAAI,eAAe,KAAK,OAAO,EAAE;YAClE,MAAM,MAAM,GAAG,MAAM,IAAA,iBAAU,EAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC,CAAA;YAEzE,IAAI,MAAM,EAAE;gBACV,SAAS,GAAG,IAAI,CAAA;gBAChB,IAAI,GAAG,eAAe,CAAA;gBAEtB,MAAK;aACN;iBAAM;gBACL,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAA;gBAClD,CAAC,EAAE,CAAA;aACJ;SACF;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAAA;AAxBD,wCAwBC"}
|
package/utils/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.
|
|
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/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,sDAAmC;AACnC,8CAA2B;AAC3B,iDAA8B;AAC9B,8CAA2B;AAC3B,iDAA8B;AAC9B,wDAAqC;AACrC,0DAAuC"}
|
package/utils/isIgnored.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ import { LintConfig } from '../types';
|
|
|
5
5
|
* @param {string} fPath - absolute path of file or folder
|
|
6
6
|
* @returns {Promise<boolean>} true if path matches the patterns from .gitignore file otherwise false
|
|
7
7
|
*/
|
|
8
|
-
export declare const isIgnored: (fPath: string, configuration?: LintConfig
|
|
8
|
+
export declare const isIgnored: (fPath: string, configuration?: LintConfig) => Promise<boolean>;
|
package/utils/isIgnored.js
CHANGED
|
@@ -8,83 +8,36 @@ 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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
15
|
exports.isIgnored = void 0;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
16
|
+
const utils_1 = require("@sasjs/utils");
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
19
|
+
const _1 = require(".");
|
|
47
20
|
/**
|
|
48
21
|
* A function to check if file/folder path matches any pattern from .gitignore or ignoreList (.sasjsLint)
|
|
49
22
|
*
|
|
50
23
|
* @param {string} fPath - absolute path of file or folder
|
|
51
24
|
* @returns {Promise<boolean>} true if path matches the patterns from .gitignore file otherwise false
|
|
52
25
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
gitIgnoreFilePath = path_1.default.join(projectRoot, '.gitignore');
|
|
70
|
-
rootPath = projectRoot + path_1.default.sep;
|
|
71
|
-
relativePath = fPath.replace(rootPath, '');
|
|
72
|
-
if (fPath === projectRoot)
|
|
73
|
-
return [2 /*return*/, false];
|
|
74
|
-
gitIgnoreFileContent = '';
|
|
75
|
-
return [4 /*yield*/, utils_1.fileExists(gitIgnoreFilePath)];
|
|
76
|
-
case 4:
|
|
77
|
-
if (!_b.sent()) return [3 /*break*/, 6];
|
|
78
|
-
return [4 /*yield*/, utils_1.readFile(gitIgnoreFilePath)];
|
|
79
|
-
case 5:
|
|
80
|
-
gitIgnoreFileContent = _b.sent();
|
|
81
|
-
_b.label = 6;
|
|
82
|
-
case 6: return [2 /*return*/, ignore_1.default()
|
|
83
|
-
.add(gitIgnoreFileContent)
|
|
84
|
-
.add(config.ignoreList)
|
|
85
|
-
.ignores(relativePath)];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}); };
|
|
26
|
+
const isIgnored = (fPath, configuration) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
const config = configuration || (yield (0, _1.getLintConfig)());
|
|
28
|
+
const projectRoot = yield (0, _1.getProjectRoot)();
|
|
29
|
+
const gitIgnoreFilePath = path_1.default.join(projectRoot, '.gitignore');
|
|
30
|
+
const rootPath = projectRoot + path_1.default.sep;
|
|
31
|
+
const relativePath = fPath.replace(rootPath, '');
|
|
32
|
+
if (fPath === projectRoot)
|
|
33
|
+
return false;
|
|
34
|
+
let gitIgnoreFileContent = '';
|
|
35
|
+
if (yield (0, utils_1.fileExists)(gitIgnoreFilePath))
|
|
36
|
+
gitIgnoreFileContent = yield (0, utils_1.readFile)(gitIgnoreFilePath);
|
|
37
|
+
return (0, ignore_1.default)()
|
|
38
|
+
.add(gitIgnoreFileContent)
|
|
39
|
+
.add(config.ignoreList)
|
|
40
|
+
.ignores(relativePath);
|
|
41
|
+
});
|
|
89
42
|
exports.isIgnored = isIgnored;
|
|
90
43
|
//# sourceMappingURL=isIgnored.js.map
|
package/utils/isIgnored.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isIgnored.js","sourceRoot":"","sources":["../../src/utils/isIgnored.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isIgnored.js","sourceRoot":"","sources":["../../src/utils/isIgnored.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAmD;AACnD,gDAAuB;AACvB,oDAA2B;AAC3B,wBAAiD;AAGjD;;;;;GAKG;AACI,MAAM,SAAS,GAAG,CACvB,KAAa,EACb,aAA0B,EACR,EAAE;IACpB,MAAM,MAAM,GAAG,aAAa,IAAI,CAAC,MAAM,IAAA,gBAAa,GAAE,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,IAAA,iBAAc,GAAE,CAAA;IAC1C,MAAM,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;IAC9D,MAAM,QAAQ,GAAG,WAAW,GAAG,cAAI,CAAC,GAAG,CAAA;IACvC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IAEhD,IAAI,KAAK,KAAK,WAAW;QAAE,OAAO,KAAK,CAAA;IAEvC,IAAI,oBAAoB,GAAG,EAAE,CAAA;IAE7B,IAAI,MAAM,IAAA,kBAAU,EAAC,iBAAiB,CAAC;QACrC,oBAAoB,GAAG,MAAM,IAAA,gBAAQ,EAAC,iBAAiB,CAAC,CAAA;IAE1D,OAAO,IAAA,gBAAM,GAAE;SACZ,GAAG,CAAC,oBAAoB,CAAC;SACzB,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;SACtB,OAAO,CAAC,YAAY,CAAC,CAAA;AAC1B,CAAC,CAAA,CAAA;AArBY,QAAA,SAAS,aAqBrB"}
|