Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

feat: adds no-global-fetch rule to avoid direct usage of fetch in favour of our thin wrapper #62

Merged
merged 2 commits into from
Aug 12, 2019
Merged

Conversation

jbalsas
Copy link
Contributor

@jbalsas jbalsas commented Aug 12, 2019

No description provided.

},

create(context) {
let foundFetchImport = false;
Copy link
Contributor Author

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.

Copy link
Contributor

@wincent wincent left a 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.
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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'),
Copy link
Contributor

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.

@jbalsas
Copy link
Contributor Author

jbalsas commented Aug 12, 2019

Ok, let me rebase and try to format things properly :D

@jbalsas
Copy link
Contributor Author

jbalsas commented Aug 12, 2019

Done, @wincent! I've rebased and pushforced with an additional commit for the formatting issues.

@wincent wincent merged commit a21c78f into liferay:master Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants