Skip to content

jstaab/eslint-plugin-deckgl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ESLint-plugin-DeckGL

Deck.gl specific linting rules for ESLint

Installation

Install ESLint either locally or globally. (Note that locally, per project, is strongly preferred)

$ npm install eslint --save-dev

If you installed ESLint globally, you have to install Deck.gl plugin globally too. Otherwise, install it locally.

$ npm install https://github.com/jstaab/eslint-plugin-deckgl --save-dev

Configuration

Add "deckgl" to the plugins section.

{
  "plugins": [
    "deckgl"
  ]
}

Enable the rules that you would like to use

  "rules": {
    "deckgl/exhaustive-triggers": "warning"
  }

Rules

exhaustive-triggers

All non-local variables used in an accessor function must be listed in the containing layer's updateTriggers property, under the key of the accessor function name.

new ScatterplotLayer({
  data: [...],
  getRadius: d => Math.sqrt(d.populationsByYear[currentYear]),
  // ^^^ exhaustive-triggers will complain: "currentYear" missing from updateTriggers
});

new ScatterplotLayer({
  data: [...],
  getRadius: d => Math.sqrt(d.populationsByYear[currentYear]),
  // ^^^ all ok
  updateTriggers: {
    getRadius: [currentYear]
  },
});

 new ScatterplotLayer({
  data: [...],
  getRadius: d => Math.sqrt(d.populationsByYear[0]),
  // ^^^ all ok -- all variables are local
});

All updateTriggers property values must be arrays when their corresponding accessor function contains non-local variables.

new ScatterplotLayer({
  data: [...],
  getRadius: d => Math.sqrt(d.populationsByYear[currentYear]),
  // ^^^ exhaustive-triggers will complain (because it expects an array)
  updateTriggers: {
    getRadius: currentYear
    // ^^^ exhaustive-triggers will complain: "getRadius" updateTrigger should be an array
  },
});

License

ESLint-plugin-DeckGL is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published