All Projects → mizdra → eslint-plugin-layout-shift

mizdra / eslint-plugin-layout-shift

Licence: MIT license
ESLint plugin to force responsive media elements to set the width/height attributes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to eslint-plugin-layout-shift

Sowing Machine
🌱A React UI toolchain & JSX alternative
Stars: ✭ 64 (+326.67%)
Mutual labels:  eslint, jsx, eslint-plugin
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.
Stars: ✭ 19 (+26.67%)
Mutual labels:  eslint, jsx, eslint-plugin
Eslint Plugin Ava
ESLint rules for AVA
Stars: ✭ 209 (+1293.33%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Eslint Comments
Additional ESLint rules for directive comments of ESLint.
Stars: ✭ 221 (+1373.33%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-pug
An ESLint plugin for linting inline scripts in Pug files
Stars: ✭ 17 (+13.33%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Boundaries
Eslint plugin checking architecture boundaries between elements
Stars: ✭ 157 (+946.67%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Jsx A11y
Static AST checker for a11y rules on JSX elements.
Stars: ✭ 2,609 (+17293.33%)
Mutual labels:  eslint, jsx
Eslint Plugin Mocha
ESLint rules for mocha
Stars: ✭ 249 (+1560%)
Mutual labels:  eslint, eslint-plugin
Eslint Import Resolver Alias
a simple Node behavior import resolution plugin for eslint-plugin-import, supporting module alias
Stars: ✭ 121 (+706.67%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-editorconfig
An ESLint plugin to enforce EditorConfig rules
Stars: ✭ 22 (+46.67%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-rulesdir
An ESLint plugin to load project-specific ESLint rules
Stars: ✭ 28 (+86.67%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-disable
Disable ESLint plugins using file path patterns and inline comments
Stars: ✭ 51 (+240%)
Mutual labels:  eslint, eslint-plugin
Redux React Starter
DEPRECATED use the new https://github.com/didierfranc/react-webpack-4
Stars: ✭ 137 (+813.33%)
Mutual labels:  eslint, jsx
Eslint Plugin Unicorn
Various awesome ESLint rules
Stars: ✭ 2,157 (+14280%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Lodash
ESLint rules for lodash
Stars: ✭ 208 (+1286.67%)
Mutual labels:  eslint, eslint-plugin
Hyperapp One
Hyperapp One is a Parcel boilerplate for quickstarting a web application with Hyperapp (V1), JSX, and Prettier.
Stars: ✭ 129 (+760%)
Mutual labels:  eslint, jsx
Eslint Plugin Ember
An ESlint plugin that provides set of rules for Ember Applications based on commonly known good practices.
Stars: ✭ 240 (+1500%)
Mutual labels:  eslint, eslint-plugin
eslint-plugin-svelte
ESLint plugin for Svelte using AST
Stars: ✭ 22 (+46.67%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin I18n Json
Fully extendable eslint plugin for JSON i18n translation files.
Stars: ✭ 101 (+573.33%)
Mutual labels:  eslint, eslint-plugin
Eslint Plugin Css Modules
Project status: NOT MAINTAINED; Checks that you are using the existent css/scss classes, no more no less
Stars: ✭ 115 (+666.67%)
Mutual labels:  eslint, eslint-plugin

@mizdra/eslint-plugin-layout-shift

ESLint plugin to force responsive media elements to set the width/height attributes

Motivation

The Web has been using <img> tags to load images since ancient times. However, the <img> tag does not have any attribute to embed the aspect ratio. As a result, the size of the responsive img element cannot be determined until the browser fetches the image from the network and finishes loading, and there is a problem that Layout Shift occurs on the page.

To solve this problem, the idea of computing the layout using the width and height attributes has been proposed and is starting to be implemented in browsers.

This plugin forbids media element without an explicit size attributes to prevent Layout Shift from occurring.

Installation

You'll first need to install ESLint:

$ npm i eslint --save-dev
$ yarn add eslint --save-dev

Next, install @mizdra/eslint-plugin-layout-shift:

$ npm install @mizdra/eslint-plugin-layout-shift --save-dev
$ yarn add @mizdra/eslint-plugin-layout-shift --save-dev

Usage

Add @mizdra/layout-shift to the plugins section of your .eslintrc configuration file.

{
  "plugins": ["@mizdra/layout-shift"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "@mizdra/layout-shift/require-size-attributes": 2
  }
}

Supported Rules

Release (for contributor)

$ # Wait for passing CI...
$ git switch master
$ git pull
$ yarn version
$ npm publish
$ git push --follow-tags
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].