-
Notifications
You must be signed in to change notification settings - Fork 5
feat: adds no-global-fetch rule to avoid direct usage of fetch in favour of our thin wrapper #62
Conversation
}, | ||
|
||
create(context) { | ||
let foundFetchImport = false; |
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 think this is sufficiently scoped per-context... if it's not, we can store this using some additional context
information.
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.
lg2m!
@@ -66,6 +66,7 @@ The bundled `eslint-plugin-liferay` plugin includes the following [rules](./plug | |||
|
|||
The bundled `eslint-plugin-liferay-portal` plugin includes the following [rules](./plugins/eslint-plugin-liferay-portal/docs/rules): | |||
|
|||
- [liferay-portal/no-global-fetch](./plugins/eslint-plugin-liferay-portal/docs/rules/no-global-fetch.md): Prevents usage of unwrapped fetch to avoid possible issues related to security misconfiguration. |
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.
Yeah, obviously we need a Markdown linter to enforce order here. 😂
@@ -0,0 +1,50 @@ | |||
# Disallow use of global fetch (no-global-fetch) | |||
|
|||
This rule guards against the direct use of the `fetch` API. As a secured-environment, Liferay Portal requests often rely on specific security headers and tokens being set in the requests. The `frontend-js-web` module offers a thin wrapp around `fetch` that takes care |
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.
wrapp → wrapper
# Disallow use of global fetch (no-global-fetch) | ||
|
||
This rule guards against the direct use of the `fetch` API. As a secured-environment, Liferay Portal requests often rely on specific security headers and tokens being set in the requests. The `frontend-js-web` module offers a thin wrapp around `fetch` that takes care | ||
of the most common configuration to avoid issues. |
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 need to break this one onto a new line.
@@ -6,6 +6,7 @@ | |||
|
|||
module.exports = { | |||
rules: { | |||
'no-global-fetch': require('./lib/rules/no-global-fetch'), |
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.
Should order this too, although I bet it will conflict with your other PR.
Ok, let me rebase and try to format things properly :D |
Done, @wincent! I've rebased and pushforced with an additional commit for the formatting issues. |
No description provided.