@sasjs/lint 2.2.1 → 2.3.0
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/README.md +11 -2
- package/format/formatProject.js +2 -1
- package/format/formatProject.js.map +1 -1
- package/lint/lintProject.js +2 -1
- package/lint/lintProject.js.map +1 -1
- package/package.json +1 -1
- package/sasjslint-schema.json +2 -2
- package/utils/getLintConfig.d.ts +3 -1
- package/utils/getLintConfig.js +7 -3
- package/utils/getLintConfig.js.map +1 -1
- package/utils/getProjectRoot.js +4 -2
- package/utils/getProjectRoot.js.map +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Configuration is via a `.sasjslint` file with the following structure (these are
|
|
|
23
23
|
"hasDoxygenHeader": true,
|
|
24
24
|
"hasMacroNameInMend": true,
|
|
25
25
|
"hasMacroParentheses": true,
|
|
26
|
-
"ignoreList": ["
|
|
26
|
+
"ignoreList": ["sasjsbuild/", "sasjsresults/"],
|
|
27
27
|
"indentationMultiple": 2,
|
|
28
28
|
"lineEndings": "off",
|
|
29
29
|
"lowerCaseFileNames": true,
|
|
@@ -49,9 +49,11 @@ Each setting can have three states:
|
|
|
49
49
|
|
|
50
50
|
For more details, and the default state, see the description of each rule below. It is also possible to change whether a rule returns ERROR or WARN using the `severityLevels` object.
|
|
51
51
|
|
|
52
|
+
Configuring a non-zero return code (ERROR) is helpful when running `sasjs lint` as part of a git pre-commit hook. An example is available [here](https://github.com/sasjs/template_jobs/blob/main/.git-hooks/pre-commit).
|
|
53
|
+
|
|
52
54
|
### allowedGremlins
|
|
53
55
|
|
|
54
|
-
An array of hex codes that represents allowed gremlins (invisible / undesirable characters). To allow all gremlins, you can also set the `noGremlins` rule to `false`.
|
|
56
|
+
An array of hex codes that represents allowed gremlins (invisible / undesirable characters). To allow all gremlins, you can also set the `noGremlins` rule to `false`. The full gremlin list is [here](https://github.com/sasjs/lint/blob/main/src/utils/gremlinCharacters.ts).
|
|
55
57
|
|
|
56
58
|
Example:
|
|
57
59
|
|
|
@@ -228,6 +230,13 @@ In addition, when such files are used in URLs, they are often padded with a mess
|
|
|
228
230
|
- Default: true
|
|
229
231
|
- Severity: WARNING
|
|
230
232
|
|
|
233
|
+
As an alternative (or in addition) to using a lint rule, you can also set the following in your `.gitignore` file to prevent files with spaces from being committed:
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
# prevent files/folders with spaces
|
|
237
|
+
**\ **
|
|
238
|
+
```
|
|
239
|
+
|
|
231
240
|
### noTabs
|
|
232
241
|
|
|
233
242
|
Whilst there are some arguments for using tabs (such as the ability to set your own indentation width, and to reduce character count) there are many, many, many developers who think otherwise. We're in that camp. Sorry (not sorry).
|
package/format/formatProject.js
CHANGED
|
@@ -49,10 +49,11 @@ var formatProject = function () { return __awaiter(void 0, void 0, void 0, funct
|
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0: return [4 /*yield*/, getProjectRoot_1.getProjectRoot()];
|
|
51
51
|
case 1:
|
|
52
|
-
projectRoot = (_a.sent()) || process.
|
|
52
|
+
projectRoot = (_a.sent()) || process.currentDir;
|
|
53
53
|
if (!projectRoot) {
|
|
54
54
|
throw new Error('SASjs Project Root was not found.');
|
|
55
55
|
}
|
|
56
|
+
console.info("Formatting all .sas files under " + projectRoot);
|
|
56
57
|
return [4 /*yield*/, formatFolder_1.formatFolder(projectRoot)];
|
|
57
58
|
case 2: return [2 /*return*/, _a.sent()];
|
|
58
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatProject.js","sourceRoot":"","sources":["../../src/format/formatProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0DAAwD;AACxD,+CAA6C;AAE7C;;;GAGG;AACI,IAAM,aAAa,GAAG;;;;
|
|
1
|
+
{"version":3,"file":"formatProject.js","sourceRoot":"","sources":["../../src/format/formatProject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0DAAwD;AACxD,+CAA6C;AAE7C;;;GAGG;AACI,IAAM,aAAa,GAAG;;;;oBACN,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,qCAAmC,WAAa,CAAC,CAAA;gBAEvD,qBAAM,2BAAY,CAAC,WAAW,CAAC,EAAA;oBAAtC,sBAAO,SAA+B,EAAA;;;KACvC,CAAA;AATY,QAAA,aAAa,iBASzB"}
|
package/lint/lintProject.js
CHANGED
|
@@ -49,10 +49,11 @@ var lintProject = function () { return __awaiter(void 0, void 0, void 0, functio
|
|
|
49
49
|
switch (_a.label) {
|
|
50
50
|
case 0: return [4 /*yield*/, getProjectRoot_1.getProjectRoot()];
|
|
51
51
|
case 1:
|
|
52
|
-
projectRoot = (_a.sent()) || process.
|
|
52
|
+
projectRoot = (_a.sent()) || process.currentDir;
|
|
53
53
|
if (!projectRoot) {
|
|
54
54
|
throw new Error('SASjs Project Root was not found.');
|
|
55
55
|
}
|
|
56
|
+
console.info("Linting all .sas files under " + projectRoot);
|
|
56
57
|
return [4 /*yield*/, lintFolder_1.lintFolder(projectRoot)];
|
|
57
58
|
case 2: return [2 /*return*/, _a.sent()];
|
|
58
59
|
}
|
package/lint/lintProject.js.map
CHANGED
|
@@ -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;;;;
|
|
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"}
|
package/package.json
CHANGED
package/sasjslint-schema.json
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"noSpacesInFileNames": true,
|
|
21
21
|
"noTabs": true,
|
|
22
22
|
"noTrailingSpaces": true,
|
|
23
|
-
"lineEndings": "
|
|
23
|
+
"lineEndings": "off",
|
|
24
24
|
"strictMacroDefinition": true,
|
|
25
25
|
"ignoreList": ["sajsbuild", "sasjsresults"]
|
|
26
26
|
},
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"enum": ["lf", "crlf", "off"],
|
|
186
186
|
"title": "lineEndings",
|
|
187
187
|
"description": "Enforces the configured terminating character for each line. Shows a warning when incorrect line endings are present.",
|
|
188
|
-
"default": "
|
|
188
|
+
"default": "off",
|
|
189
189
|
"examples": ["lf", "crlf"]
|
|
190
190
|
},
|
|
191
191
|
"strictMacroDefinition": {
|
package/utils/getLintConfig.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { LintConfig } from '../types/LintConfig';
|
|
2
|
+
import { LineEndings } from '../types/LineEndings';
|
|
2
3
|
export declare const getDefaultHeader: () => string;
|
|
3
4
|
/**
|
|
4
5
|
* Default configuration that is used when a .sasjslint file is not found
|
|
5
6
|
*/
|
|
6
7
|
export declare const DefaultLintConfiguration: {
|
|
8
|
+
lineEndings: LineEndings;
|
|
7
9
|
noTrailingSpaces: boolean;
|
|
8
10
|
noEncodedPasswords: boolean;
|
|
9
11
|
hasDoxygenHeader: boolean;
|
|
@@ -22,7 +24,7 @@ export declare const DefaultLintConfiguration: {
|
|
|
22
24
|
defaultHeader: string;
|
|
23
25
|
};
|
|
24
26
|
/**
|
|
25
|
-
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
|
27
|
+
* Fetches the config from the .sasjslint file (at project root or home directory) and creates a LintConfig object.
|
|
26
28
|
* Returns the default configuration when a .sasjslint file is unavailable.
|
|
27
29
|
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
|
28
30
|
*/
|
package/utils/getLintConfig.js
CHANGED
|
@@ -41,9 +41,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.getLintConfig = exports.DefaultLintConfiguration = exports.getDefaultHeader = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var os_1 = __importDefault(require("os"));
|
|
44
45
|
var LintConfig_1 = require("../types/LintConfig");
|
|
45
46
|
var file_1 = require("@sasjs/utils/file");
|
|
46
47
|
var getProjectRoot_1 = require("./getProjectRoot");
|
|
48
|
+
var LineEndings_1 = require("../types/LineEndings");
|
|
47
49
|
var getDefaultHeader = function () {
|
|
48
50
|
return "/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/";
|
|
49
51
|
};
|
|
@@ -52,6 +54,7 @@ exports.getDefaultHeader = getDefaultHeader;
|
|
|
52
54
|
* Default configuration that is used when a .sasjslint file is not found
|
|
53
55
|
*/
|
|
54
56
|
exports.DefaultLintConfiguration = {
|
|
57
|
+
lineEndings: LineEndings_1.LineEndings.OFF,
|
|
55
58
|
noTrailingSpaces: true,
|
|
56
59
|
noEncodedPasswords: true,
|
|
57
60
|
hasDoxygenHeader: true,
|
|
@@ -70,19 +73,20 @@ exports.DefaultLintConfiguration = {
|
|
|
70
73
|
defaultHeader: exports.getDefaultHeader()
|
|
71
74
|
};
|
|
72
75
|
/**
|
|
73
|
-
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
|
76
|
+
* Fetches the config from the .sasjslint file (at project root or home directory) and creates a LintConfig object.
|
|
74
77
|
* Returns the default configuration when a .sasjslint file is unavailable.
|
|
75
78
|
* @returns {Promise<LintConfig>} resolves with an object representing the current lint configuration.
|
|
76
79
|
*/
|
|
77
80
|
function getLintConfig() {
|
|
78
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var projectRoot, configuration;
|
|
82
|
+
var projectRoot, lintFileLocation, configuration;
|
|
80
83
|
return __generator(this, function (_a) {
|
|
81
84
|
switch (_a.label) {
|
|
82
85
|
case 0: return [4 /*yield*/, getProjectRoot_1.getProjectRoot()];
|
|
83
86
|
case 1:
|
|
84
87
|
projectRoot = _a.sent();
|
|
85
|
-
|
|
88
|
+
lintFileLocation = projectRoot || os_1.default.homedir();
|
|
89
|
+
return [4 /*yield*/, file_1.readFile(path_1.default.join(lintFileLocation, '.sasjslint')).catch(function (_) {
|
|
86
90
|
return JSON.stringify(exports.DefaultLintConfiguration);
|
|
87
91
|
})];
|
|
88
92
|
case 2:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,kDAAgD;AAChD,0CAA4C;AAC5C,mDAAiD;
|
|
1
|
+
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8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__importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
exports.getProjectRoot = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var os_1 = __importDefault(require("os"));
|
|
44
45
|
var file_1 = require("@sasjs/utils/file");
|
|
45
46
|
/**
|
|
46
47
|
* Returns the absolute path to the location of the .sasjslint file.
|
|
@@ -49,7 +50,7 @@ var file_1 = require("@sasjs/utils/file");
|
|
|
49
50
|
*/
|
|
50
51
|
function getProjectRoot() {
|
|
51
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var root, rootFound, i, currentLocation, maxLevels, isRoot;
|
|
53
|
+
var root, rootFound, i, currentLocation, homeDir, maxLevels, isRoot;
|
|
53
54
|
return __generator(this, function (_a) {
|
|
54
55
|
switch (_a.label) {
|
|
55
56
|
case 0:
|
|
@@ -57,10 +58,11 @@ function getProjectRoot() {
|
|
|
57
58
|
rootFound = false;
|
|
58
59
|
i = 1;
|
|
59
60
|
currentLocation = process.cwd();
|
|
61
|
+
homeDir = os_1.default.homedir();
|
|
60
62
|
maxLevels = currentLocation.split(path_1.default.sep).length;
|
|
61
63
|
_a.label = 1;
|
|
62
64
|
case 1:
|
|
63
|
-
if (!(i <= maxLevels && !rootFound)) return [3 /*break*/, 3];
|
|
65
|
+
if (!(i <= maxLevels && !rootFound && currentLocation !== homeDir)) return [3 /*break*/, 3];
|
|
64
66
|
return [4 /*yield*/, file_1.fileExists(path_1.default.join(currentLocation, '.sasjslint'))];
|
|
65
67
|
case 2:
|
|
66
68
|
isRoot = _a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getProjectRoot.js","sourceRoot":"","sources":["../../src/utils/getProjectRoot.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAuB;AACvB,0CAA8C;AAE9C;;;;GAIG;AACH,SAAsB,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