Skip to content

New rule: Ban top-level querying in module. #228

Open
@koddsson

Description

Querying should be wrapped in event listeners such as document.addEventListener('DOMContentLoaded', ...) or a Web Component.

👎🏻 Examples of bad code.

const el = document.querySelector('.my-element')

👍🏻 Example of good code.

document.addEventListener('DOMContentLoaded', function() {
  const el = document.querySelector('.my-element')
})

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions