@sasjs/lint 1.11.2 → 1.13.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/.all-contributorsrc +113 -0
- package/.github/CONTRIBUTING.md +54 -0
- package/{PULL_REQUEST_TEMPLATE.md → .github/PULL_REQUEST_TEMPLATE.md} +0 -0
- package/.github/dependabot.yml +5 -5
- package/.github/workflows/build.yml +3 -2
- package/.gitpod.yml +8 -0
- package/README.md +72 -8
- package/checkNodeVersion.js +16 -0
- package/format/shared.js +1 -1
- package/format/shared.js.map +1 -1
- package/lint/lintFile.d.ts +3 -3
- package/lint/lintFile.js +12 -9
- package/lint/lintFile.js.map +1 -1
- package/lint/lintFolder.d.ts +1 -2
- package/lint/lintFolder.js +16 -12
- package/lint/lintFolder.js.map +1 -1
- package/package.json +9 -5
- package/rules/file/hasDoxygenHeader.js +4 -2
- package/rules/file/hasDoxygenHeader.js.map +1 -1
- package/sasjslint-schema.json +15 -2
- package/types/LintConfig.d.ts +2 -0
- package/types/LintConfig.js +20 -0
- package/types/LintConfig.js.map +1 -1
- package/utils/getLintConfig.d.ts +2 -0
- package/utils/getLintConfig.js +7 -2
- package/utils/getLintConfig.js.map +1 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/index.js.map +1 -1
- package/utils/isIgnored.d.ts +8 -0
- package/utils/isIgnored.js +90 -0
- package/utils/isIgnored.js.map +1 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"README.md"
|
|
4
|
+
],
|
|
5
|
+
"imageSize": 100,
|
|
6
|
+
"commit": false,
|
|
7
|
+
"contributors": [
|
|
8
|
+
{
|
|
9
|
+
"login": "Carus11",
|
|
10
|
+
"name": "Carus Kyle",
|
|
11
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/4925828?v=4",
|
|
12
|
+
"profile": "https://github.com/Carus11",
|
|
13
|
+
"contributions": [
|
|
14
|
+
"ideas"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"login": "allanbowe",
|
|
19
|
+
"name": "Allan Bowe",
|
|
20
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/4420615?v=4",
|
|
21
|
+
"profile": "https://github.com/allanbowe",
|
|
22
|
+
"contributions": [
|
|
23
|
+
"code",
|
|
24
|
+
"test",
|
|
25
|
+
"review",
|
|
26
|
+
"video",
|
|
27
|
+
"doc"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"login": "YuryShkoda",
|
|
32
|
+
"name": "Yury Shkoda",
|
|
33
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/25773492?v=4",
|
|
34
|
+
"profile": "https://www.erudicat.com/",
|
|
35
|
+
"contributions": [
|
|
36
|
+
"code",
|
|
37
|
+
"test",
|
|
38
|
+
"projectManagement",
|
|
39
|
+
"video",
|
|
40
|
+
"doc"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"login": "krishna-acondy",
|
|
45
|
+
"name": "Krishna Acondy",
|
|
46
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/2980428?v=4",
|
|
47
|
+
"profile": "https://krishna-acondy.io/",
|
|
48
|
+
"contributions": [
|
|
49
|
+
"code",
|
|
50
|
+
"test",
|
|
51
|
+
"review",
|
|
52
|
+
"infra",
|
|
53
|
+
"platform",
|
|
54
|
+
"maintenance",
|
|
55
|
+
"content"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"login": "saadjutt01",
|
|
60
|
+
"name": "Muhammad Saad ",
|
|
61
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/8914650?v=4",
|
|
62
|
+
"profile": "https://github.com/saadjutt01",
|
|
63
|
+
"contributions": [
|
|
64
|
+
"code",
|
|
65
|
+
"test",
|
|
66
|
+
"review",
|
|
67
|
+
"mentoring",
|
|
68
|
+
"doc"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"login": "sabhas",
|
|
73
|
+
"name": "Sabir Hassan",
|
|
74
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/82647447?v=4",
|
|
75
|
+
"profile": "https://github.com/sabhas",
|
|
76
|
+
"contributions": [
|
|
77
|
+
"code",
|
|
78
|
+
"test",
|
|
79
|
+
"review",
|
|
80
|
+
"ideas"
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"login": "medjedovicm",
|
|
85
|
+
"name": "Mihajlo Medjedovic",
|
|
86
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/18329105?v=4",
|
|
87
|
+
"profile": "https://github.com/medjedovicm",
|
|
88
|
+
"contributions": [
|
|
89
|
+
"code",
|
|
90
|
+
"test",
|
|
91
|
+
"review",
|
|
92
|
+
"infra"
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"login": "VladislavParhomchik",
|
|
97
|
+
"name": "Vladislav Parhomchik",
|
|
98
|
+
"avatar_url": "https://avatars.githubusercontent.com/u/83717836?v=4",
|
|
99
|
+
"profile": "https://github.com/VladislavParhomchik",
|
|
100
|
+
"contributions": [
|
|
101
|
+
"test",
|
|
102
|
+
"review"
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"contributorsPerLine": 7,
|
|
107
|
+
"projectName": "lint",
|
|
108
|
+
"projectOwner": "sasjs",
|
|
109
|
+
"repoType": "github",
|
|
110
|
+
"repoHost": "https://github.com",
|
|
111
|
+
"skipCi": true,
|
|
112
|
+
"commitConvention": "none"
|
|
113
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions to `@sasjs/lint` are very welcome!
|
|
4
|
+
Please fill in the pull request template and make sure that your code changes are adequately covered with tests when making a PR.
|
|
5
|
+
|
|
6
|
+
## Architecture
|
|
7
|
+
|
|
8
|
+
This project implements a number of rules for SAS projects and code. There are three types of rules:
|
|
9
|
+
|
|
10
|
+
* File rules - rules applied at the file level
|
|
11
|
+
* Line rules - rules applied to each line of a file
|
|
12
|
+
* Path rules - rules applied to paths and file names
|
|
13
|
+
|
|
14
|
+
When implementing a new rule, place it in the appropriate folder for its type.
|
|
15
|
+
Please also make sure to export it from the `index.ts` file in that folder.
|
|
16
|
+
|
|
17
|
+
The file for each rule typically exports an object that conforms to the `LintRule` interface.
|
|
18
|
+
This means it will have a `type`, `name`, `description` and `message` at a minimum.
|
|
19
|
+
|
|
20
|
+
File, line and path lint rules also have a `test` property.
|
|
21
|
+
This is a function that will run a piece of logic against the supplied item and produce an array of `Diagnostic` objects.
|
|
22
|
+
These objects can be used in the consuming application to display the problems in the code.
|
|
23
|
+
|
|
24
|
+
With some lint rules, we can also write logic that can automatically fix the issues found.
|
|
25
|
+
These rules will also have a `fix` property, which is a function that takes the original content -
|
|
26
|
+
either a line or the entire contents of a file, and returns the transformed content with the fix applied.
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
|
|
30
|
+
Testing is one of the most important steps when developing a new lint rule.
|
|
31
|
+
It helps us ensure that our lint rules do what they are intended to do.
|
|
32
|
+
|
|
33
|
+
We use `jest` for testing, and since most of the code is based on pure functions, there is little mocking to do.
|
|
34
|
+
This makes `@sasjs/lint` very easy to unit test, and so there is no excuse for not testing a new rule. :)
|
|
35
|
+
|
|
36
|
+
When adding a new rule, please make sure that all positive and negative scenarios are tested in separate test cases.
|
|
37
|
+
When modifying an existing rule, ensure that your changes haven't affected existing functionality by running the tests on your machine.
|
|
38
|
+
|
|
39
|
+
You can run the tests using `npm test`.
|
|
40
|
+
|
|
41
|
+
## Code Style
|
|
42
|
+
|
|
43
|
+
This repository uses `Prettier` to ensure a uniform code style.
|
|
44
|
+
If you are using VS Code for development, you can automatically fix your code to match the style as follows:
|
|
45
|
+
|
|
46
|
+
- Install the `Prettier` extension for VS Code.
|
|
47
|
+
- Open your `settings.json` file by choosing 'Preferences: Open Settings (JSON)' from the command palette.
|
|
48
|
+
- Add the following items to the JSON.
|
|
49
|
+
```
|
|
50
|
+
"editor.formatOnSave": true,
|
|
51
|
+
"editor.formatOnPaste": true,
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
If you are using another editor, or are unable to install the extension, you can run `npm run lint:fix` to fix the formatting after you've made your changes.
|
|
File without changes
|
package/.github/dependabot.yml
CHANGED
|
@@ -13,14 +13,15 @@ jobs:
|
|
|
13
13
|
|
|
14
14
|
strategy:
|
|
15
15
|
matrix:
|
|
16
|
-
node-version: [
|
|
16
|
+
node-version: [lts/*]
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
19
|
- uses: actions/checkout@v2
|
|
20
20
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
-
uses: actions/setup-node@
|
|
21
|
+
uses: actions/setup-node@v2
|
|
22
22
|
with:
|
|
23
23
|
node-version: ${{ matrix.node-version }}
|
|
24
|
+
cache: npm
|
|
24
25
|
- name: Install Dependencies
|
|
25
26
|
run: npm ci
|
|
26
27
|
- name: Check Code Style
|
package/.gitpod.yml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# This configuration file was automatically generated by Gitpod.
|
|
2
|
+
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
|
|
3
|
+
# and commit this file to your remote git repository to share the goodness with others.
|
|
4
|
+
|
|
5
|
+
tasks:
|
|
6
|
+
- init: npm install && npm run build
|
|
7
|
+
|
|
8
|
+
|
package/README.md
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
[](/LICENSE)
|
|
2
|
+

|
|
3
|
+
[](https://github.com/sasjs/lint/issues?q=is%3Aissue+is%3Aclosed)
|
|
4
|
+
[](https://github.com/sasjs/lint/issues)
|
|
5
|
+

|
|
6
|
+
[](https://gitpod.io/#https://github.com/sasjs/lint)
|
|
2
7
|
|
|
3
8
|
# SAS Code linting and formatting
|
|
4
9
|
|
|
@@ -18,18 +23,43 @@ Configuration is via a `.sasjslint` file with the following structure (these are
|
|
|
18
23
|
"hasDoxygenHeader": true,
|
|
19
24
|
"hasMacroNameInMend": true,
|
|
20
25
|
"hasMacroParentheses": true,
|
|
26
|
+
"ignoreList": [
|
|
27
|
+
"sajsbuild/",
|
|
28
|
+
"sasjsresults/"
|
|
29
|
+
],
|
|
21
30
|
"indentationMultiple": 2,
|
|
22
31
|
"lowerCaseFileNames": true,
|
|
23
32
|
"maxLineLength": 80,
|
|
24
33
|
"noNestedMacros": true,
|
|
25
34
|
"noSpacesInFileNames": true,
|
|
26
35
|
"noTabIndentation": true,
|
|
27
|
-
"noTrailingSpaces": true
|
|
36
|
+
"noTrailingSpaces": true,
|
|
37
|
+
"defaultHeader": "/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/"
|
|
28
38
|
}
|
|
29
39
|
```
|
|
30
40
|
|
|
31
41
|
### SAS Lint Settings
|
|
32
42
|
|
|
43
|
+
#### defaultHeader
|
|
44
|
+
|
|
45
|
+
This sets the default program header - applies when a SAS program does NOT begin with `/**`. The default header is as follows:
|
|
46
|
+
|
|
47
|
+
```sas
|
|
48
|
+
/**
|
|
49
|
+
@file
|
|
50
|
+
@brief <Your brief here>
|
|
51
|
+
<h4> SAS Macros </h4>
|
|
52
|
+
**/
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The default header is automatically applied when running `sasjs lint fix` in the SASjs CLI, or by hitting "save" when using the SASjs VS Code extension. If creating a new value, use `{lineEnding}` instead of `\n`, eg as follows:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"defaultHeader": "/**{lineEnding} @file{lineEnding} @brief Our Company Brief{lineEnding}**/"
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
33
63
|
#### noEncodedPasswords
|
|
34
64
|
|
|
35
65
|
This will highlight any rows that contain a `{sas00X}` type password, or `{sasenc}`. These passwords (especially 001 and 002) are NOT secure, and should NEVER be pushed to source control or saved to the filesystem without special permissions applied.
|
|
@@ -55,6 +85,9 @@ As per the example [here](https://github.com/sasjs/lint/issues/20), macros defin
|
|
|
55
85
|
* Default: true
|
|
56
86
|
* Severity: WARNING
|
|
57
87
|
|
|
88
|
+
#### ignoreList
|
|
89
|
+
There may be specific files (or folders) that are not good candidates for linting. Simply list them in this array and they will be ignored. In addition, any files in the project `.gitignore` file will also be ignored.
|
|
90
|
+
|
|
58
91
|
#### indentationMultiple
|
|
59
92
|
This will check each line to ensure that the count of leading spaces can be divided cleanly by this multiple.
|
|
60
93
|
|
|
@@ -70,7 +103,7 @@ On *nix systems, it is imperative that autocall macros are in lowercase. When s
|
|
|
70
103
|
#### maxLineLength
|
|
71
104
|
Code becomes far more readable when line lengths are short. The most compelling reason for short line lengths is to avoid the need to scroll when performing a side-by-side 'compare' between two files (eg as part of a GIT feature branch review). A longer discussion on optimal code line length can be found [here](https://stackoverflow.com/questions/578059/studies-on-optimal-code-width)
|
|
72
105
|
|
|
73
|
-
In batch mode, long SAS code lines may also be truncated, causing hard-to-detect errors.
|
|
106
|
+
In batch mode, long SAS code lines may also be truncated, causing hard-to-detect errors.
|
|
74
107
|
|
|
75
108
|
We strongly recommend a line length limit, and set the bar at 80. To turn this feature off, set the value to 0.
|
|
76
109
|
|
|
@@ -78,7 +111,7 @@ We strongly recommend a line length limit, and set the bar at 80. To turn this
|
|
|
78
111
|
* Severity: WARNING
|
|
79
112
|
|
|
80
113
|
#### noNestedMacros
|
|
81
|
-
Where macros are defined inside other macros, they are recompiled every time the outer macro is invoked. Hence, it is widely considered inefficient, and bad practice, to nest macro definitions.
|
|
114
|
+
Where macros are defined inside other macros, they are recompiled every time the outer macro is invoked. Hence, it is widely considered inefficient, and bad practice, to nest macro definitions.
|
|
82
115
|
|
|
83
116
|
* Default: true
|
|
84
117
|
* Severity: WARNING
|
|
@@ -108,7 +141,7 @@ This will highlight lines with trailing spaces. Trailing spaces serve no useful
|
|
|
108
141
|
|
|
109
142
|
### Upcoming Linting Rules:
|
|
110
143
|
|
|
111
|
-
* `noTabs` -> does what it says on the tin
|
|
144
|
+
* `noTabs` -> does what it says on the tin
|
|
112
145
|
* `noGremlins` -> identifies all invisible characters, other than spaces / tabs / line endings. If you really need that bell character, use a hex literal!
|
|
113
146
|
* `lineEndings` -> set a standard line ending, such as LF or CRLF
|
|
114
147
|
|
|
@@ -118,13 +151,13 @@ A formatter will automatically apply rules when you hit SAVE, which can save a L
|
|
|
118
151
|
|
|
119
152
|
We've already implemented the following rules:
|
|
120
153
|
|
|
121
|
-
* Add the macro name to the %mend statement
|
|
122
|
-
* Add a doxygen header template if none exists
|
|
154
|
+
* Add the macro name to the %mend statement
|
|
155
|
+
* Add a doxygen header template if none exists
|
|
123
156
|
* Remove trailing spaces
|
|
124
157
|
|
|
125
158
|
We're looking to implement the following rules:
|
|
126
159
|
|
|
127
|
-
* Change tabs to spaces
|
|
160
|
+
* Change tabs to spaces
|
|
128
161
|
* zap gremlins
|
|
129
162
|
* fix line endings
|
|
130
163
|
|
|
@@ -145,3 +178,34 @@ The SAS 9 Health Check is a 'plug & play' product, that uses the [SAS 9 REST API
|
|
|
145
178
|
Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details.
|
|
146
179
|
|
|
147
180
|
|
|
181
|
+
|
|
182
|
+
## Contributors ✨
|
|
183
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
184
|
+
[](#contributors-)
|
|
185
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
186
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
187
|
+
|
|
188
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
189
|
+
<!-- prettier-ignore-start -->
|
|
190
|
+
<!-- markdownlint-disable -->
|
|
191
|
+
<table>
|
|
192
|
+
<tr>
|
|
193
|
+
<td align="center"><a href="https://github.com/Carus11"><img src="https://avatars.githubusercontent.com/u/4925828?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Carus Kyle</b></sub></a><br /><a href="#ideas-Carus11" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
194
|
+
<td align="center"><a href="https://github.com/allanbowe"><img src="https://avatars.githubusercontent.com/u/4420615?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Allan Bowe</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=allanbowe" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=allanbowe" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3Aallanbowe" title="Reviewed Pull Requests">👀</a> <a href="#video-allanbowe" title="Videos">📹</a> <a href="https://github.com/sasjs/lint/commits?author=allanbowe" title="Documentation">📖</a></td>
|
|
195
|
+
<td align="center"><a href="https://www.erudicat.com/"><img src="https://avatars.githubusercontent.com/u/25773492?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Yury Shkoda</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=YuryShkoda" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=YuryShkoda" title="Tests">⚠️</a> <a href="#projectManagement-YuryShkoda" title="Project Management">📆</a> <a href="#video-YuryShkoda" title="Videos">📹</a> <a href="https://github.com/sasjs/lint/commits?author=YuryShkoda" title="Documentation">📖</a></td>
|
|
196
|
+
<td align="center"><a href="https://krishna-acondy.io/"><img src="https://avatars.githubusercontent.com/u/2980428?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Krishna Acondy</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=krishna-acondy" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=krishna-acondy" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3Akrishna-acondy" title="Reviewed Pull Requests">👀</a> <a href="#infra-krishna-acondy" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#platform-krishna-acondy" title="Packaging/porting to new platform">📦</a> <a href="#maintenance-krishna-acondy" title="Maintenance">🚧</a> <a href="#content-krishna-acondy" title="Content">🖋</a></td>
|
|
197
|
+
<td align="center"><a href="https://github.com/saadjutt01"><img src="https://avatars.githubusercontent.com/u/8914650?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Muhammad Saad </b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=saadjutt01" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=saadjutt01" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3Asaadjutt01" title="Reviewed Pull Requests">👀</a> <a href="#mentoring-saadjutt01" title="Mentoring">🧑🏫</a> <a href="https://github.com/sasjs/lint/commits?author=saadjutt01" title="Documentation">📖</a></td>
|
|
198
|
+
<td align="center"><a href="https://github.com/sabhas"><img src="https://avatars.githubusercontent.com/u/82647447?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sabir Hassan</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=sabhas" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=sabhas" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3Asabhas" title="Reviewed Pull Requests">👀</a> <a href="#ideas-sabhas" title="Ideas, Planning, & Feedback">🤔</a></td>
|
|
199
|
+
<td align="center"><a href="https://github.com/medjedovicm"><img src="https://avatars.githubusercontent.com/u/18329105?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mihajlo Medjedovic</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=medjedovicm" title="Code">💻</a> <a href="https://github.com/sasjs/lint/commits?author=medjedovicm" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3Amedjedovicm" title="Reviewed Pull Requests">👀</a> <a href="#infra-medjedovicm" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
|
|
200
|
+
</tr>
|
|
201
|
+
<tr>
|
|
202
|
+
<td align="center"><a href="https://github.com/VladislavParhomchik"><img src="https://avatars.githubusercontent.com/u/83717836?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vladislav Parhomchik</b></sub></a><br /><a href="https://github.com/sasjs/lint/commits?author=VladislavParhomchik" title="Tests">⚠️</a> <a href="https://github.com/sasjs/lint/pulls?q=is%3Apr+reviewed-by%3AVladislavParhomchik" title="Reviewed Pull Requests">👀</a></td>
|
|
203
|
+
</tr>
|
|
204
|
+
</table>
|
|
205
|
+
|
|
206
|
+
<!-- markdownlint-restore -->
|
|
207
|
+
<!-- prettier-ignore-end -->
|
|
208
|
+
|
|
209
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
210
|
+
|
|
211
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const result = process.versions
|
|
2
|
+
if (result && result.node) {
|
|
3
|
+
if (parseInt(result.node) < 14) {
|
|
4
|
+
console.log(
|
|
5
|
+
'\x1b[31m%s\x1b[0m',
|
|
6
|
+
`❌ Process failed due to Node Version,\nPlease install and use Node Version >= 14\nYour current Node Version is: ${result.node}`
|
|
7
|
+
)
|
|
8
|
+
process.exit(1)
|
|
9
|
+
}
|
|
10
|
+
} else {
|
|
11
|
+
console.log(
|
|
12
|
+
'\x1b[31m%s\x1b[0m',
|
|
13
|
+
'Something went wrong while checking Node version'
|
|
14
|
+
)
|
|
15
|
+
process.exit(1)
|
|
16
|
+
}
|
package/format/shared.js
CHANGED
|
@@ -18,7 +18,7 @@ var processContent = function (config, content) {
|
|
|
18
18
|
config.fileLintRules
|
|
19
19
|
.filter(function (r) { return !!r.fix; })
|
|
20
20
|
.forEach(function (rule) {
|
|
21
|
-
processedContent = rule.fix(processedContent);
|
|
21
|
+
processedContent = rule.fix(processedContent, config);
|
|
22
22
|
});
|
|
23
23
|
return processedContent;
|
|
24
24
|
};
|
package/format/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/format/shared.ts"],"names":[],"mappings":";;;AACA,oDAAkD;AAClD,gDAA8C;AAEvC,IAAM,WAAW,GAAG,UAAC,IAAY,EAAE,MAAkB;IAC1D,IAAM,aAAa,GAAG,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAClD,IAAM,KAAK,GAAG,qBAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC9C,IAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,UAAC,IAAI;QACpC,OAAO,mBAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAClC,CAAC,CAAC,CAAA;IAEF,IAAM,oBAAoB,GACxB,MAAM,CAAC,WAAW,KAAK,yBAAW,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IACvD,OAAO,cAAc,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;AAClD,CAAC,CAAA;AAVY,QAAA,WAAW,eAUvB;AAED,IAAM,cAAc,GAAG,UAAC,MAAkB,EAAE,OAAe;IACzD,IAAI,gBAAgB,GAAG,OAAO,CAAA;IAC9B,MAAM,CAAC,aAAa;SACjB,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,EAAP,CAAO,CAAC;SACtB,OAAO,CAAC,UAAC,IAAI;QACZ,gBAAgB,GAAG,IAAI,CAAC,GAAI,CAAC,gBAAgB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/format/shared.ts"],"names":[],"mappings":";;;AACA,oDAAkD;AAClD,gDAA8C;AAEvC,IAAM,WAAW,GAAG,UAAC,IAAY,EAAE,MAAkB;IAC1D,IAAM,aAAa,GAAG,cAAc,CAAC,MAAM,EAAE,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
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LintConfig } from '../types
|
|
1
|
+
import { Diagnostic, LintConfig } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Analyses and produces a set of diagnostics for the file at the given path.
|
|
4
4
|
* @param {string} filePath - the path to the file to be linted.
|
|
5
5
|
* @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
|
|
6
|
-
* @returns {Diagnostic[]} array of diagnostic objects, each containing a warning, line number and column number.
|
|
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<
|
|
8
|
+
export declare const lintFile: (filePath: string, configuration?: LintConfig | undefined) => Promise<Diagnostic[]>;
|
package/lint/lintFile.js
CHANGED
|
@@ -59,29 +59,32 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
60
|
exports.lintFile = void 0;
|
|
61
61
|
var file_1 = require("@sasjs/utils/file");
|
|
62
|
-
var
|
|
62
|
+
var utils_1 = require("../utils");
|
|
63
63
|
var shared_1 = require("./shared");
|
|
64
64
|
/**
|
|
65
65
|
* Analyses and produces a set of diagnostics for the file at the given path.
|
|
66
66
|
* @param {string} filePath - the path to the file to be linted.
|
|
67
67
|
* @param {LintConfig} configuration - an optional configuration. When not passed in, this is read from the .sasjslint file.
|
|
68
|
-
* @returns {Diagnostic[]} array of diagnostic objects, each containing a warning, line number and column number.
|
|
68
|
+
* @returns {Promise<Diagnostic[]>} array of diagnostic objects, each containing a warning, line number and column number.
|
|
69
69
|
*/
|
|
70
70
|
var lintFile = function (filePath, configuration) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
71
|
var config, _a, text, fileDiagnostics, textDiagnostics;
|
|
72
72
|
return __generator(this, function (_b) {
|
|
73
73
|
switch (_b.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
_a = configuration;
|
|
76
|
-
if (_a) return [3 /*break*/, 2];
|
|
77
|
-
return [4 /*yield*/, getLintConfig_1.getLintConfig()];
|
|
74
|
+
case 0: return [4 /*yield*/, utils_1.isIgnored(filePath)];
|
|
78
75
|
case 1:
|
|
79
|
-
|
|
80
|
-
|
|
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
81
|
case 2:
|
|
82
|
+
_a = (_b.sent());
|
|
83
|
+
_b.label = 3;
|
|
84
|
+
case 3:
|
|
82
85
|
config = _a;
|
|
83
86
|
return [4 /*yield*/, file_1.readFile(filePath)];
|
|
84
|
-
case
|
|
87
|
+
case 4:
|
|
85
88
|
text = _b.sent();
|
|
86
89
|
fileDiagnostics = shared_1.processFile(filePath, config);
|
|
87
90
|
textDiagnostics = shared_1.processText(text, config);
|
package/lint/lintFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lintFile.js","sourceRoot":"","sources":["../../src/lint/lintFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4C;AAE5C,
|
|
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,CAAC,EAAA;;gBAA7B,IAAI,SAAyB;oBAAE,sBAAO,EAAE,EAAA;gBAEzB,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"}
|
package/lint/lintFolder.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Diagnostic } from '../types
|
|
2
|
-
import { LintConfig } from '../types/LintConfig';
|
|
1
|
+
import { Diagnostic, LintConfig } from '../types';
|
|
3
2
|
/**
|
|
4
3
|
* Analyses and produces a set of diagnostics for the folder at the given path.
|
|
5
4
|
* @param {string} folderPath - the path to the folder to be linted.
|
package/lint/lintFolder.js
CHANGED
|
@@ -63,9 +63,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
63
63
|
exports.lintFolder = void 0;
|
|
64
64
|
var file_1 = require("@sasjs/utils/file");
|
|
65
65
|
var path_1 = __importDefault(require("path"));
|
|
66
|
-
var
|
|
67
|
-
var getLintConfig_1 = require("../utils/getLintConfig");
|
|
68
|
-
var listSasFiles_1 = require("../utils/listSasFiles");
|
|
66
|
+
var utils_1 = require("../utils");
|
|
69
67
|
var lintFile_1 = require("./lintFile");
|
|
70
68
|
var excludeFolders = [
|
|
71
69
|
'.git',
|
|
@@ -88,17 +86,21 @@ var lintFolder = function (folderPath, configuration) { return __awaiter(void 0,
|
|
|
88
86
|
case 0:
|
|
89
87
|
_a = configuration;
|
|
90
88
|
if (_a) return [3 /*break*/, 2];
|
|
91
|
-
return [4 /*yield*/,
|
|
89
|
+
return [4 /*yield*/, utils_1.getLintConfig()];
|
|
92
90
|
case 1:
|
|
93
91
|
_a = (_b.sent());
|
|
94
92
|
_b.label = 2;
|
|
95
93
|
case 2:
|
|
96
94
|
config = _a;
|
|
97
95
|
diagnostics = new Map();
|
|
98
|
-
return [4 /*yield*/,
|
|
96
|
+
return [4 /*yield*/, utils_1.isIgnored(folderPath)];
|
|
99
97
|
case 3:
|
|
98
|
+
if (_b.sent())
|
|
99
|
+
return [2 /*return*/, diagnostics];
|
|
100
|
+
return [4 /*yield*/, utils_1.listSasFiles(folderPath)];
|
|
101
|
+
case 4:
|
|
100
102
|
fileNames = _b.sent();
|
|
101
|
-
return [4 /*yield*/,
|
|
103
|
+
return [4 /*yield*/, utils_1.asyncForEach(fileNames, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
104
|
var filePath, _a, _b, _c;
|
|
103
105
|
return __generator(this, function (_d) {
|
|
104
106
|
switch (_d.label) {
|
|
@@ -113,16 +115,18 @@ var lintFolder = function (folderPath, configuration) { return __awaiter(void 0,
|
|
|
113
115
|
}
|
|
114
116
|
});
|
|
115
117
|
}); })];
|
|
116
|
-
case
|
|
118
|
+
case 5:
|
|
117
119
|
_b.sent();
|
|
118
120
|
return [4 /*yield*/, file_1.listSubFoldersInFolder(folderPath)];
|
|
119
|
-
case
|
|
121
|
+
case 6:
|
|
120
122
|
subFolders = (_b.sent()).filter(function (f) { return !excludeFolders.includes(f); });
|
|
121
|
-
return [4 /*yield*/,
|
|
122
|
-
var subFolderDiagnostics;
|
|
123
|
+
return [4 /*yield*/, utils_1.asyncForEach(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
|
|
124
|
+
var subFolderPath, subFolderDiagnostics;
|
|
123
125
|
return __generator(this, function (_a) {
|
|
124
126
|
switch (_a.label) {
|
|
125
|
-
case 0:
|
|
127
|
+
case 0:
|
|
128
|
+
subFolderPath = path_1.default.join(folderPath, subFolder);
|
|
129
|
+
return [4 /*yield*/, exports.lintFolder(subFolderPath, config)];
|
|
126
130
|
case 1:
|
|
127
131
|
subFolderDiagnostics = _a.sent();
|
|
128
132
|
diagnostics = new Map(__spreadArray(__spreadArray([], __read(diagnostics)), __read(subFolderDiagnostics)));
|
|
@@ -130,7 +134,7 @@ var lintFolder = function (folderPath, configuration) { return __awaiter(void 0,
|
|
|
130
134
|
}
|
|
131
135
|
});
|
|
132
136
|
}); })];
|
|
133
|
-
case
|
|
137
|
+
case 7:
|
|
134
138
|
_b.sent();
|
|
135
139
|
return [2 /*return*/, diagnostics];
|
|
136
140
|
}
|
package/lint/lintFolder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lintFolder.js","sourceRoot":"","sources":["../../src/lint/lintFolder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0D;AAC1D,8CAAuB;
|
|
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,KAA2C;gBACnD,WAAW,GAA8B,IAAI,GAAG,EAAwB,CAAA;gBAExE,qBAAM,iBAAS,CAAC,UAAU,CAAC,EAAA;;gBAA/B,IAAI,SAA2B;o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
|
7
9
|
"prepublishOnly": "cp -r ./build/* . && rm -rf ./build && rm -rf ./src && rm tsconfig.json",
|
|
8
10
|
"postpublish": "git clean -fd",
|
|
9
|
-
"package:lib": "npm run build && cp ./package.json build && cp README.md build && cd build && npm version \"5.0.0\" && npm pack",
|
|
10
|
-
"lint:fix": "npx prettier --write
|
|
11
|
-
"lint": "npx prettier --check
|
|
11
|
+
"package:lib": "npm run build && cp ./package.json ./checkNodeVersion.js build && cp README.md build && cd build && npm version \"5.0.0\" && npm pack",
|
|
12
|
+
"lint:fix": "npx prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
|
|
13
|
+
"lint": "npx prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"",
|
|
12
14
|
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
|
13
15
|
},
|
|
14
16
|
"publishConfig": {
|
|
@@ -39,13 +41,15 @@
|
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@types/jest": "^26.0.23",
|
|
41
43
|
"@types/node": "^15.12.2",
|
|
44
|
+
"all-contributors-cli": "^6.20.0",
|
|
42
45
|
"jest": "^26.6.3",
|
|
43
46
|
"rimraf": "^3.0.2",
|
|
44
47
|
"ts-jest": "^26.5.6",
|
|
45
48
|
"typescript": "^4.3.2"
|
|
46
49
|
},
|
|
47
50
|
"dependencies": {
|
|
48
|
-
"@sasjs/utils": "^2.19.0"
|
|
51
|
+
"@sasjs/utils": "^2.19.0",
|
|
52
|
+
"ignore": "^5.2.0"
|
|
49
53
|
},
|
|
50
|
-
"version": "1.
|
|
54
|
+
"version": "1.13.0"
|
|
51
55
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasDoxygenHeader = void 0;
|
|
4
|
+
var types_1 = require("../../types");
|
|
4
5
|
var LineEndings_1 = require("../../types/LineEndings");
|
|
5
6
|
var LintRuleType_1 = require("../../types/LintRuleType");
|
|
6
7
|
var Severity_1 = require("../../types/Severity");
|
|
7
|
-
var
|
|
8
|
+
var getLintConfig_1 = require("../../utils/getLintConfig");
|
|
8
9
|
var name = 'hasDoxygenHeader';
|
|
9
10
|
var description = 'Enforce the presence of a Doxygen header at the start of each file.';
|
|
10
11
|
var message = 'File missing Doxygen header';
|
|
@@ -57,9 +58,10 @@ var fix = function (value, config) {
|
|
|
57
58
|
}
|
|
58
59
|
else if (result[0].message == messageForSingleAsterisk)
|
|
59
60
|
return value.replace('/*', '/**');
|
|
61
|
+
config = config || new types_1.LintConfig(getLintConfig_1.DefaultLintConfiguration);
|
|
60
62
|
var lineEndingConfig = (config === null || config === void 0 ? void 0 : config.lineEndings) || LineEndings_1.LineEndings.LF;
|
|
61
63
|
var lineEnding = lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n';
|
|
62
|
-
return "" +
|
|
64
|
+
return "" + (config === null || config === void 0 ? void 0 : config.defaultHeader.replace(/{lineEnding}/g, lineEnding)) + lineEnding + value;
|
|
63
65
|
};
|
|
64
66
|
/**
|
|
65
67
|
* Lint rule that checks for the presence of a Doxygen header in a given file.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,uDAAqD;AAErD,yDAAuD;AACvD,iDAA+C;AAC/C,2DAAoE;AAEpE,IAAM,IAAI,GAAG,kBAAkB,CAAA;AAC/B,IAAM,WAAW,GACf,qEAAqE,CAAA;AACvE,IAAM,OAAO,GAAG,6BAA6B,CAAA;AAC7C,IAAM,wBAAwB,GAC5B,+DAA+D,CAAA;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E,MAAmB;IAC7C,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAClC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;QACvB,OAAO,KAAK,CAAA;KACb;SAAM,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,wBAAwB;QACtD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAEnC,MAAM,GAAG,MAAM,IAAI,IAAI,kBAAU,CAAC,wCAAwB,CAAC,CAAA;IAC3D,IAAM,gBAAgB,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,yBAAW,CAAC,EAAE,CAAA;IAC9D,IAAM,UAAU,GAAG,gBAAgB,KAAK,yBAAW,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IAEtE,OAAO,MAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC,OAAO,CACrC,eAAe,EACf,UAAU,CACX,IAAG,UAAU,GAAG,KAAO,CAAA;AAC1B,CAAC,CAAA;AAED;;GAEG;AACU,QAAA,gBAAgB,GAAiB;IAC5C,IAAI,EAAE,2BAAY,CAAC,IAAI;IACvB,IAAI,MAAA;IACJ,WAAW,aAAA;IACX,OAAO,SAAA;IACP,IAAI,MAAA;IACJ,GAAG,KAAA;CACJ,CAAA"}
|
package/sasjslint-schema.json
CHANGED
|
@@ -17,7 +17,11 @@
|
|
|
17
17
|
"noTabIndentation": true,
|
|
18
18
|
"noTrailingSpaces": true,
|
|
19
19
|
"lineEndings": "lf",
|
|
20
|
-
"strictMacroDefinition": true
|
|
20
|
+
"strictMacroDefinition": true,
|
|
21
|
+
"ignoreList": [
|
|
22
|
+
"sajsbuild",
|
|
23
|
+
"sasjsresults"
|
|
24
|
+
]
|
|
21
25
|
},
|
|
22
26
|
"examples": [
|
|
23
27
|
{
|
|
@@ -33,7 +37,8 @@
|
|
|
33
37
|
"noNestedMacros": true,
|
|
34
38
|
"hasMacroParentheses": true,
|
|
35
39
|
"lineEndings": "crlf",
|
|
36
|
-
"strictMacroDefinition": true
|
|
40
|
+
"strictMacroDefinition": true,
|
|
41
|
+
"ignoreList": ["sajsbuild", "sasjsresults"]
|
|
37
42
|
}
|
|
38
43
|
],
|
|
39
44
|
"properties": {
|
|
@@ -140,6 +145,14 @@
|
|
|
140
145
|
"description": "Enforces Macro Definition syntax. Shows a warning when incorrect syntax is used.",
|
|
141
146
|
"default": true,
|
|
142
147
|
"examples": [true, false]
|
|
148
|
+
},
|
|
149
|
+
"ignoreList": {
|
|
150
|
+
"$id": "#/properties/ignoreList",
|
|
151
|
+
"type": "array",
|
|
152
|
+
"title": "ignoreList",
|
|
153
|
+
"description": "An array of paths or path patterns to ignore when linting. Any files or matching patterns in the .gitignore file will also be ignored.",
|
|
154
|
+
"default": ["sasjsbuild/", "sasjsresults/"],
|
|
155
|
+
"examples": ["sasjs/tests", "tmp/scratch.sas"]
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
158
|
}
|
package/types/LintConfig.d.ts
CHANGED
|
@@ -8,11 +8,13 @@ import { FileLintRule, LineLintRule, PathLintRule } from './LintRule';
|
|
|
8
8
|
* More types of rules, when available, will be added here.
|
|
9
9
|
*/
|
|
10
10
|
export declare class LintConfig {
|
|
11
|
+
readonly ignoreList: string[];
|
|
11
12
|
readonly lineLintRules: LineLintRule[];
|
|
12
13
|
readonly fileLintRules: FileLintRule[];
|
|
13
14
|
readonly pathLintRules: PathLintRule[];
|
|
14
15
|
readonly maxLineLength: number;
|
|
15
16
|
readonly indentationMultiple: number;
|
|
16
17
|
readonly lineEndings: LineEndings;
|
|
18
|
+
readonly defaultHeader: string;
|
|
17
19
|
constructor(json?: any);
|
|
18
20
|
}
|
package/types/LintConfig.js
CHANGED
|
@@ -5,6 +5,7 @@ var file_1 = require("../rules/file");
|
|
|
5
5
|
var line_1 = require("../rules/line");
|
|
6
6
|
var path_1 = require("../rules/path");
|
|
7
7
|
var LineEndings_1 = require("./LineEndings");
|
|
8
|
+
var utils_1 = require("../utils");
|
|
8
9
|
/**
|
|
9
10
|
* LintConfig is the logical representation of the .sasjslint file.
|
|
10
11
|
* It exposes two sets of rules - one to be run against each line in a file,
|
|
@@ -14,12 +15,28 @@ var LineEndings_1 = require("./LineEndings");
|
|
|
14
15
|
*/
|
|
15
16
|
var LintConfig = /** @class */ (function () {
|
|
16
17
|
function LintConfig(json) {
|
|
18
|
+
var _this = this;
|
|
19
|
+
this.ignoreList = [];
|
|
17
20
|
this.lineLintRules = [];
|
|
18
21
|
this.fileLintRules = [];
|
|
19
22
|
this.pathLintRules = [];
|
|
20
23
|
this.maxLineLength = 80;
|
|
21
24
|
this.indentationMultiple = 2;
|
|
22
25
|
this.lineEndings = LineEndings_1.LineEndings.LF;
|
|
26
|
+
this.defaultHeader = utils_1.getDefaultHeader();
|
|
27
|
+
if (json === null || json === void 0 ? void 0 : json.ignoreList) {
|
|
28
|
+
if (Array.isArray(json.ignoreList)) {
|
|
29
|
+
json.ignoreList.forEach(function (item) {
|
|
30
|
+
if (typeof item === 'string')
|
|
31
|
+
_this.ignoreList.push(item);
|
|
32
|
+
else
|
|
33
|
+
throw new Error("Property \"ignoreList\" has invalid type of values. It can contain only strings.");
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new Error("Property \"ignoreList\" can only be an array of strings");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
23
40
|
if (json === null || json === void 0 ? void 0 : json.noTrailingSpaces) {
|
|
24
41
|
this.lineLintRules.push(line_1.noTrailingSpaces);
|
|
25
42
|
}
|
|
@@ -48,6 +65,9 @@ var LintConfig = /** @class */ (function () {
|
|
|
48
65
|
if (json === null || json === void 0 ? void 0 : json.hasDoxygenHeader) {
|
|
49
66
|
this.fileLintRules.push(file_1.hasDoxygenHeader);
|
|
50
67
|
}
|
|
68
|
+
if (json === null || json === void 0 ? void 0 : json.defaultHeader) {
|
|
69
|
+
this.defaultHeader = json.defaultHeader;
|
|
70
|
+
}
|
|
51
71
|
if (json === null || json === void 0 ? void 0 : json.noSpacesInFileNames) {
|
|
52
72
|
this.pathLintRules.push(path_1.noSpacesInFileNames);
|
|
53
73
|
}
|
package/types/LintConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LintConfig.js","sourceRoot":"","sources":["../../src/types/LintConfig.ts"],"names":[],"mappings":";;;AAAA,sCAOsB;AACtB,sCAMsB;AACtB,sCAAuE;AACvE,6CAA2C;
|
|
1
|
+
{"version":3,"file":"LintConfig.js","sourceRoot":"","sources":["../../src/types/LintConfig.ts"],"names":[],"mappings":";;;AAAA,sCAOsB;AACtB,sCAMsB;AACtB,sCAAuE;AACvE,6CAA2C;AAE3C,kCAA2C;AAE3C;;;;;;GAMG;AACH;IAUE,oBAAY,IAAU;QAAtB,iBAiFC;QA1FQ,eAAU,GAAa,EAAE,CAAA;QACzB,kBAAa,GAAmB,EAAE,CAAA;QAClC,kBAAa,GAAmB,EAAE,CAAA;QAClC,kBAAa,GAAmB,EAAE,CAAA;QAClC,kBAAa,GAAW,EAAE,CAAA;QAC1B,wBAAmB,GAAW,CAAC,CAAA;QAC/B,gBAAW,GAAgB,yBAAW,CAAC,EAAE,CAAA;QACzC,kBAAa,GAAW,wBAAgB,EAAE,CAAA;QAGjD,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,UAAU,EAAE;YACpB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBAClC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,UAAC,IAAS;oBAChC,IAAI,OAAO,IAAI,KAAK,QAAQ;wBAAE,KAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;wBAEtD,MAAM,IAAI,KAAK,CACb,kFAAgF,CACjF,CAAA;gBACL,CAAC,C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+1,5 @@
|
|
|
1
1
|
import { LintConfig } from '../types/LintConfig';
|
|
2
|
+
export declare const getDefaultHeader: () => string;
|
|
2
3
|
/**
|
|
3
4
|
* Default configuration that is used when a .sasjslint file is not found
|
|
4
5
|
*/
|
|
@@ -15,6 +16,7 @@ export declare const DefaultLintConfiguration: {
|
|
|
15
16
|
noNestedMacros: boolean;
|
|
16
17
|
hasMacroParentheses: boolean;
|
|
17
18
|
strictMacroDefinition: boolean;
|
|
19
|
+
defaultHeader: string;
|
|
18
20
|
};
|
|
19
21
|
/**
|
|
20
22
|
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
package/utils/getLintConfig.js
CHANGED
|
@@ -39,11 +39,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.getLintConfig = exports.DefaultLintConfiguration = void 0;
|
|
42
|
+
exports.getLintConfig = exports.DefaultLintConfiguration = exports.getDefaultHeader = void 0;
|
|
43
43
|
var path_1 = __importDefault(require("path"));
|
|
44
44
|
var LintConfig_1 = require("../types/LintConfig");
|
|
45
45
|
var file_1 = require("@sasjs/utils/file");
|
|
46
46
|
var getProjectRoot_1 = require("./getProjectRoot");
|
|
47
|
+
var getDefaultHeader = function () {
|
|
48
|
+
return "/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding} <h4> SAS Macros </h4>{lineEnding}**/";
|
|
49
|
+
};
|
|
50
|
+
exports.getDefaultHeader = getDefaultHeader;
|
|
47
51
|
/**
|
|
48
52
|
* Default configuration that is used when a .sasjslint file is not found
|
|
49
53
|
*/
|
|
@@ -59,7 +63,8 @@ exports.DefaultLintConfiguration = {
|
|
|
59
63
|
hasMacroNameInMend: true,
|
|
60
64
|
noNestedMacros: true,
|
|
61
65
|
hasMacroParentheses: true,
|
|
62
|
-
strictMacroDefinition: true
|
|
66
|
+
strictMacroDefinition: true,
|
|
67
|
+
defaultHeader: exports.getDefaultHeader()
|
|
63
68
|
};
|
|
64
69
|
/**
|
|
65
70
|
* Fetches the config from the .sasjslint file and creates a LintConfig object.
|
|
@@ -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,8CAAuB;AACvB,kDAAgD;AAChD,0CAA4C;AAC5C,mDAAiD;AAE1C,IAAM,gBAAgB,GAAG;IAC9B,OAAA,gHAAgH;AAAhH,CAAgH,CAAA;AADrG,QAAA,gBAAgB,oBACqF;AAElH;;GAEG;AACU,QAAA,wBAAwB,GAAG;IACtC,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,IAAI;IACzB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,EAAE;IACjB,gBAAgB,EAAE,IAAI;IACtB,mBAAmB,EAAE,CAAC;IACtB,kBAAkB,EAAE,IAAI;IACxB,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,IAAI;IACzB,qBAAqB,EAAE,IAAI;IAC3B,aAAa,EAAE,wBAAgB,EAAE;CAClC,CAAA;AAED;;;;GAIG;AACH,SAAsB,aAAa;;;;;wBACb,qBAAM,+BAAc,EAAE,EAAA;;oBAApC,WAAW,GAAG,SAAsB;oBACpB,qBAAM,eAAQ,CAClC,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CACrC,CAAC,KAAK,CAAC,UAAC,CAAC;4BACR,OAAO,IAAI,CAAC,SAAS,CAAC,gCAAwB,CAAC,CAAA;wBACjD,CAAC,CAAC,EAAA;;oBAJI,aAAa,GAAG,SAIpB;oBACF,sBAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,EAAA;;;;CACjD;AARD,sCAQC"}
|
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -10,8 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./asyncForEach"), exports);
|
|
13
14
|
__exportStar(require("./getLintConfig"), exports);
|
|
14
15
|
__exportStar(require("./getProjectRoot"), exports);
|
|
16
|
+
__exportStar(require("./isIgnored"), exports);
|
|
15
17
|
__exportStar(require("./listSasFiles"), exports);
|
|
16
18
|
__exportStar(require("./splitText"), exports);
|
|
17
19
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA+B;AAC/B,mDAAgC;AAChC,iDAA8B;AAC9B,8CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,8CAA2B;AAC3B,iDAA8B;AAC9B,8CAA2B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LintConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* A function to check if file/folder path matches any pattern from .gitignore or ignoreList (.sasjsLint)
|
|
4
|
+
*
|
|
5
|
+
* @param {string} fPath - absolute path of file or folder
|
|
6
|
+
* @returns {Promise<boolean>} true if path matches the patterns from .gitignore file otherwise false
|
|
7
|
+
*/
|
|
8
|
+
export declare const isIgnored: (fPath: string, configuration?: LintConfig | undefined) => Promise<boolean>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.isIgnored = void 0;
|
|
43
|
+
var utils_1 = require("@sasjs/utils");
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var ignore_1 = __importDefault(require("ignore"));
|
|
46
|
+
var _1 = require(".");
|
|
47
|
+
/**
|
|
48
|
+
* A function to check if file/folder path matches any pattern from .gitignore or ignoreList (.sasjsLint)
|
|
49
|
+
*
|
|
50
|
+
* @param {string} fPath - absolute path of file or folder
|
|
51
|
+
* @returns {Promise<boolean>} true if path matches the patterns from .gitignore file otherwise false
|
|
52
|
+
*/
|
|
53
|
+
var isIgnored = function (fPath, configuration) { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var config, _a, projectRoot, gitIgnoreFilePath, rootPath, relativePath, gitIgnoreFileContent;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
_a = configuration;
|
|
59
|
+
if (_a) return [3 /*break*/, 2];
|
|
60
|
+
return [4 /*yield*/, _1.getLintConfig()];
|
|
61
|
+
case 1:
|
|
62
|
+
_a = (_b.sent());
|
|
63
|
+
_b.label = 2;
|
|
64
|
+
case 2:
|
|
65
|
+
config = _a;
|
|
66
|
+
return [4 /*yield*/, _1.getProjectRoot()];
|
|
67
|
+
case 3:
|
|
68
|
+
projectRoot = _b.sent();
|
|
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
|
+
}); };
|
|
89
|
+
exports.isIgnored = isIgnored;
|
|
90
|
+
//# sourceMappingURL=isIgnored.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isIgnored.js","sourceRoot":"","sources":["../../src/utils/isIgnored.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAmD;AACnD,8CAAuB;AACvB,kDAA2B;AAC3B,sBAAiD;AAGjD;;;;;GAKG;AACI,IAAM,SAAS,GAAG,UACvB,KAAa,EACb,aAA0B;;;;;gBAEX,KAAA,aAAa,CAAA;wBAAb,wBAAa;gBAAK,qBAAM,gBAAa,EAAE,EAAA;;gBAAtB,KAAA,CAAC,SAAqB,CAAC,CAAA;;;gBAAjD,MAAM,KAA2C;gBACnC,qBAAM,iBAAc,EAAE,EAAA;;gBAApC,WAAW,GAAG,SAAsB;gBACpC,iBAAiB,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAA;gBACxD,QAAQ,GAAG,WAAW,GAAG,cAAI,CAAC,GAAG,CAAA;gBACjC,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;gBAEhD,IAAI,KAAK,KAAK,WAAW;oBAAE,sBAAO,KAAK,EAAA;gBAEnC,oBAAoB,GAAG,EAAE,CAAA;gBAEzB,qBAAM,kBAAU,CAAC,iBAAiB,CAAC,EAAA;;qBAAnC,SAAmC,EAAnC,wBAAmC;gBACd,qBAAM,gBAAQ,CAAC,iBAAiB,CAAC,EAAA;;gBAAxD,oBAAoB,GAAG,SAAiC,CAAA;;oBAE1D,sBAAO,gBAAM,EAAE;qBACZ,GAAG,CAAC,oBAAoB,CAAC;qBACzB,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC;qBACtB,OAAO,CAAC,YAAY,CAAC,EAAA;;;KACzB,CAAA;AArBY,QAAA,SAAS,aAqBrB"}
|