@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/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
|
-
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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(
|
|
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
|
});
|
package/lintExample.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lintExample.js","sourceRoot":"","sources":["../src/lintExample.ts"],"names":[],"mappings":";;;;;AAAA
|
|
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"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Linting and formatting for SAS code",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"test": "jest --coverage",
|
|
6
|
-
"build": "rimraf build && tsc",
|
|
6
|
+
"build": "npx rimraf build && tsc",
|
|
7
7
|
"preinstall": "node checkNodeVersion",
|
|
8
8
|
"prebuild": "node checkNodeVersion",
|
|
9
9
|
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build && rm -rf ./src && rm tsconfig.json",
|
|
@@ -41,15 +41,13 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jest": "29.2.5",
|
|
43
43
|
"@types/node": "18.11.18",
|
|
44
|
-
"all-contributors-cli": "6.24.0",
|
|
45
44
|
"jest": "29.3.1",
|
|
46
|
-
"rimraf": "^3.0.2",
|
|
47
45
|
"ts-jest": "29.0.3",
|
|
48
46
|
"typescript": "^4.3.2"
|
|
49
47
|
},
|
|
50
48
|
"dependencies": {
|
|
51
|
-
"@sasjs/utils": "
|
|
49
|
+
"@sasjs/utils": "3.5.2",
|
|
52
50
|
"ignore": "5.2.4"
|
|
53
51
|
},
|
|
54
|
-
"version": "2.4.
|
|
52
|
+
"version": "2.4.3"
|
|
55
53
|
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasDoxygenHeader = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
const LineEndings_1 = require("../../types/LineEndings");
|
|
6
|
+
const LintRuleType_1 = require("../../types/LintRuleType");
|
|
7
|
+
const Severity_1 = require("../../types/Severity");
|
|
8
|
+
const getLintConfig_1 = require("../../utils/getLintConfig");
|
|
9
|
+
const name = 'hasDoxygenHeader';
|
|
10
|
+
const description = 'Enforce the presence of a Doxygen header at the start of each file.';
|
|
11
|
+
const message = 'File missing Doxygen header';
|
|
12
|
+
const messageForSingleAsterisk = 'File not following Doxygen header style, use double asterisks';
|
|
13
|
+
const test = (value, config) => {
|
|
14
14
|
var _a;
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
16
|
+
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
17
17
|
try {
|
|
18
|
-
|
|
18
|
+
const hasFileHeader = value.trimStart().startsWith('/**');
|
|
19
19
|
if (hasFileHeader)
|
|
20
20
|
return [];
|
|
21
|
-
|
|
21
|
+
const hasFileHeaderWithSingleAsterisk = value.trimStart().startsWith('/*');
|
|
22
22
|
if (hasFileHeaderWithSingleAsterisk)
|
|
23
23
|
return [
|
|
24
24
|
{
|
|
@@ -27,52 +27,52 @@ var test = function (value, config) {
|
|
|
27
27
|
.length + 1,
|
|
28
28
|
startColumnNumber: 1,
|
|
29
29
|
endColumnNumber: 1,
|
|
30
|
-
severity
|
|
30
|
+
severity
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
33
|
return [
|
|
34
34
|
{
|
|
35
|
-
message
|
|
35
|
+
message,
|
|
36
36
|
lineNumber: 1,
|
|
37
37
|
startColumnNumber: 1,
|
|
38
38
|
endColumnNumber: 1,
|
|
39
|
-
severity
|
|
39
|
+
severity
|
|
40
40
|
}
|
|
41
41
|
];
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
44
|
return [
|
|
45
45
|
{
|
|
46
|
-
message
|
|
46
|
+
message,
|
|
47
47
|
lineNumber: 1,
|
|
48
48
|
startColumnNumber: 1,
|
|
49
49
|
endColumnNumber: 1,
|
|
50
|
-
severity
|
|
50
|
+
severity
|
|
51
51
|
}
|
|
52
52
|
];
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const fix = (value, config) => {
|
|
56
|
+
const result = test(value, config);
|
|
57
57
|
if (result.length === 0) {
|
|
58
58
|
return value;
|
|
59
59
|
}
|
|
60
60
|
else if (result[0].message == messageForSingleAsterisk)
|
|
61
61
|
return value.replace('/*', '/**');
|
|
62
62
|
config = config || new types_1.LintConfig(getLintConfig_1.DefaultLintConfiguration);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
63
|
+
const lineEndingConfig = (config === null || config === void 0 ? void 0 : config.lineEndings) || LineEndings_1.LineEndings.LF;
|
|
64
|
+
const lineEnding = lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n';
|
|
65
|
+
return `${config === null || config === void 0 ? void 0 : config.defaultHeader.replace(/{lineEnding}/g, lineEnding)}${lineEnding}${value}`;
|
|
66
66
|
};
|
|
67
67
|
/**
|
|
68
68
|
* Lint rule that checks for the presence of a Doxygen header in a given file.
|
|
69
69
|
*/
|
|
70
70
|
exports.hasDoxygenHeader = {
|
|
71
71
|
type: LintRuleType_1.LintRuleType.File,
|
|
72
|
-
name
|
|
73
|
-
description
|
|
74
|
-
message
|
|
75
|
-
test
|
|
76
|
-
fix
|
|
72
|
+
name,
|
|
73
|
+
description,
|
|
74
|
+
message,
|
|
75
|
+
test,
|
|
76
|
+
fix
|
|
77
77
|
};
|
|
78
78
|
//# sourceMappingURL=hasDoxygenHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AACxC,yDAAqD;AAErD,2DAAuD;AACvD,mDAA+C;AAC/C,6DAAoE;AAEpE,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAC/B,MAAM,WAAW,GACf,qEAAqE,CAAA;AACvE,MAAM,OAAO,GAAG,6BAA6B,CAAA;AAC7C,MAAM,wBAAwB,GAC5B,+DAA+D,CAAA;AAEjE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;;IAClD,MAAM,UAAU,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,MAAK,yBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3E,MAAM,QAAQ,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC,IAAI,CAAC,KAAI,mBAAQ,CAAC,OAAO,CAAA;IAEhE,IAAI;QACF,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QACzD,IAAI,aAAa;YAAE,OAAO,EAAE,CAAA;QAE5B,MAAM,+BAA+B,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC1E,IAAI,+BAA+B;YACjC,OAAO;gBACL;oBACE,OAAO,EAAE,wBAAwB;oBACjC,UAAU,EACR,CAAC,MAAA,KAAK,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,mCAAI,EAAE,CAAC;yBAC9D,MAAM,GAAG,CAAC;oBACf,iBAAiB,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Y,CAAC,IAAI;IACvB,IAAI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAA"}
|
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasMacroNameInMend = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
macros.forEach(
|
|
4
|
+
const LintRuleType_1 = require("../../types/LintRuleType");
|
|
5
|
+
const Severity_1 = require("../../types/Severity");
|
|
6
|
+
const getColumnNumber_1 = require("../../utils/getColumnNumber");
|
|
7
|
+
const LineEndings_1 = require("../../types/LineEndings");
|
|
8
|
+
const parseMacros_1 = require("../../utils/parseMacros");
|
|
9
|
+
const name = 'hasMacroNameInMend';
|
|
10
|
+
const description = 'Enforces the presence of the macro name in each %mend statement.';
|
|
11
|
+
const message = '%mend statement has missing or incorrect macro name';
|
|
12
|
+
const test = (value, config) => {
|
|
13
|
+
const lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
14
|
+
const lines = value ? value.split(lineEnding) : [];
|
|
15
|
+
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
16
|
+
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
17
|
+
const diagnostics = [];
|
|
18
|
+
macros.forEach((macro) => {
|
|
19
19
|
if (macro.startLineNumbers.length === 0 && macro.endLineNumber !== null) {
|
|
20
|
-
|
|
20
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
21
21
|
diagnostics.push({
|
|
22
|
-
message:
|
|
22
|
+
message: `%mend statement is redundant`,
|
|
23
23
|
lineNumber: macro.endLineNumber,
|
|
24
|
-
startColumnNumber: getColumnNumber_1.getColumnNumber(endLine, '%mend'),
|
|
25
|
-
endColumnNumber: getColumnNumber_1.getColumnNumber(endLine, '%mend') + macro.termination.length,
|
|
26
|
-
severity
|
|
24
|
+
startColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend'),
|
|
25
|
+
endColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend') + macro.termination.length,
|
|
26
|
+
severity
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
else if (macro.endLineNumber === null &&
|
|
30
30
|
macro.startLineNumbers.length !== 0) {
|
|
31
31
|
diagnostics.push({
|
|
32
|
-
message:
|
|
32
|
+
message: `Missing %mend statement for macro - ${macro.name}`,
|
|
33
33
|
lineNumber: macro.startLineNumbers[0],
|
|
34
34
|
startColumnNumber: 1,
|
|
35
35
|
endColumnNumber: 1,
|
|
36
|
-
severity
|
|
36
|
+
severity
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
else if (macro.mismatchedMendMacroName) {
|
|
40
|
-
|
|
40
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
41
41
|
diagnostics.push({
|
|
42
|
-
message:
|
|
42
|
+
message: `%mend statement has mismatched macro name, it should be '${macro.name}'`,
|
|
43
43
|
lineNumber: macro.endLineNumber,
|
|
44
|
-
startColumnNumber: getColumnNumber_1.getColumnNumber(endLine, macro.mismatchedMendMacroName),
|
|
45
|
-
endColumnNumber: getColumnNumber_1.getColumnNumber(endLine, macro.mismatchedMendMacroName) +
|
|
44
|
+
startColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, macro.mismatchedMendMacroName),
|
|
45
|
+
endColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, macro.mismatchedMendMacroName) +
|
|
46
46
|
macro.mismatchedMendMacroName.length -
|
|
47
47
|
1,
|
|
48
|
-
severity
|
|
48
|
+
severity
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
else if (!macro.hasMacroNameInMend) {
|
|
52
|
-
|
|
52
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
53
53
|
diagnostics.push({
|
|
54
|
-
message:
|
|
54
|
+
message: `%mend statement is missing macro name - ${macro.name}`,
|
|
55
55
|
lineNumber: macro.endLineNumber,
|
|
56
|
-
startColumnNumber: getColumnNumber_1.getColumnNumber(endLine, '%mend'),
|
|
57
|
-
endColumnNumber: getColumnNumber_1.getColumnNumber(endLine, '%mend') + 6,
|
|
58
|
-
severity
|
|
56
|
+
startColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend'),
|
|
57
|
+
endColumnNumber: (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend') + 6,
|
|
58
|
+
severity
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
return diagnostics;
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
macros.forEach(
|
|
64
|
+
const fix = (value, config) => {
|
|
65
|
+
const lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
66
|
+
const lines = value ? value.split(lineEnding) : [];
|
|
67
|
+
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
68
|
+
macros.forEach((macro) => {
|
|
69
69
|
if (macro.startLineNumbers.length === 0 && macro.endLineNumber !== null) {
|
|
70
70
|
// %mend statement is redundant
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
72
|
+
const startColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend');
|
|
73
|
+
const endColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend') + macro.termination.length;
|
|
74
|
+
const beforeStatement = endLine.slice(0, startColumnNumber - 1);
|
|
75
|
+
const afterStatement = endLine.slice(endColumnNumber);
|
|
76
76
|
lines[macro.endLineNumber - 1] = beforeStatement + afterStatement;
|
|
77
77
|
}
|
|
78
78
|
else if (macro.endLineNumber === null &&
|
|
@@ -81,28 +81,28 @@ var fix = function (value, config) {
|
|
|
81
81
|
}
|
|
82
82
|
else if (macro.mismatchedMendMacroName) {
|
|
83
83
|
// mismatched macro name
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
85
|
+
const startColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, macro.mismatchedMendMacroName);
|
|
86
|
+
const endColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, macro.mismatchedMendMacroName) +
|
|
87
87
|
macro.mismatchedMendMacroName.length -
|
|
88
88
|
1;
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
const beforeMacroName = endLine.slice(0, startColumnNumber - 1);
|
|
90
|
+
const afterMacroName = endLine.slice(endColumnNumber);
|
|
91
91
|
lines[macro.endLineNumber - 1] =
|
|
92
92
|
beforeMacroName + macro.name + afterMacroName;
|
|
93
93
|
}
|
|
94
94
|
else if (!macro.hasMacroNameInMend) {
|
|
95
95
|
// %mend statement is missing macro name
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
const endLine = lines[macro.endLineNumber - 1];
|
|
97
|
+
const startColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend');
|
|
98
|
+
const endColumnNumber = (0, getColumnNumber_1.getColumnNumber)(endLine, '%mend') + 4;
|
|
99
|
+
const beforeStatement = endLine.slice(0, startColumnNumber - 1);
|
|
100
|
+
const afterStatement = endLine.slice(endColumnNumber);
|
|
101
101
|
lines[macro.endLineNumber - 1] =
|
|
102
|
-
beforeStatement +
|
|
102
|
+
beforeStatement + `%mend ${macro.name}` + afterStatement;
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
|
-
|
|
105
|
+
const formattedText = lines.join(lineEnding);
|
|
106
106
|
return formattedText;
|
|
107
107
|
};
|
|
108
108
|
/**
|
|
@@ -110,10 +110,10 @@ var fix = function (value, config) {
|
|
|
110
110
|
*/
|
|
111
111
|
exports.hasMacroNameInMend = {
|
|
112
112
|
type: LintRuleType_1.LintRuleType.File,
|
|
113
|
-
name
|
|
114
|
-
description
|
|
115
|
-
message
|
|
116
|
-
test
|
|
117
|
-
fix
|
|
113
|
+
name,
|
|
114
|
+
description,
|
|
115
|
+
message,
|
|
116
|
+
test,
|
|
117
|
+
fix
|
|
118
118
|
};
|
|
119
119
|
//# sourceMappingURL=hasMacroNameInMend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasMacroNameInMend.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroNameInMend.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"hasMacroNameInMend.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroNameInMend.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAE7D,yDAAqD;AACrD,yDAAqD;AAErD,MAAM,IAAI,GAAG,oBAAoB,CAAA;AACjC,MAAM,WAAW,GACf,kEAAkE,CAAA;AACpE,MAAM,OAAO,GAAG,qDAAqD,CAAA;AAErE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;IAClD,MAAM,UAAU,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,MAAK,yBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3E,MAAM,KAAK,GAAa,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;IAC5D,MAAM,MAAM,GAAG,IAAA,yBAAW,EAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACzC,MAAM,QAAQ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
|
-
|
|
15
|
-
macros.forEach(
|
|
4
|
+
const LintRuleType_1 = require("../../types/LintRuleType");
|
|
5
|
+
const Severity_1 = require("../../types/Severity");
|
|
6
|
+
const getColumnNumber_1 = require("../../utils/getColumnNumber");
|
|
7
|
+
const parseMacros_1 = require("../../utils/parseMacros");
|
|
8
|
+
const name = 'hasMacroParentheses';
|
|
9
|
+
const description = 'Enforces the presence of parentheses in macro definitions.';
|
|
10
|
+
const message = 'Macro definition missing parentheses';
|
|
11
|
+
const test = (value, config) => {
|
|
12
|
+
const diagnostics = [];
|
|
13
|
+
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
14
|
+
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
15
|
+
macros.forEach((macro) => {
|
|
16
16
|
if (!macro.name) {
|
|
17
17
|
diagnostics.push({
|
|
18
18
|
message: 'Macro definition missing name',
|
|
19
19
|
lineNumber: macro.startLineNumbers[0],
|
|
20
|
-
startColumnNumber: getColumnNumber_1.getColumnNumber(macro.declarationLines[0], '%macro'),
|
|
21
|
-
endColumnNumber: getColumnNumber_1.getColumnNumber(macro.declarationLines[0], '%macro') +
|
|
20
|
+
startColumnNumber: (0, getColumnNumber_1.getColumnNumber)(macro.declarationLines[0], '%macro'),
|
|
21
|
+
endColumnNumber: (0, getColumnNumber_1.getColumnNumber)(macro.declarationLines[0], '%macro') +
|
|
22
22
|
macro.declaration.length,
|
|
23
|
-
severity
|
|
23
|
+
severity
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
else if (!macro.declarationLines.find(
|
|
27
|
-
|
|
28
|
-
return dl.includes(macro.name);
|
|
29
|
-
});
|
|
26
|
+
else if (!macro.declarationLines.find((dl) => dl.includes('('))) {
|
|
27
|
+
const macroNameLineIndex = macro.declarationLines.findIndex((dl) => dl.includes(macro.name));
|
|
30
28
|
diagnostics.push({
|
|
31
|
-
message
|
|
29
|
+
message,
|
|
32
30
|
lineNumber: macro.startLineNumbers[macroNameLineIndex],
|
|
33
|
-
startColumnNumber: getColumnNumber_1.getColumnNumber(macro.declarationLines[macroNameLineIndex], macro.name),
|
|
34
|
-
endColumnNumber: getColumnNumber_1.getColumnNumber(macro.declarationLines[macroNameLineIndex], macro.name) +
|
|
31
|
+
startColumnNumber: (0, getColumnNumber_1.getColumnNumber)(macro.declarationLines[macroNameLineIndex], macro.name),
|
|
32
|
+
endColumnNumber: (0, getColumnNumber_1.getColumnNumber)(macro.declarationLines[macroNameLineIndex], macro.name) +
|
|
35
33
|
macro.name.length -
|
|
36
34
|
1,
|
|
37
|
-
severity
|
|
35
|
+
severity
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
38
|
});
|
|
@@ -45,9 +43,9 @@ var test = function (value, config) {
|
|
|
45
43
|
*/
|
|
46
44
|
exports.hasMacroParentheses = {
|
|
47
45
|
type: LintRuleType_1.LintRuleType.File,
|
|
48
|
-
name
|
|
49
|
-
description
|
|
50
|
-
message
|
|
51
|
-
test
|
|
46
|
+
name,
|
|
47
|
+
description,
|
|
48
|
+
message,
|
|
49
|
+
test
|
|
52
50
|
};
|
|
53
51
|
//# sourceMappingURL=hasMacroParentheses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasMacroParentheses.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroParentheses.ts"],"names":[],"mappings":";;;AAEA,
|
|
1
|
+
{"version":3,"file":"hasMacroParentheses.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroParentheses.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAC7D,yDAAqD;AAGrD,MAAM,IAAI,GAAG,qBAAqB,CAAA;AAClC,MAAM,WAAW,GAAG,4DAA4D,CAAA;AAChF,MAAM,OAAO,GAAG,sCAAsC,CAAA;AAEtD,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;IAClD,MAAM,WAAW,GAAiB,EAAE,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,gBAAgB,CAAC,kBAAkB,CAAC,EAC1C,KAAK,CAAC,IAAI,CACX;oBACD,KAAK,CAAC,IAAI,CAAC,MAAM;oBACjB,CAAC;gBACH,QAAQ;aACT,CAAC,CAAA;SACH;IACH,CAAC,CAAC,CAAA;IAEF,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED;;GAEG;AACU,QAAA,mBAAmB,GAAiB;IAC/C,IAAI,EAAE,2BAAY,CAAC,IAAI;IACvB,IAAI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;CACL,CAAA"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasRequiredMacroOptions = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
const LintRuleType_1 = require("../../types/LintRuleType");
|
|
6
|
+
const parseMacros_1 = require("../../utils/parseMacros");
|
|
7
|
+
const name = 'hasRequiredMacroOptions';
|
|
8
|
+
const description = 'Enforce required macro options';
|
|
9
|
+
const message = 'Macro defined without required options';
|
|
10
|
+
const processOptions = (macro, diagnostics, config) => {
|
|
11
11
|
var _a, _b, _c;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
config === null || config === void 0 ? void 0 : config.requiredMacroOptions.forEach(
|
|
12
|
+
const optionsPresent = (_c = (_b = (_a = macro.declaration.split('/')) === null || _a === void 0 ? void 0 : _a[1]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
13
|
+
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || types_1.Severity.Warning;
|
|
14
|
+
config === null || config === void 0 ? void 0 : config.requiredMacroOptions.forEach((option) => {
|
|
15
15
|
if (!optionsPresent.includes(option)) {
|
|
16
16
|
diagnostics.push({
|
|
17
|
-
message:
|
|
17
|
+
message: `Macro '${macro.name}' does not contain the required option '${option}'`,
|
|
18
18
|
lineNumber: macro.startLineNumbers[0],
|
|
19
19
|
startColumnNumber: 0,
|
|
20
20
|
endColumnNumber: 0,
|
|
21
|
-
severity
|
|
21
|
+
severity
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
macros.forEach(
|
|
26
|
+
const test = (value, config) => {
|
|
27
|
+
const diagnostics = [];
|
|
28
|
+
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
29
|
+
macros.forEach((macro) => {
|
|
30
30
|
processOptions(macro, diagnostics, config);
|
|
31
31
|
});
|
|
32
32
|
return diagnostics;
|
|
@@ -36,9 +36,9 @@ var test = function (value, config) {
|
|
|
36
36
|
*/
|
|
37
37
|
exports.hasRequiredMacroOptions = {
|
|
38
38
|
type: LintRuleType_1.LintRuleType.File,
|
|
39
|
-
name
|
|
40
|
-
description
|
|
41
|
-
message
|
|
42
|
-
test
|
|
39
|
+
name,
|
|
40
|
+
description,
|
|
41
|
+
message,
|
|
42
|
+
test
|
|
43
43
|
};
|
|
44
44
|
//# sourceMappingURL=hasRequiredMacroOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasRequiredMacroOptions.js","sourceRoot":"","sources":["../../../src/rules/file/hasRequiredMacroOptions.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"hasRequiredMacroOptions.js","sourceRoot":"","sources":["../../../src/rules/file/hasRequiredMacroOptions.ts"],"names":[],"mappings":";;;AAAA,uCAAqE;AAErE,2DAAuD;AACvD,yDAAqD;AAErD,MAAM,IAAI,GAAG,yBAAyB,CAAA;AACtC,MAAM,WAAW,GAAG,gCAAgC,CAAA;AACpD,MAAM,OAAO,GAAG,wCAAwC,CAAA;AAExD,MAAM,cAAc,GAAG,CACrB,KAAY,EACZ,WAAyB,EACzB,MA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