Deck.gl specific linting rules for ESLint
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
Add "deckgl" to the plugins section.
{
"plugins": [
"deckgl"
]
}
Enable the rules that you would like to use
"rules": {
"deckgl/exhaustive-triggers": "warning"
}
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
},
});
ESLint-plugin-DeckGL is licensed under the MIT License.