Closed richardm90 closed 7 months ago
Would it be better to have a single rule for the directive case such as DirectivesCase: ['upper', lower']? This would deprecate the existing UppercaseDirectives rule.
I absolutely think is the way to do (DirectivesCase
✅) it instead of having two separate rules (UppercaseDirectives
, LowercaseDirectives
👎). Don't remove UppercaseDirectives
from the schema definition (rpglint.json
), but instead mark it as deprecated: true
.
Is there a way to actually run Quick Fixes as part of unit tests?
Quick Fixes, no, sadly not. But we can test what location of where the fix will take place. See this assert for example:
assert.deepStrictEqual(errors[0], {
offset: { position: 194, end: 202 },
type: `IncorrectVariableCase`,
newValue: `localVar`
});
It's ensuring the ranges in the document, the error type and what the new value will be when the user quick fixes it. This has been a very suitable test so far. I see you are already doing this!
... but this failed with a module not found error.
This is very odd! I am glad the Debug Tests worked from VS Code. I would recommend ensuring you used npm i
before running npm run test
again. Feel free to share the logs with me.
Let me know what else you need from me for this PR.
@worksofliam, I've just started work on these changes but wanted to clarify one of yours points.
I absolutely think is the way to do (
DirectivesCase
✅) it instead of having two separate rules (UppercaseDirectives
,LowercaseDirectives
👎). Don't removeUppercaseDirectives
from the schema definition (rpglint.json
), but instead mark it asdeprecated: true
.
deprecated
isn't a valid property in rpglint.json
. Shall I add it anyway? I couldn't find any other examples in the code base except for language/models/tags.js
.
@richardm90 add for now. This keyword was added back in 2019 to json schema.
https://json-schema.org/draft/2019-09/json-schema-validation#rfc.section.9.3
@richardm90 add for now. This keyword was added back in 2019 to json schema.
https://json-schema.org/draft/2019-09/json-schema-validation#rfc.section.9.3
It looks as though the new JSON schema version isn't fully supported in VS Code yet but I've added the property.
... but this failed with a module not found error.
This is very odd! I am glad the Debug Tests worked from VS Code. I would recommend ensuring you used
npm i
before runningnpm run test
again. Feel free to share the logs with me.
I tried npm i
but still no joy. This is the output in the terminal. I think it might be something to do with Typescript transpiling.
$ npm run test
> vscode-rpgle@0.24.0 test
> tsx tests
(node:29973) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("file%3A///home/richard/git/vscode-rpgle/node_modules/tsx/dist/loader.js", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/modules/cjs/loader:1134
const err = new Error(message);
^
Error: Cannot find module '../parserSetup'
Require stack:
- /home/richard/git/vscode-rpgle/tests/suite/basics.js
- /home/richard/git/vscode-rpgle/tests/suite/index.js
- /home/richard/git/vscode-rpgle/tests/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/home/richard/git/vscode-rpgle/tests/suite/basics.js:5:34)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Module.require (node:internal/modules/cjs/loader:1225:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/richard/git/vscode-rpgle/tests/suite/basics.js',
'/home/richard/git/vscode-rpgle/tests/suite/index.js',
'/home/richard/git/vscode-rpgle/tests/index.js'
]
}
Node.js v18.19.0
@richardm90 Second ask: please update the docs with a PR over there when you can!
@worksofliam Ah OK. I wasn't clear on deprecated stuff. I thought there would be a period of time before the feature was removed from the codebase. I'm happy to strip it out of the codebase though and presumably remove if from the docs as well?
@richardm90 leave it in the docs for a while but leave a note that it's deprecated!
Changes
There is a linter rule for uppercase directives but not for lowercase directives, I like my directives to be in lowercase, so I've added a new LowercaseDirectives rule.
Whilst making this change I also corrected a couple of issues.
Questions/Points
DirectivesCase: ['upper', lower']
? This would deprecate the existingUppercaseDirectives
rule.npm run test
to run the test suite but this failed with a module not found error. I'm pretty sure this is because the typescript needs to be compiled before the tests are run but I couldn't work out how this be done so used the 'Debug Tests' from the VS Code debugger instead.Checklist
console.log
s I added