@sasjs/lint 4.1.4 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CONTRIBUTING.md +111 -36
- package/.github/workflows/publish.yml +71 -5
- package/README.md +30 -14
- package/package.json +2 -2
- package/rules/file/hasDoxygenHeader.js +1 -3
- package/rules/file/hasDoxygenHeader.js.map +1 -1
- package/rules/file/hasMacroNameInMend.js +3 -3
- package/rules/file/hasMacroNameInMend.js.map +1 -1
- package/rules/file/lineEndings.d.ts +2 -1
- package/rules/file/lineEndings.js +26 -3
- package/rules/file/lineEndings.js.map +1 -1
- package/rules/file/noNestedMacros.js +2 -3
- package/rules/file/noNestedMacros.js.map +1 -1
- package/rules/file/noUndeclaredMacros.js +7 -2
- package/rules/file/noUndeclaredMacros.js.map +1 -1
- package/sasjslint-schema.json +13 -3
- package/types/LintConfig.d.ts +1 -0
- package/types/LintConfig.js +28 -1
- package/types/LintConfig.js.map +1 -1
- package/utils/defaultIgnoredMacros.d.ts +7 -0
- package/utils/defaultIgnoredMacros.js +11 -0
- package/utils/defaultIgnoredMacros.js.map +1 -0
- package/utils/getLintConfig.d.ts +1 -0
- package/utils/getLintConfig.js +2 -0
- 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/parseMacros.js +2 -3
- package/utils/parseMacros.js.map +1 -1
- package/utils/splitLines.d.ts +16 -0
- package/utils/splitLines.js +21 -0
- package/utils/splitLines.js.map +1 -0
package/.github/CONTRIBUTING.md
CHANGED
|
@@ -1,61 +1,108 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
Contributions to `@sasjs/lint` are very welcome
|
|
4
|
-
|
|
3
|
+
Contributions to `@sasjs/lint` are very welcome. This repo is a TypeScript library with no SAS dependency - it reads `.sas` files as text - so you can work on every rule, the formatter and the JSON schema with Node alone.
|
|
4
|
+
|
|
5
|
+
Please fill in the pull request template and make sure your changes are covered by tests.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
Node 22 or later (the `engines` field), and no lifecycle scripts:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/sasjs/lint.git
|
|
13
|
+
cd lint
|
|
14
|
+
npm ci # .npmrc sets ignore-scripts=true, so nothing runs on install
|
|
15
|
+
git config core.hooksPath ./.git-hooks # the prepare script is one of those scripts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm test # jest WITH the coverage gate - this is the one CI runs
|
|
22
|
+
npm run lint # prettier --check over src and test
|
|
23
|
+
npx tsc --noEmit # type check
|
|
24
|
+
npm run build # emit ./build, needed by anything that requires the built library
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`npx jest` alone does not apply the coverage threshold, so a change can look green locally and fail CI. Use `npm test`.
|
|
28
|
+
|
|
29
|
+
## Where things live
|
|
30
|
+
|
|
31
|
+
- `src/rules/file/`, `src/rules/line/`, `src/rules/path/` - one module per rule, `<name>.ts` plus `<name>.spec.ts`, each re-exported from its folder's `index.ts`.
|
|
32
|
+
- `src/lint/` - `lintText`, `lintFile`, `lintFolder`, `lintProject`, and `shared.ts` (`processText`, `processFile`, `processLine`).
|
|
33
|
+
- `src/format/` - `formatText`, `formatFile`, `formatFolder`, `formatProject`, and `shared.ts`.
|
|
34
|
+
- `src/types/` - `LintConfig.ts` (the rule registry and defaults), `LintRule.ts` (the File/Line/Path interfaces), `Diagnostic.ts`, `Severity.ts`, `LineEndings.ts`.
|
|
35
|
+
- `src/utils/` - shared helpers: `splitText`, `splitLines`, `getHeaderLinesCount`, `parseMacros`, `parseMacroCalls`, `headerMacros`, `mergeLintConfig`, `parseLintOverride`, `sasMacros`.
|
|
36
|
+
- `sasjslint-schema.json` and `README.md` - the public contract for every setting.
|
|
5
37
|
|
|
6
38
|
## Architecture
|
|
7
39
|
|
|
8
|
-
|
|
40
|
+
There are three types of rule:
|
|
9
41
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
42
|
+
- File rules - run once against the whole file
|
|
43
|
+
- Line rules - run once per line
|
|
44
|
+
- Path rules - run against a file path or name
|
|
13
45
|
|
|
14
|
-
|
|
15
|
-
Please also make sure to export it from the `index.ts` file in that folder.
|
|
46
|
+
A rule exports an object conforming to the `LintRule` interface: `type`, `name`, `description` and `message` at minimum. File, line and path rules also have `test`, a function returning `Diagnostic[]` for the consuming application to display. Rules that can repair what they find also have `fix`, which takes the original content - a line or the whole file - and returns it transformed. Path rules have no `fix`.
|
|
16
47
|
|
|
17
|
-
|
|
18
|
-
This means it will have a `type`, `name`, `description` and `message` at a minimum.
|
|
48
|
+
`test` reports positions as `lineNumber`, `startColumnNumber` and `endColumnNumber`. Severity comes from `config.severityLevel[name] || Severity.Warning`, so a rule must read its own name key.
|
|
19
49
|
|
|
20
|
-
|
|
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.
|
|
50
|
+
## Adding a rule
|
|
23
51
|
|
|
24
|
-
|
|
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.
|
|
52
|
+
Moving the check into an existing rule versus adding a new one is a design call. A rule that must be separately switchable cannot be folded into another, because `severityLevel` is per rule NAME - one name means one opt-out. Check what the neighbouring rule's registration condition is first: a rule that only registers when a key is an explicit non-`off` value drags its whole remit along with any check folded in.
|
|
27
53
|
|
|
28
|
-
|
|
54
|
+
When a new rule is the right answer:
|
|
55
|
+
|
|
56
|
+
1. Add `src/rules/<type>/X.ts` and `X.spec.ts`.
|
|
57
|
+
2. Export it from `src/rules/<type>/index.ts`.
|
|
58
|
+
3. Register it in `src/types/LintConfig.ts`, choosing the default posture:
|
|
59
|
+
- `if (json?.X !== false)` pushes a rule that is ON by default;
|
|
60
|
+
- `if (json?.X)` pushes one that is OFF by default.
|
|
61
|
+
A rule whose `fix` must run during autoformat has to be ON, because the fix only runs for rules present in the config.
|
|
62
|
+
4. Add the key to the README config block and a `### X` section in alphabetical position, with `Default:` and `Severity:`.
|
|
63
|
+
5. Add the schema entries in `sasjslint-schema.json`: the `default` object, the `examples` object, a `properties.X` block, and a `severityLevel.properties.X` entry.
|
|
64
|
+
6. Add specs for both the default-on and the default-off path.
|
|
29
65
|
|
|
30
|
-
|
|
31
|
-
It helps us ensure that our lint rules do what they are intended to do.
|
|
66
|
+
There is no "warn but do not fix" state. A rule with a `fix` either has both warning and repairing active, or is absent and does neither. If your `fix` rewrites files, defaulting it ON changes the output of `sasjs lint fix` and format-on-save for every existing user, so say so in the PR and mark the commit accordingly.
|
|
32
67
|
|
|
33
|
-
|
|
34
|
-
This makes `@sasjs/lint` very easy to unit test, and so there is no excuse for not testing a new rule. :)
|
|
68
|
+
## The three documents that must agree
|
|
35
69
|
|
|
36
|
-
|
|
37
|
-
When modifying an existing rule, ensure that your changes haven't affected existing functionality by running the tests on your machine.
|
|
70
|
+
`DefaultLintConfiguration` (`src/utils/getLintConfig.ts`), the fenced config block in `README.md`, and the `default` object in `sasjslint-schema.json` state the same thing, and they drift. Treat them as one artifact: complete the default object first, then mirror it into both documents. `src/utils/getLintConfig.spec.ts` fails if any of the three disagree, and also enumerates the settings the constructor reads, so a setting added to `LintConfig` but not to the defaults is caught. An absent key must mean the documented default - a project with no `.sasjslint` and a project whose file omits the key must get the same rule set.
|
|
38
71
|
|
|
39
|
-
|
|
72
|
+
## Reading a file: one split for line endings
|
|
40
73
|
|
|
41
|
-
|
|
74
|
+
Readers must not split content on the ending CONFIGURED in `lineEndings`. That value says what the project wants, not what the file contains, and the lint path does not normalise - so a `crlf` split over an LF file returns one string holding the whole file, and column lookups then throw. Use `splitLines` (`src/utils/splitLines.ts`), which splits on `\r\n` or `\n` and drops the carriage returns. Writers still join with the configured ending.
|
|
42
75
|
|
|
43
|
-
|
|
44
|
-
If you are using VS Code for development, you can automatically fix your code to match the style as follows:
|
|
76
|
+
The formatter currently survives the mismatch because `lineEndings.fix` runs before the later rules, but that is not a licence for a reader to assume it: `formatFile` lints before it formats.
|
|
45
77
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
78
|
+
## Formatter rules
|
|
79
|
+
|
|
80
|
+
Only file and line rules that carry a `fix` run during formatting, in the order they were pushed onto the config. `hasDoxygenHeader` is pushed first, so with the default config a `fix` may assume a Doxygen header exists - but it must still return the text unchanged when there is none.
|
|
81
|
+
|
|
82
|
+
A `fix` must be idempotent: format the same file twice and the second pass must change nothing. Formatting a corpus twice and comparing is the quickest way to prove it. A non-idempotent fix shows up as churn and an inflated `fixedDiagnosticsCount`.
|
|
83
|
+
|
|
84
|
+
Two rules can reconcile the same header from opposite sides - `noUndeclaredMacros` adds used-but-undeclared names and `noUnusedMacros` removes declared-but-unused ones - so a removal helper must keep the `<h4> SAS Macros </h4>` heading when the list empties, or the add side loses its place to write.
|
|
85
|
+
|
|
86
|
+
## Testing
|
|
53
87
|
|
|
54
|
-
|
|
88
|
+
Most of the code is pure functions, so there is little to mock and no excuse for not testing a rule. When adding a rule, test the positive and negative scenarios in separate cases; when changing one, run the suite to prove nothing else moved.
|
|
89
|
+
|
|
90
|
+
Two habits catch the failures that plain coverage does not:
|
|
91
|
+
|
|
92
|
+
- **Mutation-check your assertions.** Revert the behaviour one piece at a time and confirm a test fails. An assertion that passes on the broken code is documenting nothing. Watch for vacuous cases: for example, a "does not throw" test over a mis-split file passes while the mis-split still contains the string being searched for, so the fixture has to be shaped to fail.
|
|
93
|
+
- **A negative test must fail for the reason it names.** Assert on the specific message or error, never a bare `toThrow()`.
|
|
94
|
+
|
|
95
|
+
## Regenerating the shipped macro list
|
|
96
|
+
|
|
97
|
+
The macros SAS ships are language data, owned by `@sasjs/sas-language`. Do not hand-write them here. `npm run generate:macros` reads its `macroStatements` and `macroFunctions` groups and writes `src/utils/sasMacros.generated.ts`, which is committed so the published package carries no runtime dependency. `sasMacros.spec.ts` reads the same data independently and fails when the committed list differs, which is the drift guard. Extending that vocabulary is a PR to `@sasjs/sas-language`.
|
|
98
|
+
|
|
99
|
+
## Code style
|
|
100
|
+
|
|
101
|
+
The repo uses `Prettier`. In VS Code, install the Prettier extension and set `editor.formatOnSave` (and `editor.formatOnPaste`) to `true`. Otherwise run `npm run lint:fix` before committing, and `npm run lint` to check.
|
|
55
102
|
|
|
56
103
|
## Git hooks
|
|
57
104
|
|
|
58
|
-
The repo ships its own
|
|
105
|
+
The repo ships its own hooks in [`.git-hooks/`](../.git-hooks):
|
|
59
106
|
|
|
60
107
|
- `pre-commit` - scans staged changes for secrets with gitleaks, and requires the `@nogoo9/gitleaks` devDependency to be installed
|
|
61
108
|
- `commit-msg` - verifies the commit message follows the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary) standard
|
|
@@ -70,6 +117,20 @@ The pre-commit hook runs the gitleaks binary provided by the `@nogoo9/gitleaks`
|
|
|
70
117
|
|
|
71
118
|
If you use the [pre-commit](https://pre-commit.com) framework, the repo also ships a [`.pre-commit-config.yaml`](../.pre-commit-config.yaml) that pins the upstream gitleaks hook to an exact release tag. Activate it with `pre-commit install`.
|
|
72
119
|
|
|
120
|
+
## Commit messages and releases
|
|
121
|
+
|
|
122
|
+
Merging to `main` runs semantic-release: the commit type decides the version, and a release publishes to npm. Only `feat:`, `fix:` and `perf:` cut a release - a `chore:` or `docs:` PR publishes nothing, which is correct rather than a failure.
|
|
123
|
+
|
|
124
|
+
For a squash merge the PR TITLE drives the version, so keep it conventional. Judge the type by what users see: a new diagnostic message, or a formatter that now rewrites files it used to leave alone, is new behaviour and belongs in `feat:` even when it also fixes a defect. Warnings do not move the exit code of `sasjs lint` - only `noEncodedPasswords` ships as an error - so a new warning does not break CI for consumers; a rewritten file might surprise them, and the release notes are where to say so.
|
|
125
|
+
|
|
126
|
+
Mark a genuinely breaking change with `BREAKING CHANGE:` in the commit body, and name the config key that restores the old behaviour.
|
|
127
|
+
|
|
128
|
+
## The audit gate
|
|
129
|
+
|
|
130
|
+
`build.yml` runs `npm audit --omit=dev --audit-level=low`, scoped to production dependencies because the dev tree carries one advisory nothing here can fix (`sprintf-js` through the jest transform chain, with no patched release). A weekly `audit-watch.yml` runs the FULL audit and fails when that exemption stops matching reality - a new dev-tree advisory, the exempted one disappearing, or a watched package publishing a newer version.
|
|
131
|
+
|
|
132
|
+
Do not add a dev-tree advisory to the exemption to get a build green. Prefer removing the dependency; if an exemption is genuinely unavoidable, it needs the reachability argument written down and a guard that closes it, not an allowlist.
|
|
133
|
+
|
|
73
134
|
## CI is the enforcement point
|
|
74
135
|
|
|
75
136
|
The [build workflow](./workflows/build.yml) scans the full history for secrets with gitleaks, runs `npm audit`, checks code style and runs the tests. The local hooks are convenience - CI is what a red finding must fail.
|
|
@@ -79,3 +140,17 @@ The [build workflow](./workflows/build.yml) scans the full history for secrets w
|
|
|
79
140
|
semantic-release is not a project dependency. Every `@semantic-release` plugin declares a `semantic-release` peer, so adding one to `devDependencies` makes npm auto-install semantic-release along with the `npm` package it bundles - and that bundled npm carries advisories this repo cannot fix.
|
|
80
141
|
|
|
81
142
|
Instead, [publish.yml](./workflows/publish.yml) installs semantic-release, `@semantic-release/exec` and `@semantic-release/git` on the fly, pinned to exact versions. When you add or remove an entry in `release.plugins` (package.json), update that command to match.
|
|
143
|
+
|
|
144
|
+
## What to work on
|
|
145
|
+
|
|
146
|
+
The formatter applies these fixes today: `%mend` macro names, a Doxygen header template, adding undeclared macros to the `<h4> SAS Macros </h4>` section, removing unused macros from it, trailing spaces, and line endings (including a missing final newline) when [`lineEndings`](../README.md#lineendings) is configured.
|
|
147
|
+
|
|
148
|
+
Fixes not yet implemented, roughly in order of usefulness:
|
|
149
|
+
|
|
150
|
+
- Change tabs to spaces
|
|
151
|
+
- Remove gremlin characters
|
|
152
|
+
- Convert single asterisk comments to block comments
|
|
153
|
+
|
|
154
|
+
Harder, and still under investigation: automatic indentation and code layout.
|
|
155
|
+
|
|
156
|
+
Rules without a fix are equally welcome - a rule that reports something real is worth more than one that silently repairs it wrong. Open an issue describing the SAS construct and what a false positive would look like before you build it, so the heuristic can be argued about cheaply.
|
|
@@ -9,6 +9,18 @@ on:
|
|
|
9
9
|
- main
|
|
10
10
|
workflow_dispatch:
|
|
11
11
|
|
|
12
|
+
# One release at a time. Both triggers publish, and the push trigger fires on
|
|
13
|
+
# every release commit @semantic-release/git pushes back to main, so a
|
|
14
|
+
# dispatched recovery run can interleave with a push-triggered one. Two
|
|
15
|
+
# semantic-release processes racing the same tag and the same npm publish is a
|
|
16
|
+
# new way to strand a release - the state the retry below exists to recover.
|
|
17
|
+
# `cancel-in-progress: false` queues the second run rather than cancelling the
|
|
18
|
+
# first, because cancelling a run midway through a release is itself a way to
|
|
19
|
+
# leave a tag pushed and the release missing.
|
|
20
|
+
concurrency:
|
|
21
|
+
group: publish
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
12
24
|
jobs:
|
|
13
25
|
build:
|
|
14
26
|
runs-on: ubuntu-latest
|
|
@@ -70,12 +82,66 @@ jobs:
|
|
|
70
82
|
# - and that bundled npm carries advisories nothing here can fix.
|
|
71
83
|
# Installing it here, pinned, keeps the dependency tree clean. Keep
|
|
72
84
|
# these versions in step with `release.plugins` in package.json.
|
|
85
|
+
#
|
|
86
|
+
# semantic-release pushes twice: @semantic-release/git pushes the release
|
|
87
|
+
# commit to the branch, then core pushes the tag in a second, tags-only
|
|
88
|
+
# push. When that second push is rejected the branch keeps the release
|
|
89
|
+
# commit - package.json at the new version - with no tag: no GitHub
|
|
90
|
+
# release, no npm publish, and every later run dying in the exec plugin's
|
|
91
|
+
# `npm version` with "Version not changed", a state only a hand repair
|
|
92
|
+
# clears. sasjs/adapter hit exactly that on 2026-10-17.
|
|
93
|
+
#
|
|
94
|
+
# The tag push runs after the tag exists locally and after the branch is
|
|
95
|
+
# updated, so one more attempt has only the tag to push. Retry exactly
|
|
96
|
+
# that case: a local tag alone does not identify it, because the tag is
|
|
97
|
+
# also there when the failure came later (the GitHub release), and
|
|
98
|
+
# retrying that finds the tag restored by semantic-release's own fetch,
|
|
99
|
+
# decides there is nothing to release, exits 0 and leaves the step green
|
|
100
|
+
# with the release still missing - so require the tag to be absent from
|
|
101
|
+
# the remote as well.
|
|
102
|
+
#
|
|
103
|
+
# Only a definitive answer counts. `git ls-remote --exit-code` exits 2 for
|
|
104
|
+
# an absent ref but 128 when the query itself fails (network, auth,
|
|
105
|
+
# unreachable remote), and treating every non-zero exit as "absent" would
|
|
106
|
+
# retry on the transient GitHub-side failures that are the very class of
|
|
107
|
+
# incident this retry repairs. So 2 retries, 0 and anything else fail the
|
|
108
|
+
# step.
|
|
73
109
|
run: |
|
|
74
|
-
|
|
75
|
-
--
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
110
|
+
run_release() {
|
|
111
|
+
npx --yes \
|
|
112
|
+
--package semantic-release@25.0.9 \
|
|
113
|
+
--package @semantic-release/exec@7.1.0 \
|
|
114
|
+
--package @semantic-release/git@11.0.1 \
|
|
115
|
+
semantic-release
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if run_release; then
|
|
119
|
+
exit 0
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
version=$(node -p "require('./package.json').version")
|
|
123
|
+
|
|
124
|
+
if ! git rev-parse -q --verify "refs/tags/v$version" >/dev/null; then
|
|
125
|
+
echo "No local v$version tag, so the failure came before the tag was created - not retrying." >&2
|
|
126
|
+
exit 1
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
ls_rc=0
|
|
130
|
+
git ls-remote --exit-code --tags origin "refs/tags/v$version" >/dev/null 2>&1 || ls_rc=$?
|
|
131
|
+
|
|
132
|
+
if [ "$ls_rc" -eq 0 ]; then
|
|
133
|
+
echo "v$version is already on the remote, so the failure came after the tag push - not retrying." >&2
|
|
134
|
+
exit 1
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
if [ "$ls_rc" -ne 2 ]; then
|
|
138
|
+
echo "Could not establish whether v$version is on the remote (git ls-remote exited $ls_rc) - not retrying." >&2
|
|
139
|
+
exit 1
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
echo "Retrying: v$version exists locally but not on the remote, so the tag push is what failed."
|
|
143
|
+
git tag -d "v$version"
|
|
144
|
+
run_release
|
|
79
145
|
env:
|
|
80
146
|
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} # <-- app token, not secrets.GITHUB_TOKEN
|
|
81
147
|
|
package/README.md
CHANGED
|
@@ -29,6 +29,7 @@ Configuration is via a `.sasjslint` file with the following structure (these are
|
|
|
29
29
|
"hasRequiredMacroOptions": false,
|
|
30
30
|
"ignoreList": [],
|
|
31
31
|
"ignoredLibnames": [],
|
|
32
|
+
"ignoredMacros": ["webout"],
|
|
32
33
|
"indentationMultiple": 2,
|
|
33
34
|
"lineEndings": "off",
|
|
34
35
|
"lowerCaseFileNames": true,
|
|
@@ -182,6 +183,23 @@ A single file can add to this list with the `ignoredLibnames` key of its [`@sasj
|
|
|
182
183
|
- Default: []
|
|
183
184
|
- Used by: `noUnusedLibnames`
|
|
184
185
|
|
|
186
|
+
### ignoredMacros
|
|
187
|
+
|
|
188
|
+
The macros that `noUndeclaredMacros` treats as declared. `%webout` is the common entry: `sasjs compile` injects it into every service and no macro file provides it - `sasjs/core` carries `mv_webout` / `ms_webout` / `mm_webout`, never `webout` - so there is nothing to declare, and `sasjs lint fix` would write an `@li webout.sas` the compiler cannot find. That is why `webout` is the default entry:
|
|
189
|
+
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"ignoredMacros": ["webout"]
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The names are matched case-insensitively. A macro listed here is not reported, and `sasjs lint fix` does not add it to a header. An explicit list replaces the default, so `"ignoredMacros": []` reports `webout` like any other undeclared name.
|
|
197
|
+
|
|
198
|
+
A single file can add to this list with the `ignoredMacros` key of its [`@sasjslint`](#per-file-overrides) header block.
|
|
199
|
+
|
|
200
|
+
- Default: ["webout"]
|
|
201
|
+
- Used by: `noUndeclaredMacros`
|
|
202
|
+
|
|
185
203
|
### indentationMultiple
|
|
186
204
|
|
|
187
205
|
This will check each line to ensure that the count of leading spaces can be divided cleanly by this multiple.
|
|
@@ -191,7 +209,9 @@ This will check each line to ensure that the count of leading spaces can be divi
|
|
|
191
209
|
|
|
192
210
|
### lineEndings
|
|
193
211
|
|
|
194
|
-
This setting ensures the line endings in a file to
|
|
212
|
+
This setting ensures the line endings in a file conform to the configured type. Possible values are `lf`, `crlf` and `off` (off means rule is set to be off). If the value is missing, null or undefined then the check would also be switched off (no default applied).
|
|
213
|
+
|
|
214
|
+
The last line is a line like any other: when this setting is `lf` or `crlf`, a file whose final line has no terminator is reported, and the formatter appends the missing terminator (`\r\n` when the setting is `crlf`, `\n` when it is `lf`). A project that wants the file end checked therefore sets this setting to `lf` or `crlf`; leaving it `off` means no line ending checks at all.
|
|
195
215
|
|
|
196
216
|
- Default: "off"
|
|
197
217
|
- Severity: WARNING
|
|
@@ -344,7 +364,7 @@ This will highlight lines with trailing spaces. Trailing spaces serve no useful
|
|
|
344
364
|
|
|
345
365
|
SASjs programs declare the macros they use in the `<h4> SAS Macros </h4>` section of the header, so that the compiler can assemble the job before it runs. This rule reports a warning for each macro that a file invokes without declaring it - either by defining it in the file, or by listing it under `<h4> SAS Macros </h4>` or `<h4> Other Macros </h4>`.
|
|
346
366
|
|
|
347
|
-
The macros that ship with SAS (`%scan`, `%index`, `%sysfunc` and the other macro functions, along with the macro language keywords such as `%if`, `%then` and `%do`) are always considered declared, so they are never reported. That list is generated from the `macroStatements` and `macroFunctions` groups of `@sasjs/sas-language` (`npm run generate:macros`), so it tracks the SAS language data rather than being maintained here. Macros made available through the `SASAUTOS` system option are not visible to the linter and will be reported.
|
|
367
|
+
The macros that ship with SAS (`%scan`, `%index`, `%sysfunc` and the other macro functions, along with the macro language keywords such as `%if`, `%then` and `%do`) are always considered declared, so they are never reported. That list is generated from the `macroStatements` and `macroFunctions` groups of `@sasjs/sas-language` (`npm run generate:macros`), so it tracks the SAS language data rather than being maintained here. Macros made available through the `SASAUTOS` system option are not visible to the linter and will be reported - list them in [`ignoredMacros`](#ignoredmacros), which carries `webout` by default.
|
|
348
368
|
|
|
349
369
|
The warning is resolved by adding the macro name to the header. Running `sasjs lint fix` (or saving in the SASjs VS Code extension with `formatOnSave`) adds the missing macros automatically, as a unique list sorted alphabetically.
|
|
350
370
|
|
|
@@ -449,15 +469,17 @@ We've already implemented the following rules:
|
|
|
449
469
|
- Add undeclared macros to the `<h4> SAS Macros </h4>` section
|
|
450
470
|
- Remove unused macros from the `<h4> SAS Macros </h4>` section
|
|
451
471
|
- Remove trailing spaces
|
|
472
|
+
- Fix line endings, including adding a missing final newline when [`lineEndings`](#lineendings) is configured
|
|
473
|
+
|
|
474
|
+
The formatter only fixes rules that are in your configuration, so a rule that is off neither warns nor is repaired.
|
|
452
475
|
|
|
453
|
-
|
|
476
|
+
# Contributing
|
|
454
477
|
|
|
455
|
-
|
|
456
|
-
- zap gremlins
|
|
457
|
-
- fix line endings
|
|
458
|
-
- convert single asterisk comments to block comments
|
|
478
|
+
Development instructions, the checklist for adding a rule, and the formatter fixes still to be built live in [CONTRIBUTING.md](.github/CONTRIBUTING.md).
|
|
459
479
|
|
|
460
|
-
|
|
480
|
+
SASjs is an open source framework! Contributions are welcomed. If you would like to see a feature, because it would be useful in your project, but you don't have the requisite (Typescript) experience - then how about you engage us on a short project and we build it for you?
|
|
481
|
+
|
|
482
|
+
Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details.
|
|
461
483
|
|
|
462
484
|
# Further resources
|
|
463
485
|
|
|
@@ -465,12 +487,6 @@ We are also investigating some harder stuff, such as automatic indentation and c
|
|
|
465
487
|
* Longer intro to sasjs lint: https://vid.4gl.io/w/nDtkQFV1E8rtaa2BuM6U5s
|
|
466
488
|
* CLI docs: https://cli.sasjs.io/lint
|
|
467
489
|
|
|
468
|
-
# Sponsorship & Contributions
|
|
469
|
-
|
|
470
|
-
SASjs is an open source framework! Contributions are welcomed. If you would like to see a feature, because it would be useful in your project, but you don't have the requisite (Typescript) experience - then how about you engage us on a short project and we build it for you?
|
|
471
|
-
|
|
472
|
-
Contact [Allan Bowe](https://www.linkedin.com/in/allanbowe/) for further details.
|
|
473
|
-
|
|
474
490
|
# Contributors ✨
|
|
475
491
|
|
|
476
492
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
[
|
|
28
28
|
"@semantic-release/exec",
|
|
29
29
|
{
|
|
30
|
-
"prepareCmd": "npm version ${nextRelease.version} --no-git-tag-version"
|
|
30
|
+
"prepareCmd": "npm version ${nextRelease.version} --no-git-tag-version --allow-same-version"
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
33
|
[
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"@sasjs/utils": "4.0.0",
|
|
74
74
|
"ignore": "7.0.11"
|
|
75
75
|
},
|
|
76
|
-
"version": "4.
|
|
76
|
+
"version": "4.3.0"
|
|
77
77
|
}
|
|
@@ -12,7 +12,6 @@ const message = 'File missing Doxygen header';
|
|
|
12
12
|
const messageForSingleAsterisk = 'File not following Doxygen header style, use double asterisks';
|
|
13
13
|
const test = (value, config) => {
|
|
14
14
|
var _a;
|
|
15
|
-
const lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
16
15
|
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
17
16
|
try {
|
|
18
17
|
const hasFileHeader = value.trimStart().startsWith('/**');
|
|
@@ -23,8 +22,7 @@ const test = (value, config) => {
|
|
|
23
22
|
return [
|
|
24
23
|
{
|
|
25
24
|
message: messageForSingleAsterisk,
|
|
26
|
-
lineNumber: ((_a = value.split('/*')[0].match(
|
|
27
|
-
.length + 1,
|
|
25
|
+
lineNumber: ((_a = value.split('/*')[0].match(/\r\n|\n/g)) !== null && _a !== void 0 ? _a : []).length + 1,
|
|
28
26
|
startColumnNumber: 1,
|
|
29
27
|
endColumnNumber: 1,
|
|
30
28
|
severity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AACxC,yDAAqD;AAErD,2DAAuD;AACvD,mDAA+C;AAC/C,6DAAoE;AAEpE,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAC/B,MAAM,WAAW,GACf,qEAAqE,CAAA;AACvE,MAAM,OAAO,GAAG,6BAA6B,CAAA;AAC7C,MAAM,wBAAwB,GAC5B,+DAA+D,CAAA;AAEjE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;;IAClD,MAAM,
|
|
1
|
+
{"version":3,"file":"hasDoxygenHeader.js","sourceRoot":"","sources":["../../../src/rules/file/hasDoxygenHeader.ts"],"names":[],"mappings":";;;AAAA,uCAAwC;AACxC,yDAAqD;AAErD,2DAAuD;AACvD,mDAA+C;AAC/C,6DAAoE;AAEpE,MAAM,IAAI,GAAG,kBAAkB,CAAA;AAC/B,MAAM,WAAW,GACf,qEAAqE,CAAA;AACvE,MAAM,OAAO,GAAG,6BAA6B,CAAA;AAC7C,MAAM,wBAAwB,GAC5B,+DAA+D,CAAA;AAEjE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;;IAClD,MAAM,QAAQ,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC,IAAI,CAAC,KAAI,mBAAQ,CAAC,OAAO,CAAA;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AM,GAAG,MAAM,IAAI,IAAI,kBAAU,CAAC,wCAAwB,CAAC,CAAA;IAC3D,MAAM,gBAAgB,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,yBAAW,CAAC,EAAE,CAAA;IAC9D,MAAM,UAAU,GAAG,gBAAgB,KAAK,yBAAW,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAA;IAEtE,OAAO,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC,OAAO,CACrC,eAAe,EACf,UAAU,CACX,GAAG,UAAU,GAAG,KAAK,EAAE,CAAA;AAC1B,CAAC,CAAA;AAED;;GAEG;AACU,QAAA,gBAAgB,GAAiB;IAC5C,IAAI,EAAE,2BAAY,CAAC,IAAI;IACvB,IAAI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAA"}
|
|
@@ -6,12 +6,12 @@ const Severity_1 = require("../../types/Severity");
|
|
|
6
6
|
const getColumnNumber_1 = require("../../utils/getColumnNumber");
|
|
7
7
|
const LineEndings_1 = require("../../types/LineEndings");
|
|
8
8
|
const parseMacros_1 = require("../../utils/parseMacros");
|
|
9
|
+
const splitLines_1 = require("../../utils/splitLines");
|
|
9
10
|
const name = 'hasMacroNameInMend';
|
|
10
11
|
const description = 'Enforces the presence of the macro name in each %mend statement.';
|
|
11
12
|
const message = '%mend statement has missing or incorrect macro name';
|
|
12
13
|
const test = (value, config) => {
|
|
13
|
-
const
|
|
14
|
-
const lines = value ? value.split(lineEnding) : [];
|
|
14
|
+
const lines = (0, splitLines_1.splitLines)(value);
|
|
15
15
|
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
16
16
|
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
17
17
|
const diagnostics = [];
|
|
@@ -63,7 +63,7 @@ const test = (value, config) => {
|
|
|
63
63
|
};
|
|
64
64
|
const fix = (value, config) => {
|
|
65
65
|
const lineEnding = (config === null || config === void 0 ? void 0 : config.lineEndings) === LineEndings_1.LineEndings.CRLF ? '\r\n' : '\n';
|
|
66
|
-
const lines =
|
|
66
|
+
const lines = (0, splitLines_1.splitLines)(value);
|
|
67
67
|
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
68
68
|
macros.forEach((macro) => {
|
|
69
69
|
if (macro.startLineNumbers.length === 0 && macro.endLineNumber !== null) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasMacroNameInMend.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroNameInMend.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAE7D,yDAAqD;AACrD,yDAAqD;
|
|
1
|
+
{"version":3,"file":"hasMacroNameInMend.js","sourceRoot":"","sources":["../../../src/rules/file/hasMacroNameInMend.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAE7D,yDAAqD;AACrD,yDAAqD;AACrD,uDAAmD;AAEnD,MAAM,IAAI,GAAG,oBAAoB,CAAA;AACjC,MAAM,WAAW,GACf,kEAAkE,CAAA;AACpE,MAAM,OAAO,GAAG,qDAAqD,CAAA;AAErE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;IAClD,MAAM,KAAK,GAAG,IAAA,uBAAU,EAAC,KAAK,CAAC,CAAA;IAC/B,MAAM,MAAM,GAAG,IAAA,yBAAW,EAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACzC,MAAM,QAAQ,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAC,IAAI,CAAC,KAAI,mBAAQ,CAAC,OAAO,CAAA;IAChE,MAAM,WAAW,GAAiB,EAAE,CAAA;IAEpC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,IAAI,KA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ACxC,MAAM,OAAO,GAAG,KAAK,CAAE,KAAK,CAAC,aAAwB,GAAG,CAAC,CAAC,CAAA;YAC1D,MAAM,iBAAiB,GAAG,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC3D,MAAM,eAAe,GAAG,IAAA,iCAAe,EAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;YAE7D,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,GAAG,CAAC,CAAC,CAAA;YAC/D,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;YACrD,KAAK,CAAE,KAAK,CAAC,aAAwB,GAAG,CAAC,CAAC;gBACxC,eAAe,GAAG,SAAS,KAAK,CAAC,IAAI,EAAE,GAAG,cAAc,CAAA;QAC5D,CAAC;IACH,CAAC,CAAC,CAAA;IACF,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IAE5C,OAAO,aAAa,CAAA;AACtB,CAAC,CAAA;AAED;;GAEG;AACU,QAAA,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,2BAAY,CAAC,IAAI;IACvB,IAAI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FileLintRule } from '../../types/LintRule';
|
|
2
2
|
/**
|
|
3
|
-
* Lint rule that checks if line endings in a file match the configured type
|
|
3
|
+
* Lint rule that checks if line endings in a file match the configured type,
|
|
4
|
+
* including the line ending at the end of the file.
|
|
4
5
|
*/
|
|
5
6
|
export declare const lineEndings: FileLintRule;
|
|
@@ -5,8 +5,9 @@ const LineEndings_1 = require("../../types/LineEndings");
|
|
|
5
5
|
const LintRuleType_1 = require("../../types/LintRuleType");
|
|
6
6
|
const Severity_1 = require("../../types/Severity");
|
|
7
7
|
const name = 'lineEndings';
|
|
8
|
-
const description = 'Ensures line
|
|
8
|
+
const description = 'Ensures every line, including the last, ends with the configured line ending.';
|
|
9
9
|
const message = 'Incorrect line ending - {actual} instead of {expected}';
|
|
10
|
+
const missingMessage = 'File does not end with a {expected} line ending';
|
|
10
11
|
const test = (value, config) => {
|
|
11
12
|
const lineEndingConfig = (config === null || config === void 0 ? void 0 : config.lineEndings) || LineEndings_1.LineEndings.LF;
|
|
12
13
|
const expectedLineEnding = lineEndingConfig === LineEndings_1.LineEndings.LF ? '{lf}' : '{crlf}';
|
|
@@ -50,18 +51,40 @@ const test = (value, config) => {
|
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
});
|
|
54
|
+
// The end of the file is a line boundary too, so a last line with no
|
|
55
|
+
// terminator at all is a violation of this rule, not a separate concern.
|
|
56
|
+
// Gate on ANY terminator being present: a wrong-style terminator at the end
|
|
57
|
+
// is already reported by the loop above, and reporting it here as well would
|
|
58
|
+
// give one byte two diagnostics, at a line past the end of the file.
|
|
59
|
+
if (value.length > 0 && !value.endsWith('\n')) {
|
|
60
|
+
const lastLines = value.split(/\r\n|\n/);
|
|
61
|
+
const lastLine = lastLines[lastLines.length - 1];
|
|
62
|
+
diagnostics.push({
|
|
63
|
+
message: missingMessage.replace('{expected}', expectedLineEnding === '{lf}' ? 'LF' : 'CRLF'),
|
|
64
|
+
lineNumber: lastLines.length,
|
|
65
|
+
startColumnNumber: lastLine.length + 1,
|
|
66
|
+
endColumnNumber: lastLine.length + 2,
|
|
67
|
+
severity
|
|
68
|
+
});
|
|
69
|
+
}
|
|
53
70
|
return diagnostics;
|
|
54
71
|
};
|
|
55
72
|
const fix = (value, config) => {
|
|
56
73
|
const lineEndingConfig = (config === null || config === void 0 ? void 0 : config.lineEndings) || LineEndings_1.LineEndings.LF;
|
|
57
|
-
|
|
74
|
+
const converted = value
|
|
58
75
|
.replace(/\r\n/g, '{crlf}')
|
|
59
76
|
.replace(/\n/g, '{lf}')
|
|
60
77
|
.replace(/{crlf}/g, lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n')
|
|
61
78
|
.replace(/{lf}/g, lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n');
|
|
79
|
+
const expectedCharacter = lineEndingConfig === LineEndings_1.LineEndings.LF ? '\n' : '\r\n';
|
|
80
|
+
if (converted.length === 0 || converted.endsWith(expectedCharacter)) {
|
|
81
|
+
return converted;
|
|
82
|
+
}
|
|
83
|
+
return converted + expectedCharacter;
|
|
62
84
|
};
|
|
63
85
|
/**
|
|
64
|
-
* Lint rule that checks if line endings in a file match the configured type
|
|
86
|
+
* Lint rule that checks if line endings in a file match the configured type,
|
|
87
|
+
* including the line ending at the end of the file.
|
|
65
88
|
*/
|
|
66
89
|
exports.lineEndings = {
|
|
67
90
|
type: LintRuleType_1.LintRuleType.File,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lineEndings.js","sourceRoot":"","sources":["../../../src/rules/file/lineEndings.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AAErD,2DAAuD;AACvD,mDAA+C;AAE/C,MAAM,IAAI,GAAG,aAAa,CAAA;AAC1B,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"lineEndings.js","sourceRoot":"","sources":["../../../src/rules/file/lineEndings.ts"],"names":[],"mappings":";;;AACA,yDAAqD;AAErD,2DAAuD;AACvD,mDAA+C;AAE/C,MAAM,IAAI,GAAG,aAAa,CAAA;AAC1B,MAAM,WAAW,GACf,+EAA+E,CAAA;AACjF,MAAM,OAAO,GAAG,wDAAwD,CAAA;AACxE,MAAM,cAAc,GAAG,iDAAiD,CAAA;AAExE,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;IAClD,MAAM,gBAAgB,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,yBAAW,CAAC,EAAE,CAAA;IAC9D,MAAM,kBAAkB,GACtB,gBAAgB,KAAK,yBAAW,CAAC,EAAE,CAAC,CA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AI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAA"}
|
|
@@ -5,13 +5,12 @@ const LintRuleType_1 = require("../../types/LintRuleType");
|
|
|
5
5
|
const Severity_1 = require("../../types/Severity");
|
|
6
6
|
const getColumnNumber_1 = require("../../utils/getColumnNumber");
|
|
7
7
|
const parseMacros_1 = require("../../utils/parseMacros");
|
|
8
|
-
const
|
|
8
|
+
const splitLines_1 = require("../../utils/splitLines");
|
|
9
9
|
const name = 'noNestedMacros';
|
|
10
10
|
const description = 'Enfoces the absence of nested macro definitions.';
|
|
11
11
|
const message = `Macro definition for '{macro}' present in macro '{parent}'`;
|
|
12
12
|
const test = (value, config) => {
|
|
13
|
-
const
|
|
14
|
-
const lines = value ? value.split(lineEnding) : [];
|
|
13
|
+
const lines = (0, splitLines_1.splitLines)(value);
|
|
15
14
|
const diagnostics = [];
|
|
16
15
|
const macros = (0, parseMacros_1.parseMacros)(value, config);
|
|
17
16
|
const severity = (config === null || config === void 0 ? void 0 : config.severityLevel[name]) || Severity_1.Severity.Warning;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noNestedMacros.js","sourceRoot":"","sources":["../../../src/rules/file/noNestedMacros.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAC7D,yDAAqD;
|
|
1
|
+
{"version":3,"file":"noNestedMacros.js","sourceRoot":"","sources":["../../../src/rules/file/noNestedMacros.ts"],"names":[],"mappings":";;;AAEA,2DAAuD;AACvD,mDAA+C;AAC/C,iEAA6D;AAC7D,yDAAqD;AACrD,uDAAmD;AAGnD,MAAM,IAAI,GAAG,gBAAgB,CAAA;AAC7B,MAAM,WAAW,GAAG,kDAAkD,CAAA;AACtE,MAAM,OAAO,GAAG,4DAA4D,CAAA;AAE5E,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAE,EAAE;IAClD,MAAM,KAAK,GAAG,IAAA,uBAAU,E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14 @@ const parseMacros_1 = require("../../utils/parseMacros");
|
|
|
10
10
|
const sasMacros_1 = require("../../utils/sasMacros");
|
|
11
11
|
const name = 'noUndeclaredMacros';
|
|
12
12
|
const description = 'Enforce that every macro used in a file is declared.';
|
|
13
|
-
const message = `Macro '{macro}' is not declared - add it to the <h4> SAS Macros </h4> or <h4> Other Macros </h4> section of the header`;
|
|
13
|
+
const message = `Macro '{macro}' is not declared - add it to the <h4> SAS Macros </h4> or <h4> Other Macros </h4> section of the header, or list the macro in 'ignoredMacros'`;
|
|
14
14
|
/**
|
|
15
15
|
* Collects the first invocation of each macro that the file uses but does not
|
|
16
16
|
* declare. A macro is declared when it is defined in the file, or listed in the
|
|
17
17
|
* `<h4> SAS Macros </h4>` or `<h4> Other Macros </h4>` section of its header.
|
|
18
|
-
* Macros that ship with SAS are always considered declared
|
|
18
|
+
* Macros that ship with SAS are always considered declared, and so are the
|
|
19
|
+
* names the configuration lists in `ignoredMacros` - a macro such as `%webout`
|
|
20
|
+
* has no file to point at.
|
|
19
21
|
*/
|
|
20
22
|
const getUndeclaredCalls = (value, config) => {
|
|
21
23
|
if (!value)
|
|
@@ -28,6 +30,7 @@ const getUndeclaredCalls = (value, config) => {
|
|
|
28
30
|
(0, headerMacros_1.getHeaderMacros)(value, config).forEach((macro) => {
|
|
29
31
|
declared.add(macro.name.toLowerCase());
|
|
30
32
|
});
|
|
33
|
+
const ignored = new Set(config.ignoredMacros.map((macro) => macro.trim().toLowerCase()));
|
|
31
34
|
const undeclared = [];
|
|
32
35
|
const seen = new Set();
|
|
33
36
|
(0, parseMacroCalls_1.parseMacroCalls)(value, config).forEach((call) => {
|
|
@@ -37,6 +40,8 @@ const getUndeclaredCalls = (value, config) => {
|
|
|
37
40
|
seen.add(key);
|
|
38
41
|
if ((0, sasMacros_1.isSasMacro)(call.name))
|
|
39
42
|
return;
|
|
43
|
+
if (ignored.has(key))
|
|
44
|
+
return;
|
|
40
45
|
if (declared.has(key))
|
|
41
46
|
return;
|
|
42
47
|
undeclared.push(call);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noUndeclaredMacros.js","sourceRoot":"","sources":["../../../src/rules/file/noUndeclaredMacros.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AAEpD,2DAAuD;AACvD,mDAA+C;AAC/C,2DAA6E;AAC7E,iEAAwE;AACxE,yDAAqD;AACrD,qDAAkD;AAElD,MAAM,IAAI,GAAG,oBAAoB,CAAA;AACjC,MAAM,WAAW,GAAG,sDAAsD,CAAA;AAC1E,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"noUndeclaredMacros.js","sourceRoot":"","sources":["../../../src/rules/file/noUndeclaredMacros.ts"],"names":[],"mappings":";;;AAAA,uCAAoD;AAEpD,2DAAuD;AACvD,mDAA+C;AAC/C,2DAA6E;AAC7E,iEAAwE;AACxE,yDAAqD;AACrD,qDAAkD;AAElD,MAAM,IAAI,GAAG,oBAAoB,CAAA;AACjC,MAAM,WAAW,GAAG,sDAAsD,CAAA;AAC1E,MAAM,OAAO,GAAG,8JAA8J,CAAA;AAE9K;;;;;;;GAOG;AACH,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAE,MAAkB,EAAe,EAAE;IAC5E,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAA;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAElC,IAAA,yBAAW,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3C,IAAI,KAAK,CAAC,IAAI;YAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IACxD,CAAC,CAAC,CAAA;IAEF,IAAA,8BAAe,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QAC/C,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,W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CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC;QAC9C,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,QAAQ;KACT,CAAC,CAAC,CAAA;AACL,CAAC,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,KAAa,EAAE,MAAmB,EAAU,EAAE;IACzD,MAAM,GAAG,GAAG,MAAM,IAAI,IAAI,kBAAU,EAAE,CAAA;IACtC,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEtE,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAEhC,OAAO,IAAA,gCAAiB,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA;AAC9C,CAAC,CAAA;AAED;;;;GAIG;AACU,QAAA,kBAAkB,GAAiB;IAC9C,IAAI,EAAE,2BAAY,CAAC,IAAI;IACvB,IAAI;IACJ,WAAW;IACX,OAAO;IACP,IAAI;IACJ,GAAG;CACJ,CAAA"}
|
package/sasjslint-schema.json
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"hasRequiredMacroOptions": false,
|
|
14
14
|
"ignoreList": [],
|
|
15
15
|
"ignoredLibnames": [],
|
|
16
|
+
"ignoredMacros": ["webout"],
|
|
16
17
|
"indentationMultiple": 2,
|
|
17
18
|
"lineEndings": "off",
|
|
18
19
|
"lowerCaseFileNames": true,
|
|
@@ -57,7 +58,8 @@
|
|
|
57
58
|
"strictMacroDefinition": true,
|
|
58
59
|
"ignoreList": ["sajsbuild", "sasjsresults"],
|
|
59
60
|
"hasRequiredMacroOptions": false,
|
|
60
|
-
"requiredMacroOptions": []
|
|
61
|
+
"requiredMacroOptions": [],
|
|
62
|
+
"ignoredMacros": ["webout"]
|
|
61
63
|
}
|
|
62
64
|
],
|
|
63
65
|
"properties": {
|
|
@@ -205,7 +207,7 @@
|
|
|
205
207
|
"$id": "#/properties/noUndeclaredMacros",
|
|
206
208
|
"type": "boolean",
|
|
207
209
|
"title": "noUndeclaredMacros",
|
|
208
|
-
"description": "Reports a warning for each macro a file invokes without declaring it in the `<h4> SAS Macros </h4>` or `<h4> Other Macros </h4>` section of the header. Macros that ship with SAS are always considered declared. The formatter resolves the warning by adding the macro names to the header, sorted alphabetically.",
|
|
210
|
+
"description": "Reports a warning for each macro a file invokes without declaring it in the `<h4> SAS Macros </h4>` or `<h4> Other Macros </h4>` section of the header. Macros that ship with SAS are always considered declared, and so are the macros listed in `ignoredMacros` (`webout` by default). The formatter resolves the warning by adding the macro names to the header, sorted alphabetically.",
|
|
209
211
|
"default": true,
|
|
210
212
|
"examples": [true, false]
|
|
211
213
|
},
|
|
@@ -230,7 +232,7 @@
|
|
|
230
232
|
"type": "string",
|
|
231
233
|
"enum": ["lf", "crlf", "off"],
|
|
232
234
|
"title": "lineEndings",
|
|
233
|
-
"description": "Enforces the configured terminating character for each line. Shows a warning when incorrect line endings are present.",
|
|
235
|
+
"description": "Enforces the configured terminating character for each line, including the last one. Shows a warning when incorrect line endings are present, and a warning for a file whose final line has no terminator; the formatter appends the missing terminator.",
|
|
234
236
|
"default": "off",
|
|
235
237
|
"examples": ["lf", "crlf"]
|
|
236
238
|
},
|
|
@@ -258,6 +260,14 @@
|
|
|
258
260
|
"default": [],
|
|
259
261
|
"examples": [["outData", "TESTWORK"]]
|
|
260
262
|
},
|
|
263
|
+
"ignoredMacros": {
|
|
264
|
+
"$id": "#/properties/ignoredMacros",
|
|
265
|
+
"type": "array",
|
|
266
|
+
"title": "ignoredMacros",
|
|
267
|
+
"description": "An array of macros that `noUndeclaredMacros` treats as declared: an entry is neither reported nor added to the header by the formatter. Use it for macros that no file in the project provides - the default entry, `webout`, is injected by `sasjs compile`. An explicit list replaces the default. A single file can add to this list with the `ignoredMacros` key of its `@sasjslint` header block.",
|
|
268
|
+
"default": ["webout"],
|
|
269
|
+
"examples": [["webout", "mpeinit"]]
|
|
270
|
+
},
|
|
261
271
|
"hasRequiredMacroOptions": {
|
|
262
272
|
"$id": "#/properties/hasRequiredMacroOptions",
|
|
263
273
|
"type": "boolean",
|
package/types/LintConfig.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export declare class LintConfig {
|
|
|
27
27
|
};
|
|
28
28
|
readonly requiredMacroOptions: string[];
|
|
29
29
|
readonly ignoredLibnames: string[];
|
|
30
|
+
readonly ignoredMacros: string[];
|
|
30
31
|
constructor(json?: any);
|
|
31
32
|
/**
|
|
32
33
|
* Returns a new configuration with an override merged over this one, so a
|
package/types/LintConfig.js
CHANGED
|
@@ -31,6 +31,7 @@ class LintConfig {
|
|
|
31
31
|
this.severityLevel = {};
|
|
32
32
|
this.requiredMacroOptions = [];
|
|
33
33
|
this.ignoredLibnames = [];
|
|
34
|
+
this.ignoredMacros = [];
|
|
34
35
|
this.source = json !== null && json !== void 0 ? json : {};
|
|
35
36
|
if (json === null || json === void 0 ? void 0 : json.ignoreList) {
|
|
36
37
|
if (Array.isArray(json.ignoreList)) {
|
|
@@ -45,6 +46,24 @@ class LintConfig {
|
|
|
45
46
|
throw new Error(`Property "ignoreList" can only be an array of strings`);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
49
|
+
// An absent setting falls back to the documented default. An explicit list
|
|
50
|
+
// replaces it, so `[]` reports `webout` like any other undeclared name.
|
|
51
|
+
if ((json === null || json === void 0 ? void 0 : json.ignoredMacros) === undefined) {
|
|
52
|
+
this.ignoredMacros.push(...utils_1.defaultIgnoredMacros);
|
|
53
|
+
}
|
|
54
|
+
else if (!Array.isArray(json.ignoredMacros)) {
|
|
55
|
+
throw new Error(`Property "ignoredMacros" can only be an array of strings.`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
json.ignoredMacros.forEach((item) => {
|
|
59
|
+
if (typeof item === 'string') {
|
|
60
|
+
this.ignoredMacros.push(item);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
throw new Error(`Property "ignoredMacros" has invalid type of values. It can only contain strings.`);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
48
67
|
if ((json === null || json === void 0 ? void 0 : json.noTrailingSpaces) !== false) {
|
|
49
68
|
this.lineLintRules.push(line_1.noTrailingSpaces);
|
|
50
69
|
}
|
|
@@ -183,7 +202,15 @@ class LintConfig {
|
|
|
183
202
|
* @returns {LintConfig} a new configuration; this one is unchanged.
|
|
184
203
|
*/
|
|
185
204
|
override(json) {
|
|
186
|
-
|
|
205
|
+
const source = Object.assign({}, this.source);
|
|
206
|
+
// Arrays whose documented default is not empty are seeded into the base
|
|
207
|
+
// before the merge. A per-file override is additive, and the project json
|
|
208
|
+
// usually leaves such a key out rather than restating the default - without
|
|
209
|
+
// the seed, an override that adds one entry would drop the rest.
|
|
210
|
+
if (source.ignoredMacros === undefined) {
|
|
211
|
+
source.ignoredMacros = [...this.ignoredMacros];
|
|
212
|
+
}
|
|
213
|
+
return new LintConfig((0, mergeLintConfig_1.mergeLintConfig)(source, json));
|
|
187
214
|
}
|
|
188
215
|
}
|
|
189
216
|
exports.LintConfig = LintConfig;
|
package/types/LintConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LintConfig.js","sourceRoot":"","sources":["../../src/types/LintConfig.ts"],"names":[],"mappings":";;;AAAA,wCAYsB;AACtB,wCAOsB;AACtB,wCAAuE;AACvE,+CAA2C;AAE3C,
|
|
1
|
+
{"version":3,"file":"LintConfig.js","sourceRoot":"","sources":["../../src/types/LintConfig.ts"],"names":[],"mappings":";;;AAAA,wCAYsB;AACtB,wCAOsB;AACtB,wCAAuE;AACvE,+CAA2C;AAE3C,oCAAiE;AACjE,8DAA0D;AAC1D,yCAAqC;AAErC;;;;;;GAMG;AACH,MAAa,UAAU;IAmBrB,YAAY,IA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AAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;;4BAE/B,MAAM,IAAI,KAAK,CACb,gIAAgI,CACjI,CAAA;oBACL,CAAC,CAAC,CAAA;gBACJ,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CACb,wGAAwG,CACzG,CAAA;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,EAAE,CAAC;YACxB,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;gBAClE,IAAI,QAAQ,KAAK,MAAM;oBAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,mBAAQ,CAAC,OAAO,CAAA;gBACpE,IAAI,QAAQ,KAAK,OAAO;oBAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,mBAAQ,CAAC,KAAK,CAAA;YACrE,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;;;;;OASG;IACH,QAAQ,CAAC,IAAS;QAChB,MAAM,MAAM,qBAAQ,IAAI,CAAC,MAAM,CAAE,CAAA;QAEjC,wEAAwE;QACxE,0EAA0E;QAC1E,4EAA4E;QAC5E,iEAAiE;QACjE,IAAI,MAAM,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;YACvC,MAAM,CAAC,aAAa,GAAG,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,CAAA;QAChD,CAAC;QAED,OAAO,IAAI,UAAU,CAAC,IAAA,iCAAe,EAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;IACtD,CAAC;CACF;AAtPD,gCAsPC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The default value of the `ignoredMacros` setting. `sasjs compile` injects
|
|
3
|
+
* `%webout` into every service, and no macro file provides it - `sasjs/core`
|
|
4
|
+
* carries `mv_webout` / `ms_webout` / `mm_webout`, never `webout` - so declaring
|
|
5
|
+
* it would hand the compiler a dependency it cannot resolve.
|
|
6
|
+
*/
|
|
7
|
+
export declare const defaultIgnoredMacros: string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defaultIgnoredMacros = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The default value of the `ignoredMacros` setting. `sasjs compile` injects
|
|
6
|
+
* `%webout` into every service, and no macro file provides it - `sasjs/core`
|
|
7
|
+
* carries `mv_webout` / `ms_webout` / `mm_webout`, never `webout` - so declaring
|
|
8
|
+
* it would hand the compiler a dependency it cannot resolve.
|
|
9
|
+
*/
|
|
10
|
+
exports.defaultIgnoredMacros = ['webout'];
|
|
11
|
+
//# sourceMappingURL=defaultIgnoredMacros.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultIgnoredMacros.js","sourceRoot":"","sources":["../../src/utils/defaultIgnoredMacros.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACU,QAAA,oBAAoB,GAAG,CAAC,QAAQ,CAAC,CAAA"}
|
package/utils/getLintConfig.d.ts
CHANGED
package/utils/getLintConfig.js
CHANGED
|
@@ -20,6 +20,7 @@ const LintConfig_1 = require("../types/LintConfig");
|
|
|
20
20
|
const file_1 = require("@sasjs/utils/file");
|
|
21
21
|
const getProjectRoot_1 = require("./getProjectRoot");
|
|
22
22
|
const LineEndings_1 = require("../types/LineEndings");
|
|
23
|
+
const defaultIgnoredMacros_1 = require("./defaultIgnoredMacros");
|
|
23
24
|
const getDefaultHeader = () => `/**{lineEnding} @file{lineEnding} @brief <Your brief here>{lineEnding}{lineEnding} <h4> SAS Macros </h4>{lineEnding}{lineEnding}**/`;
|
|
24
25
|
exports.getDefaultHeader = getDefaultHeader;
|
|
25
26
|
/**
|
|
@@ -39,6 +40,7 @@ exports.DefaultLintConfiguration = {
|
|
|
39
40
|
hasRequiredMacroOptions: false,
|
|
40
41
|
ignoreList: [],
|
|
41
42
|
ignoredLibnames: [],
|
|
43
|
+
ignoredMacros: [...defaultIgnoredMacros_1.defaultIgnoredMacros],
|
|
42
44
|
indentationMultiple: 2,
|
|
43
45
|
lineEndings: LineEndings_1.LineEndings.OFF,
|
|
44
46
|
lowerCaseFileNames: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"getLintConfig.js","sourceRoot":"","sources":["../../src/utils/getLintConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAuDA,sCASC;AAhED,gDAAuB;AACvB,4CAAmB;AACnB,oDAAgD;AAChD,4CAA4C;AAC5C,qDAAiD;AACjD,sDAAkD;AAClD,iEAA6D;AAEtD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CACnC,wIAAwI,CAAA;AAD7H,QAAA,gBAAgB,oBAC6G;AAE1I;;;;;;;GAOG;AACU,QAAA,wBAAwB,GAAG;IACtC,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,IAAA,wBAAgB,GAAE;IACjC,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAAE,IAAI;IACzB,uBAAuB,EAAE,KAAK;IAC9B,UAAU,EAAE,EAAE;IACd,eAAe,EAAE,EAAE;IACnB,aAAa,EAAE,CAAC,GAAG,2CAAoB,CAAC;IACxC,mBAAmB,EAAE,CAAC;IACtB,WAAW,EAAE,yBAAW,CAAC,GAAG;IAC5B,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,EAAE;IACrB,mBAAmB,EAAE,EAAE;IACvB,aAAa,EAAE,EAAE;IACjB,kBAAkB,EAAE,IAAI;IACxB,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;IACpB,wBAAwB,EAAE,KAAK;IAC/B,mBAAmB,EAAE,IAAI;IACzB,MAAM,EAAE,IAAI;IACZ,gBAAgB,EAAE,IAAI;IACtB,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,KAAK;IACvB,cAAc,EAAE,IAAI;IACpB,oBAAoB,EAAE,EAAE;IACxB,aAAa,EAAE,EAAE;IACjB,qBAAqB,EAAE,IAAI;CAC5B,CAAA;AAED;;;;GAIG;AACH,SAAsB,aAAa;;QACjC,MAAM,WAAW,GAAG,MAAM,IAAA,+BAAc,GAAE,CAAA;QAC1C,MAAM,gBAAgB,GAAG,WAAW,IAAI,YAAE,CAAC,OAAO,EAAE,CAAA;QACpD,MAAM,aAAa,GAAG,MAAM,IAAA,eAAQ,EAClC,cAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAC1C,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,gCAAwB,CAAC,CAAA;QACjD,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,uBAAU,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;IAClD,CAAC;CAAA"}
|
package/utils/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@ export * from './gremlinCharacters';
|
|
|
5
5
|
export * from './isIgnored';
|
|
6
6
|
export * from './listSasFiles';
|
|
7
7
|
export * from './splitText';
|
|
8
|
+
export * from './splitLines';
|
|
8
9
|
export * from './getIndicesOf';
|
|
9
10
|
export * from './getHeaderLinesCount';
|
|
10
11
|
export * from './getDataSectionsDetail';
|
|
12
|
+
export * from './defaultIgnoredMacros';
|
|
11
13
|
export * from './headerMacros';
|
|
12
14
|
export * from './mergeLintConfig';
|
|
13
15
|
export * from './parseLibnames';
|
package/utils/index.js
CHANGED
|
@@ -21,9 +21,11 @@ __exportStar(require("./gremlinCharacters"), exports);
|
|
|
21
21
|
__exportStar(require("./isIgnored"), exports);
|
|
22
22
|
__exportStar(require("./listSasFiles"), exports);
|
|
23
23
|
__exportStar(require("./splitText"), exports);
|
|
24
|
+
__exportStar(require("./splitLines"), exports);
|
|
24
25
|
__exportStar(require("./getIndicesOf"), exports);
|
|
25
26
|
__exportStar(require("./getHeaderLinesCount"), exports);
|
|
26
27
|
__exportStar(require("./getDataSectionsDetail"), exports);
|
|
28
|
+
__exportStar(require("./defaultIgnoredMacros"), exports);
|
|
27
29
|
__exportStar(require("./headerMacros"), exports);
|
|
28
30
|
__exportStar(require("./mergeLintConfig"), exports);
|
|
29
31
|
__exportStar(require("./parseLibnames"), exports);
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,sDAAmC;AACnC,8CAA2B;AAC3B,iDAA8B;AAC9B,8CAA2B;AAC3B,iDAA8B;AAC9B,wDAAqC;AACrC,0DAAuC;AACvC,iDAA8B;AAC9B,oDAAiC;AACjC,kDAA+B;AAC/B,sDAAmC;AACnC,oDAAiC;AACjC,8CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B;AAC9B,kDAA+B;AAC/B,mDAAgC;AAChC,sDAAmC;AACnC,8CAA2B;AAC3B,iDAA8B;AAC9B,8CAA2B;AAC3B,+CAA4B;AAC5B,iDAA8B;AAC9B,wDAAqC;AACrC,0DAAuC;AACvC,yDAAsC;AACtC,iDAA8B;AAC9B,oDAAiC;AACjC,kDAA+B;AAC/B,sDAAmC;AACnC,oDAAiC;AACjC,8CAA2B"}
|
package/utils/parseMacros.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMacros = void 0;
|
|
4
|
-
const LineEndings_1 = require("../types/LineEndings");
|
|
5
4
|
const trimComments_1 = require("./trimComments");
|
|
5
|
+
const splitLines_1 = require("./splitLines");
|
|
6
6
|
const parseMacros = (text, config) => {
|
|
7
|
-
const
|
|
8
|
-
const lines = text ? text.split(lineEnding) : [];
|
|
7
|
+
const lines = (0, splitLines_1.splitLines)(text);
|
|
9
8
|
const macros = [];
|
|
10
9
|
let isCommentStarted = false;
|
|
11
10
|
let macroStack = [];
|
package/utils/parseMacros.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseMacros.js","sourceRoot":"","sources":["../../src/utils/parseMacros.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"parseMacros.js","sourceRoot":"","sources":["../../src/utils/parseMacros.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AAC7C,6CAAyC;AAElC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,MAAmB,EAAW,EAAE;IACxE,MAAM,KAAK,GAAG,IAAA,uBAAU,EAAC,IAAI,CAAC,CAAA;IAC9B,MAAM,MAAM,GAAY,EAAE,CAAA;IAE1B,IAAI,gBAAgB,GAAG,KAAK,CAAA;IAC5B,IAAI,UAAU,GAAY,EAAE,CAAA;IAC5B,IAAI,wBAAwB,GAAG,KAAK,CAAA;IACpC,IAAI,oBAAoB,GAAG,IAAI,CAAA;IAC/B,IAAI,oBAAoB,GAAG,EAAE,CAAA;IAC7B,IAAI,yBAAyB,GAAa,EAAE,CAAA;IAC5C,IAAI,oBAAoB,GAAa,EAAE,CAAA;IACvC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAChC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,IAAA,2BAAY,EAC7D,IAAI,EACJ,gBAAgB,CACjB,CAAA;QACD,gBAAgB,GAAG,cAAc,CAAA;QAEjC,o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5B,KAAK,CAAC,WAAW,GAAG,gBAAgB,CAAA;oBACpC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBACpB,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,EAAE;wBACR,gBAAgB,EAAE,EAAE;wBACpB,aAAa,EAAE,SAAS,GAAG,CAAC;wBAC5B,WAAW,EAAE,EAAE;wBACf,kBAAkB,EAAE,KAAK;wBACzB,uBAAuB,EAAE,EAAE;wBAC3B,gBAAgB,EAAE,EAAE;wBACpB,eAAe,EAAE,IAAI;wBACrB,WAAW,EAAE,EAAE;wBACf,WAAW,EAAE,gBAAgB;qBAC9B,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAA;IAE1B,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAjJY,QAAA,WAAW,eAiJvB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits text into lines on either terminator, so a reader works whatever the
|
|
3
|
+
* file's own endings are.
|
|
4
|
+
*
|
|
5
|
+
* Readers must NOT split on the line ending configured in `lineEndings`. That
|
|
6
|
+
* value describes what the project wants, not what the file contains, and the
|
|
7
|
+
* lint path has no normalisation step - unlike the formatter, where
|
|
8
|
+
* `lineEndings.fix` converts every terminator before the later rules run. A
|
|
9
|
+
* configured-ending split over a file of the other style yields one string
|
|
10
|
+
* holding the whole file, so `lines[n - 1]` is not line n and column lookups
|
|
11
|
+
* throw.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} text - the text to split into lines.
|
|
14
|
+
* @returns {string[]} the lines, without their terminators.
|
|
15
|
+
*/
|
|
16
|
+
export declare const splitLines: (text: string) => string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.splitLines = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Splits text into lines on either terminator, so a reader works whatever the
|
|
6
|
+
* file's own endings are.
|
|
7
|
+
*
|
|
8
|
+
* Readers must NOT split on the line ending configured in `lineEndings`. That
|
|
9
|
+
* value describes what the project wants, not what the file contains, and the
|
|
10
|
+
* lint path has no normalisation step - unlike the formatter, where
|
|
11
|
+
* `lineEndings.fix` converts every terminator before the later rules run. A
|
|
12
|
+
* configured-ending split over a file of the other style yields one string
|
|
13
|
+
* holding the whole file, so `lines[n - 1]` is not line n and column lookups
|
|
14
|
+
* throw.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} text - the text to split into lines.
|
|
17
|
+
* @returns {string[]} the lines, without their terminators.
|
|
18
|
+
*/
|
|
19
|
+
const splitLines = (text) => text ? text.split(/\r\n|\n/) : [];
|
|
20
|
+
exports.splitLines = splitLines;
|
|
21
|
+
//# sourceMappingURL=splitLines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLines.js","sourceRoot":"","sources":["../../src/utils/splitLines.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;GAcG;AACI,MAAM,UAAU,GAAG,CAAC,IAAY,EAAY,EAAE,CACnD,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AADtB,QAAA,UAAU,cACY"}
|