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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure polyfills.js is imported before anything else #13277

Merged
merged 1 commit into from
Feb 6, 2018
Merged

Make sure polyfills.js is imported before anything else #13277

merged 1 commit into from
Feb 6, 2018

Conversation

rsimha
Copy link
Contributor

@rsimha rsimha commented Feb 5, 2018

In #13256, we introduced new eslint rules to keep our import and require statements sorted. However, some modules like polyfill.js must be imported before any others.

This PR adds eslint rule exceptions to all import './polyfills'; statements to ensure that they appear at the top of their respective files. This will prevent gulp lint from complaining if another file-level import that alphabetically precedes ./polyfill (for example, ./foo) is added below it.

Will generate a linter error:

// src/polyfills.js must be the first import.
import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6
import './foo';

Won't generate a linter error:

// src/polyfills.js must be the first import.
import './polyfills'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6
import './foo'; // eslint-disable-line sort-imports-es6-autofix/sort-imports-es6

@rsimha
Copy link
Contributor Author

rsimha commented Feb 5, 2018

/to @jridgewell @erwinmombay

Are there any other imports like polyfills.js that we'd like to ensure stay at the top?

@rsimha rsimha merged commit 686abe4 into ampproject:master Feb 6, 2018
@rsimha rsimha deleted the 2018-02-05-ImportSortExceptions branch February 6, 2018 04:15
protonate pushed a commit to protonate/amphtml that referenced this pull request Feb 26, 2018
RanAbram pushed a commit to RanAbram/amphtml that referenced this pull request Mar 12, 2018
protonate pushed a commit to protonate/amphtml that referenced this pull request Mar 15, 2018
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