@sasjs/lint 1.11.2 → 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.
@@ -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
+ }
@@ -1,7 +1,7 @@
1
1
  version: 2
2
2
  updates:
3
- - package-ecosystem: npm
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- open-pull-requests-limit: 10
3
+ - package-ecosystem: npm
4
+ directory: '/'
5
+ schedule:
6
+ interval: monthly
7
+ open-pull-requests-limit: 10
@@ -13,14 +13,15 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [12.x]
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@v1
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
@@ -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
- [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=sasjs/lint)](https://dependabot.com)
1
+ [![License](https://img.shields.io/apm/l/atomic-design-ui.svg)](/LICENSE)
2
+ ![GitHub top language](https://img.shields.io/github/languages/top/sasjs/lint)
3
+ [![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/sasjs/lint)](https://github.com/sasjs/lint/issues?q=is%3Aissue+is%3Aclosed)
4
+ [![GitHub issues](https://img.shields.io/github/issues-raw/sasjs/lint)](https://github.com/sasjs/lint/issues)
5
+ ![total lines](https://tokei.rs/b1/github/sasjs/lint)
6
+ [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/sasjs/lint)
2
7
 
3
8
  # SAS Code linting and formatting
4
9
 
@@ -145,3 +150,34 @@ The SAS 9 Health Check is a 'plug & play' product, that uses the [SAS 9 REST API
145
150
  Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details.
146
151
 
147
152
 
153
+
154
+ ## Contributors ✨
155
+ <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
156
+ [![All Contributors](https://img.shields.io/badge/all_contributors-8-orange.svg?style=flat-square)](#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
+ }
@@ -1,8 +1,8 @@
1
- import { LintConfig } from '../types/LintConfig';
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<import("..").Diagnostic[]>;
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 getLintConfig_1 = require("../utils/getLintConfig");
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
- _a = (_b.sent());
80
- _b.label = 2;
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 3:
87
+ case 4:
85
88
  text = _b.sent();
86
89
  fileDiagnostics = shared_1.processFile(filePath, config);
87
90
  textDiagnostics = shared_1.processText(text, config);
@@ -1 +1 @@
1
- {"version":3,"file":"lintFile.js","sourceRoot":"","sources":["../../src/lint/lintFile.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4C;AAE5C,wDAAsD;AACtD,mCAAmD;AAEnD;;;;;GAKG;AACI,IAAM,QAAQ,GAAG,UACtB,QAAgB,EAChB,aAA0B;;;;;gBAEX,KAAA,aAAa,CAAA;wBAAb,wBAAa;gBAAK,qBAAM,6BAAa,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;AAXY,QAAA,QAAQ,YAWpB"}
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"}
@@ -1,5 +1,4 @@
1
- import { Diagnostic } from '../types/Diagnostic';
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.
@@ -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 asyncForEach_1 = require("../utils/asyncForEach");
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*/, getLintConfig_1.getLintConfig()];
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*/, listSasFiles_1.listSasFiles(folderPath)];
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*/, asyncForEach_1.asyncForEach(fileNames, function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
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 4:
118
+ case 5:
117
119
  _b.sent();
118
120
  return [4 /*yield*/, file_1.listSubFoldersInFolder(folderPath)];
119
- case 5:
121
+ case 6:
120
122
  subFolders = (_b.sent()).filter(function (f) { return !excludeFolders.includes(f); });
121
- return [4 /*yield*/, asyncForEach_1.asyncForEach(subFolders, function (subFolder) { return __awaiter(void 0, void 0, void 0, function () {
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: return [4 /*yield*/, exports.lintFolder(path_1.default.join(folderPath, subFolder), config)];
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 6:
137
+ case 7:
134
138
  _b.sent();
135
139
  return [2 /*return*/, diagnostics];
136
140
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lintFolder.js","sourceRoot":"","sources":["../../src/lint/lintFolder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA0D;AAC1D,8CAAuB;AAGvB,sDAAoD;AACpD,wDAAsD;AACtD,sDAAoD;AACpD,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,q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Aa,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,11 +4,13 @@
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 '{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
11
- "lint": "npx prettier --check '{src,test}/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}'",
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.11.2"
54
+ "version": "1.12.0"
51
55
  }
@@ -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
  }
@@ -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[];
@@ -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
  }
@@ -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;IAQE,oBAAY,IAAU;QAPb,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;QAGhD,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,uBAAgB,CAAC,CAAA;SAC1C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,kBAAkB,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAkB,CAAC,CAAA;SAC5C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,gBAAgB,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,uBAAgB,CAAC,CAAA;SAC1C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,EAAE;YACvB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;YACvC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,oBAAa,CAAC,CAAA;SACvC;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI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CAAE,gBAAgB,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,uBAAgB,CAAC,CAAA;SAC1C;QAED,IAAI,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,kBAAkB,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAkB,CAAC,CAAA;SAC5C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,kBAAkB,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,yBAAkB,CAAC,CAAA;SAC5C;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,cAAc,EAAE;YACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,qBAAc,CAAC,CAAA;SACxC;QAED,IAAI,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
@@ -1,4 +1,6 @@
1
+ export * from './asyncForEach';
1
2
  export * from './getLintConfig';
2
3
  export * from './getProjectRoot';
4
+ export * from './isIgnored';
3
5
  export * from './listSasFiles';
4
6
  export * from './splitText';
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
@@ -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"}