Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃彈 Ensure that forbidden term allowlists are updated #33490

Merged
merged 12 commits into from
Mar 25, 2021

Conversation

alanorozco
Copy link
Member

@alanorozco alanorozco commented Mar 25, 2021

Adds a lint rule local/forbidden-terms-config that's used on one file:

  • Term keys should be string literals.
  • Allowlist items should be string literals.
  • Allowed files should contain the term.
  • allowlist property should be removed if empty.

@alanorozco alanorozco requested a review from rsimha March 25, 2021 18:50
@amp-owners-bot
Copy link

Hey @erwinmombay, @jridgewell! These files were changed:

build-system/eslint-rules/forbidden-terms-config.js

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one suggestion. Job well done!

Comment on lines 19 to 24
// Terms are defined in this file.
/* eslint-disable local/no-forbidden-terms */

// Ensures that file is up-to-date.
/* eslint "local/forbidden-terms-config": 2 */

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For maintainability, would it make sense to move these two rules to a new file build-system/test-configs/.eslintrc.js?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, moved. It also happens to speed up linting. File-level rules seem to only ignore reports, but still run.

TIMING=1 npx eslint build-system/test-configs/forbidden-terms.js
  Rule                          | Time (ms) 
  :-----------------------------|----------:
  prettier/prettier             |   248.790 
  local/forbidden-terms-config  |    34.043 
- local/no-forbidden-terms      |    30.997 
+ jsdoc/check-types             |    16.759 

@@ -1235,8 +1103,6 @@ const forbiddenTermsSrcInclusive = {
'extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js',
'extensions/amp-iframe/0.1/amp-iframe.js',
'extensions/amp-script/0.1/amp-script.js',
'extensions/amp-sidebar/0.1/amp-sidebar.js',
'extensions/amp-sidebar/0.2/amp-sidebar.js',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bravo! I don't think this kind of a cleanup would've been possible (or would've ever happened) earlier.

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta suggestion: Today, all the error messages from local/no-forbidden-terms are split across two lines, which breaks the flow of lint error reporting. Would it make sense / be possible to make them mostly single-line (except for ones that are really too long)?

image

}
}

function* removeFromArray(fixer, node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just fixer.remove(node) and let eslint automatically fix formatting?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that won't remove the trailing comma nor the whitespace.

I also want to remove comments on the same line, since context for those is lost.

@alanorozco
Copy link
Member Author

alanorozco commented Mar 25, 2021

@rsimha Sure, makes sense! I'll do on a separate PR since that belongs to the lint rule.

EDIT: #33504

@alanorozco alanorozco merged commit aa46b7e into ampproject:master Mar 25, 2021
@alanorozco alanorozco deleted the terms-allowlist branch March 25, 2021 23:49
rochapablo pushed a commit to rochapablo/amphtml that referenced this pull request Aug 30, 2021
Adds a lint rule `local/forbidden-terms-config` that's used on one file:

- Term keys should be string literals.
- Allowlist items should be string literals.
- Allowed files should contain the term.
- `allowlist` property should be removed if empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants