ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

JavaScript files in examples/ (like visual tests) are not linted/formatted #32306

Closed alanorozco closed 3 years ago

alanorozco commented 3 years ago

JavaScript files in examples/ are not formatted with prettier or linted.

npx prettier --check examples/**/*.js

[warn] examples/amp-ad/sticky.js
[warn] examples/amp-script/amp-script-demo.js
[warn] examples/amp-script/empty.js
[warn] examples/amp-script/todomvc.ssr.js
[warn] examples/amp-script/vue-todomvc.js
[warn] examples/amphtml-ads/ads-tag-integration.js
[warn] examples/example-sw.js
[warn] examples/mraid/mraid.js
[warn] examples/pwa/pwa-sw.js
[warn] examples/pwa/pwa.js
[warn] examples/visual-tests/amp-date-picker/amp-date-picker.js
[warn] examples/visual-tests/amp-list/amp-list.amp.js
[warn] examples/visual-tests/amp-video-docking/_helpers.js
[warn] examples/visual-tests/amphtml-ads/static.js
[warn] examples/visual-tests/font.amp.404/font.amp.js
[warn] Code style issues found in the above file(s). Forgot to run Prettier?

There's a rule somewhere excluding examples/ because we don't want to format .html files. We should exclude .js files from that rule.

@ampproject/wg-infra @danielrozenberg @rsimha

rsimha commented 3 years ago

Here's where the files are ignored:

https://github.com/ampproject/amphtml/blob/e9e76fdbaeecf0062d3eaaf99734abbdc376da38/.eslintignore#L15

Wanna send out a PR to make the rule less broad (and auto-fix)? 😃

Note: For JS files, we don't use prettier directly. Instead, we use eslint with the prettier plugin (so that only one entity is auto-fixing the files, and so that we can mix other lint rules with prettier).

You can auto-fix JS files once you change the rule by running:

gulp lint --fix