-
Notifications
You must be signed in to change notification settings - Fork 16
1200 feature GitHub action javascript linter formatter #1201
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
1200 feature GitHub action javascript linter formatter #1201
Conversation
Reviewer's Guide by SourceryThis pull request introduces a GitHub action to lint and format JavaScript code. This addresses the current lack of quality controls for JavaScript code. Sequence diagram for authorization check flowsequenceDiagram
participant Client
participant AuthzWorker
participant CoreService
Client->>AuthzWorker: checkAuth(client_id, path, action)
AuthzWorker->>AuthzWorker: isURLValid(path)
AuthzWorker->>AuthzWorker: removeOrigin(path)
AuthzWorker->>AuthzWorker: isPathValid(path)
AuthzWorker->>AuthzWorker: isTestPath(path)
alt is test path
AuthzWorker-->>Client: return 0 (allowed)
else not test path
AuthzWorker->>CoreService: send authorization request
CoreService-->>AuthzWorker: response
AuthzWorker->>AuthzWorker: processResponse(response)
AuthzWorker-->>Client: return result
end
Class diagram for AuthzWorker refactoringclassDiagram
class AuthzWorker {
-Config* m_config
-LogContext m_log_context
-string m_local_globus_path_root
-string m_test_path
-map<CredentialType, string> m_cred_options
-unique_ptr<ICredentials> m_sec_ctx
-unique_ptr<ICommunicator> m_comm
+AuthzWorker(Config*, LogContext)
+checkAuth(char*, char*, char*) int
-isTestPath(string) bool
-isPathValid(string) bool
-isURLValid(char*) bool
-removeOrigin(char*) string
-getAuthzPath(char*) string
-processResponse(ICommunicator::Response&) int
-initCommunicator() void
}
note for AuthzWorker "Refactored class with improved
modularity and error handling"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…errors Address eslint errors
|
Currently the formatter is passing and not failing because formatting needs to be fixed in a separate PR. JavaScript formatter is set to pass inspite of failures currently. |
AronPerez
left a comment
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.
actions/setup-node@v3 -> v4
actions/checkout@v3 -> v4
Linter + prettier config
| - name: Install ESLint | ||
| run: | | ||
| npm init -y | ||
| npm install eslint@latest @babel/eslint-parser@latest eslint-define-config globals --save |
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.
Do we want to add a package.json to manage these scripts? That way we could just run npm run lint
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.
This works as it is. What is the advantage of adding another file to the repo? I suppose if you want to test locally... and ensure the packages are the same?
| "vueIndentScriptAndStyle": false, | ||
| "proseWrap": "preserve", | ||
| "insertPragma": false, | ||
| "printWidth": 100, |
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.
❓: Why 100 and not 120?
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.
@t-ramz any particular reason, do you want to increase it?
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.
No reason, I am happy to increase it. In fact, I don't particularly like width limits at all. More is more here.
| "insertPragma": false, | ||
| "printWidth": 100, | ||
| "requirePragma": false, | ||
| "tabWidth": 4, |
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.
Nit: I'm a fan of 2 tabs per tab width personally
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.
Did you mean spaces? per tab? That is actually my default as well.
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.
But I don't feel strongly about this.
| @@ -0,0 +1,21 @@ | |||
| { | |||
| "arrowParens": "always", | |||
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.
❤️
| "singleQuote": false, | ||
| "jsxSingleQuote": false, | ||
| "quoteProps": "as-needed", | ||
| "trailingComma": "all", |
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.
I like the es5 option
| continue-on-error: true # Allow this job to fail without failing the entire workflow | ||
| run: | | ||
| prettier "**/*.js" --write | ||
| git diff |
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.
Why are we doing this?
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.
Prettier won't show the differences, it just shows what files will be changed.
| module.exports = [{ | ||
| languageOptions: { | ||
| globals: { | ||
| ...globals.jquery, | ||
| ...globals.node, | ||
| }, | ||
| }, | ||
| }]; |
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.
We should extend prettier to prevent rule collision issues:
| module.exports = [{ | |
| languageOptions: { | |
| globals: { | |
| ...globals.jquery, | |
| ...globals.node, | |
| }, | |
| }, | |
| }]; | |
| module.exports = [{ | |
| languageOptions: { | |
| globals: { | |
| ...globals.jquery, | |
| ...globals.node, | |
| }, | |
| }, | |
| plugins: ["prettier"], | |
| extends: ["plugin:prettier/recommended"], | |
| }]; |
Co-authored-by: Aaron Perez <aperez0295@gmail.com>
PR Description
JavaScript code needs quality controls which are currently missing this is an attempt to add them.
Tasks
Summary by Sourcery
Add JavaScript linting and formatting using ESLint and Prettier.
CI:
Tests: