-
Notifications
You must be signed in to change notification settings - Fork 0
update contract-shield.config.json, contract-shield.json, configUtils.js and transpile.test.js #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,5 @@ | |
| "__tests__/**", | ||
| "**/*.test.js" | ||
| ], | ||
| "output": "./dist" | ||
| "output": "dist" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,5 +13,5 @@ | |
| "__tests__/**", | ||
| "**/*.test.js" | ||
| ], | ||
| "output": "./dist" | ||
| "output": "dist" | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
|
|
||
| module.exports = { | ||
| validateConfigSchema: (config) => { | ||
| if (typeof config !== "object" || config === null) { | ||
| return false; | ||
| } | ||
|
|
||
| const requiredFields = ["output"]; | ||
| for (const field of requiredFields) { | ||
| if (!Object.prototype.hasOwnProperty.call(config, field)) { | ||
| return false; | ||
| } | ||
| } | ||
|
Comment on lines
+8
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Schema Definition Mixed with Validation Logic
Tell me moreWhat is the issue?The validation logic mixes concerns by handling both the required fields list and the validation logic in the same function, making it harder to extend or modify the schema requirements. Why this mattersFuture changes to the configuration schema will require modifying the validation function directly, violating the Open-Closed Principle. Suggested change ∙ Feature PreviewSeparate schema definition from validation logic: const CONFIG_SCHEMA = {
required: ['output'],
types: {
output: 'string'
}
};
module.exports = {
validateConfigSchema: (config) => {
return validateAgainstSchema(config, CONFIG_SCHEMA);
}
};Provide feedback to improve future suggestions💬 Looking for more details? Reply to this comment to chat with Korbit. |
||
|
|
||
| if ( | ||
| typeof config.output !== "string" | ||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| }, | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid dirname reference
Tell me more
What is the issue?
The code uses 'dirname' (with double underscores) which is an undefined variable. The correct Node.js global variable is '__dirname' (single underscore).
Why this matters
This will cause a ReferenceError when trying to access the undefined variable, preventing the global configuration file from being found.
Suggested change ∙ Feature Preview
Replace 'dirname' with '__dirname':
Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.