@sasjs/lint 1.11.0 → 1.12.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/dependabot.yml +5 -5
- package/.github/workflows/build.yml +3 -2
- package/CONTRIBUTING.md +54 -0
- package/README.md +51 -10
- package/checkNodeVersion.js +16 -0
- 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 +12 -8
- package/rules/file/hasDoxygenHeader.js +21 -3
- package/rules/file/hasDoxygenHeader.js.map +1 -1
- package/sasjslint-schema.json +8 -0
- package/types/LintConfig.d.ts +1 -0
- package/types/LintConfig.js +15 -0
- package/types/LintConfig.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
|
+
}
|
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/CONTRIBUTING.md
ADDED
|
@@ -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.
|
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
|
|
|
@@ -44,7 +49,7 @@ The SASjs framework recommends the use of Doxygen headers for describing all typ
|
|
|
44
49
|
* Severity: WARNING
|
|
45
50
|
|
|
46
51
|
#### hasMacroNameInMend
|
|
47
|
-
The addition of the macro name in the `%mend` statement is optional, but can approve readability in large programs. A discussion on this topic can be found [here](https://www.linkedin.com/posts/allanbowe_sas-sasapps-sasjs-activity-6783413360781266945-1-7m). The default setting
|
|
52
|
+
The addition of the macro name in the `%mend` statement is optional, but can approve readability in large programs. A discussion on this topic can be found [here](https://www.linkedin.com/posts/allanbowe_sas-sasapps-sasjs-activity-6783413360781266945-1-7m). The default setting was the result of a poll with over 300 votes.
|
|
48
53
|
|
|
49
54
|
* Default: true
|
|
50
55
|
* Severity: WARNING
|
|
@@ -72,13 +77,13 @@ Code becomes far more readable when line lengths are short. The most compelling
|
|
|
72
77
|
|
|
73
78
|
In batch mode, long SAS code lines may also be truncated, causing hard-to-detect errors.
|
|
74
79
|
|
|
75
|
-
|
|
80
|
+
We strongly recommend a line length limit, and set the bar at 80. To turn this feature off, set the value to 0.
|
|
76
81
|
|
|
77
82
|
* Default: 80
|
|
78
83
|
* Severity: WARNING
|
|
79
84
|
|
|
80
85
|
#### noNestedMacros
|
|
81
|
-
Where macros are defined inside other macros, they are recompiled every time the outer
|
|
86
|
+
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
87
|
|
|
83
88
|
* Default: true
|
|
84
89
|
* Severity: WARNING
|
|
@@ -95,7 +100,7 @@ In addition, when such files are used in URLs, they are often padded with a mess
|
|
|
95
100
|
* Severity: WARNING
|
|
96
101
|
|
|
97
102
|
#### noTabIndentation
|
|
98
|
-
Whilst there are some arguments for using tabs to indent (such as the ability to set your own indentation width, and to
|
|
103
|
+
Whilst there are some arguments for using tabs to indent (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).
|
|
99
104
|
|
|
100
105
|
* Default: true
|
|
101
106
|
* Severity: WARNING
|
|
@@ -116,14 +121,19 @@ This will highlight lines with trailing spaces. Trailing spaces serve no useful
|
|
|
116
121
|
|
|
117
122
|
A formatter will automatically apply rules when you hit SAVE, which can save a LOT of time.
|
|
118
123
|
|
|
119
|
-
We'
|
|
124
|
+
We've already implemented the following rules:
|
|
120
125
|
|
|
121
|
-
* Remove trailing spaces
|
|
122
|
-
* Change tabs to spaces
|
|
123
126
|
* Add the macro name to the %mend statement
|
|
124
127
|
* Add a doxygen header template if none exists
|
|
128
|
+
* Remove trailing spaces
|
|
125
129
|
|
|
126
|
-
|
|
130
|
+
We're looking to implement the following rules:
|
|
131
|
+
|
|
132
|
+
* Change tabs to spaces
|
|
133
|
+
* zap gremlins
|
|
134
|
+
* fix line endings
|
|
135
|
+
|
|
136
|
+
We are also investigating some harder stuff, such as automatic indentation and code layout
|
|
127
137
|
|
|
128
138
|
## Sponsorship & Contributions
|
|
129
139
|
|
|
@@ -133,10 +143,41 @@ Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details
|
|
|
133
143
|
|
|
134
144
|
## SAS 9 Health check
|
|
135
145
|
|
|
136
|
-
The SASjs Linter (and formatter) is a great way to de-risk and accelerate the delivery of SAS code into production environments. However, code is just one part of a SAS estate. If you are running SAS 9, you may be interested to know what 'gremlins' are lurking in your system. Maybe you are preparing for a migration. Maybe you are preparing to hand over the control of your environment. Either way, an assessment of your existing system would put minds at rest and pro-actively identify trouble spots.
|
|
146
|
+
The SASjs Linter (and formatter) is a great way to de-risk and accelerate the delivery of SAS code into production environments. However, code is just one part of a SAS estate. If you are running SAS 9, you may be interested to know what 'gremlins' are lurking in your SAS 9 system. Maybe you are preparing for a migration. Maybe you are preparing to hand over the control of your environment. Either way, an assessment of your existing system would put minds at rest and pro-actively identify trouble spots.
|
|
137
147
|
|
|
138
148
|
The SAS 9 Health Check is a 'plug & play' product, that uses the [SAS 9 REST API](https://sas9api.io) to run hundreds of metadata and system checks to identify common problems. The checks are non-invasive, and becuase it is a client app, there is NOTHING TO INSTALL on your SAS server. We offer this assessment for a low fixed fee, and if you engage our (competitively priced) services to address the issues we highlight, then the assessment is free.
|
|
139
149
|
|
|
140
150
|
Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details.
|
|
141
151
|
|
|
142
152
|
|
|
153
|
+
|
|
154
|
+
## Contributors ✨
|
|
155
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
156
|
+
[](#contributors-)
|
|
157
|
+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
158
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
159
|
+
|
|
160
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
161
|
+
<!-- prettier-ignore-start -->
|
|
162
|
+
<!-- markdownlint-disable -->
|
|
163
|
+
<table>
|
|
164
|
+
<tr>
|
|
165
|
+
<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>
|
|
166
|
+
<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>
|
|
167
|
+
<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>
|
|
168
|
+
<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>
|
|
169
|
+
<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>
|
|
170
|
+
<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>
|
|
171
|
+
<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>
|
|
172
|
+
</tr>
|
|
173
|
+
<tr>
|
|
174
|
+
<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>
|
|
175
|
+
</tr>
|
|
176
|
+
</table>
|
|
177
|
+
|
|
178
|
+
<!-- markdownlint-restore -->
|
|
179
|
+
<!-- prettier-ignore-end -->
|
|
180
|
+
|
|
181
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
182
|
+
|
|
183
|
+
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/lint/lintFile.d.ts
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;oBAAE,sBAAO,WAAW,EAAA;gBAEjC,qBAAM,oBAAY,CAAC,UAAU,CAAC,EAAA;;gBAA1C,SAAS,GAAG,SAA8B;gBAChD,qBAAM,oBAAY,CAAC,SAAS,EAAE,UAAO,QAAQ;;;;;oCACrC,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;oCAChD,KAAA,CAAA,KAAA,WAAW,CAAA,CAAC,GAAG,CAAA;0CAAC,QAAQ;oCAAE,qBAAM,mBAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAA;;oCAA1D,wBAA0B,SAAgC,GAAC,CAAA;;;;yBAC5D,CAAC,EAAA;;gBAHF,SAGE,CAAA;gBAEkB,qBAAM,6BAAsB,CAAC,UAAU,CAAC,EAAA;;gBAAtD,UAAU,GAAG,CAAC,SAAwC,CAAC,CAAC,MAAM,CAClE,UAAC,CAAS,IAAK,OAAA,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,EAA3B,CAA2B,CAC3C;gBAED,qBAAM,oBAAY,CAAC,UAAU,EAAE,UAAO,SAAS;;;;;oCACvC,aAAa,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;oCACzB,qBAAM,kBAAU,CAAC,aAAa,EAAE,MAAM,CAAC,EAAA;;oCAA9D,oBAAoB,GAAG,SAAuC;oCACpE,WAAW,GAAG,IAAI,GAAG,wCAAK,WAAW,WAAK,oBAAoB,GAAE,CAAA;;;;yBACjE,CAAC,EAAA;;gBAJF,SAIE,CAAA;gBAEF,sBAAO,WAAW,EAAA;;;KACnB,CAAA;AA1BY,QAAA,UAAU,cA0BtB"}
|
package/package.json
CHANGED
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
"scripts": {
|
|
5
5
|
"test": "jest --coverage",
|
|
6
6
|
"build": "rimraf build && tsc",
|
|
7
|
+
"preinstall": "node checkNodeVersion",
|
|
8
|
+
"prebuild": "node checkNodeVersion",
|
|
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
|
|
12
|
-
"
|
|
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}\"",
|
|
14
|
+
"prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
|
|
13
15
|
},
|
|
14
16
|
"publishConfig": {
|
|
15
17
|
"access": "public"
|
|
@@ -38,14 +40,16 @@
|
|
|
38
40
|
"homepage": "https://github.com/sasjs/lint#readme",
|
|
39
41
|
"devDependencies": {
|
|
40
42
|
"@types/jest": "^26.0.23",
|
|
41
|
-
"@types/node": "^15.
|
|
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
|
-
"typescript": "^4.2
|
|
48
|
+
"typescript": "^4.3.2"
|
|
46
49
|
},
|
|
47
50
|
"dependencies": {
|
|
48
|
-
"@sasjs/utils": "^2.
|
|
51
|
+
"@sasjs/utils": "^2.19.0",
|
|
52
|
+
"ignore": "^5.2.0"
|
|
49
53
|
},
|
|
50
|
-
"version": "1.
|
|
54
|
+
"version": "1.12.0"
|
|
51
55
|
}
|
|
@@ -8,11 +8,26 @@ var DoxygenHeader = "/**{lineEnding} @file{lineEnding} @brief <Your brief here
|
|
|
8
8
|
var name = 'hasDoxygenHeader';
|
|
9
9
|
var description = 'Enforce the presence of a Doxygen header at the start of each file.';
|
|
10
10
|
var message = 'File missing Doxygen header';
|
|
11
|
-
var
|
|
11
|
+
var messageForSingleAsterisk = 'File not following Doxygen header style, use double asterisks';
|
|
12
|
+
var test = function (value, config) {
|
|
13
|
+
var _a;
|
|
14
|
+
var lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
12
15
|
try {
|
|
13
|
-
var hasFileHeader = value.trimStart().startsWith('
|
|
16
|
+
var hasFileHeader = value.trimStart().startsWith('/**');
|
|
14
17
|
if (hasFileHeader)
|
|
15
18
|
return [];
|
|
19
|
+
var hasFileHeaderWithSingleAsterisk = value.trimStart().startsWith('/*');
|
|
20
|
+
if (hasFileHeaderWithSingleAsterisk)
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
message: messageForSingleAsterisk,
|
|
24
|
+
lineNumber: ((_a = value.split('/*')[0].match(new RegExp(lineEnding, 'g'))) !== null && _a !== void 0 ? _a : [])
|
|
25
|
+
.length + 1,
|
|
26
|
+
startColumnNumber: 1,
|
|
27
|
+
endColumnNumber: 1,
|
|
28
|
+
severity: Severity_1.Severity.Warning
|
|
29
|
+
}
|
|
30
|
+
];
|
|
16
31
|
return [
|
|
17
32
|
{
|
|
18
33
|
message: message,
|
|
@@ -36,9 +51,12 @@ var test = function (value) {
|
|
|
36
51
|
}
|
|
37
52
|
};
|
|
38
53
|
var fix = function (value, config) {
|
|
39
|
-
|
|
54
|
+
var result = test(value, config);
|
|
55
|
+
if (result.length === 0) {
|
|
40
56
|
return value;
|
|
41
57
|
}
|
|
58
|
+
else if (result[0].message == messageForSingleAsterisk)
|
|
59
|
+
return value.replace('/*', '/**');
|
|
42
60
|
var lineEndingConfig = (config === null || config === void 0 ? void 0 : config.lineEndings) || LineEndings_1.LineEndings.LF;
|
|
43
61
|
var lineEnding = lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n';
|
|
44
62
|
return "" + DoxygenHeader.replace(/{lineEnding}/g, lineEnding) + lineEnding + value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AAErD,yDAAuD;AACvD,iDAA+C;AAE/C,IAAM,aAAa,GAAG,gHAAgH,CAAA;AAEtI,IAAM,IAAI,GAAG,kBAAkB,CAAA;AAC/B,IAAM,WAAW,GACf,qEAAqE,CAAA;AACvE,IAAM,OAAO,GAAG,6BAA6B,CAAA;AAC7C,IAAM,IAAI,GAAG,UAAC,KAAa;
|
|
1
|
+
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AAErD,yDAAuD;AACvD,iDAA+C;AAE/C,IAAM,aAAa,GAAG,gHAAgH,CAAA;AAEtI,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;AACjE,IAAM,IAAI,GAAG,UAAC,KAAa,EAAE,MAAmB;;IAC9C,IAAM,UAAU,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,MAAK,yBAAW,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA;IAC3E,IAAI;QACF,IAAM,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;QACzD,IAAI,aAAa;YAAE,OAAO,EAAE,CAAA;QAE5B,IAAM,+BAA+B,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;QAC1E,IAAI,+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AAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IAEtE,OAAO,KAAG,aAAa,CAAC,OAAO,CAC7B,eAAe,EACf,UAAU,CACX,GAAG,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
|
@@ -140,6 +140,14 @@
|
|
|
140
140
|
"description": "Enforces Macro Definition syntax. Shows a warning when incorrect syntax is used.",
|
|
141
141
|
"default": true,
|
|
142
142
|
"examples": [true, false]
|
|
143
|
+
},
|
|
144
|
+
"ignoreList": {
|
|
145
|
+
"$id": "#/properties/ignoreList",
|
|
146
|
+
"type": "object",
|
|
147
|
+
"title": "ignoreList",
|
|
148
|
+
"description": "An array of paths or path patterns to ignore matching resources from linting. Files or folders matching patterns in .gitignore will always be ignored.",
|
|
149
|
+
"default": ["sasjsbuild/", "sasjsresults/"],
|
|
150
|
+
"examples": ["sasjs/services", "appinit.sas"]
|
|
143
151
|
}
|
|
144
152
|
}
|
|
145
153
|
}
|
package/types/LintConfig.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ 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[];
|
package/types/LintConfig.js
CHANGED
|
@@ -14,12 +14,27 @@ var LineEndings_1 = require("./LineEndings");
|
|
|
14
14
|
*/
|
|
15
15
|
var LintConfig = /** @class */ (function () {
|
|
16
16
|
function LintConfig(json) {
|
|
17
|
+
var _this = this;
|
|
18
|
+
this.ignoreList = [];
|
|
17
19
|
this.lineLintRules = [];
|
|
18
20
|
this.fileLintRules = [];
|
|
19
21
|
this.pathLintRules = [];
|
|
20
22
|
this.maxLineLength = 80;
|
|
21
23
|
this.indentationMultiple = 2;
|
|
22
24
|
this.lineEndings = LineEndings_1.LineEndings.LF;
|
|
25
|
+
if (json === null || json === void 0 ? void 0 : json.ignoreList) {
|
|
26
|
+
if (Array.isArray(json.ignoreList)) {
|
|
27
|
+
json.ignoreList.forEach(function (item) {
|
|
28
|
+
if (typeof item === 'string')
|
|
29
|
+
_this.ignoreList.push(item);
|
|
30
|
+
else
|
|
31
|
+
throw new Error("Property \"ignoreList\" has invalid type of values. It can contain only strings.");
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new Error("Property \"ignoreList\" can only be an array of strings");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
if (json === null || json === void 0 ? void 0 : json.noTrailingSpaces) {
|
|
24
39
|
this.lineLintRules.push(line_1.noTrailingSpaces);
|
|
25
40
|
}
|
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;AAG3C;;;;;;GAMG;AACH;
|
|
1
|
+
{"version":3,"file":"LintConfig.js","sourceRoot":"","sources":["../../src/types/LintConfig.ts"],"names":[],"mappings":";;;AAAA,sCAOsB;AACtB,sCAMsB;AACtB,sCAAuE;AACvE,6CAA2C;AAG3C;;;;;;GAMG;AACH;IASE,oBAAY,IAAU;QAAtB,iBA6EC;QArFQ,eAAU,GAAa,EAAE,CAAA;QACzB,kBAAa,GAAmB,EAAE,CAAA;QAClC,kBAAa,GAAmB,EAAE,CAAA;QAClC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IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,mBAAmB,EAAE;YAC7B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,0BAAmB,CAAC,CAAA;SAC7C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,qBAAqB,EAAE;YAC/B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,4BAAqB,CAAC,CAAA;SAC/C;IACH,CAAC;IACH,iBAAC;AAAD,CAAC,AAvFD,IAuFC;AAvFY,gCAAU"}
|
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"}
|