eslint-config-openlayers
raw JSON → 21.0.0 verified Sat Apr 25 auth: no javascript
Shareable ESLint configuration enforcing OpenLayers coding style. v21.0.0 (stable), updated regularly with dependency bumps. Supports ESLint flat config (eslint.config.js). Differentiator: opinionated set of rules for OpenLayers projects, includes JSdoc and Prettier integration. Requires ESLint as peer dependency.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/eslint-config-openlayers/index.js not supported. ↓
cause Using CommonJS require() on an ESM-only package.
fix
Use import syntax in your eslint.config.js or convert to ES module.
error Error: Failed to load config 'openlayers' to extend from. ↓
cause Using .eslintrc file with extends; flat config required since v18.
fix
Create eslint.config.js and use import openlayers from 'eslint-config-openlayers'; export default [...openlayers];
error Error: Configuration for rule 'no-else-return' is invalid: value 'error' is not allowed. ↓
cause Rule 'no-else-return' uses allowElseIf option not present in ESLint config.
fix
Remove you can use the built-in 'no-else-return' rule configuration or otherwise adjust.
error Parsing error: The keyword 'const' is reserved. ↓
cause ESLint is not configured for ES6+ syntax; config may not include ecmaVersion.
fix
Ensure eslint-config-openlayers is correctly imported; if using custom parser, set ecmaVersion: 2022.
Warnings
breaking Flat config syntax required as of v18.0.0; .eslintrc files no longer supported ↓
fix Use eslint.config.js with export default [...openlayers];
breaking No else-if return rule added in v18.0.0 may cause new lint errors ↓
fix Refactor code to avoid else-if after return, e.g. remove else block.
deprecated ESLint 8 support ends; v18+ uses ESLint 9 flat config only ↓
fix Upgrade ESLint to 9.x and use flat config.
gotcha Prettier integration requires eslint-config-prettier and eslint-plugin-prettier to be installed ↓
fix Add 'eslint-config-prettier' and 'eslint-plugin-prettier' as devDependencies.
breaking Prefer Object to object rule added in v16.2.2 may cause errors ↓
fix Use `Object` instead of `object` in TypeScript types or JSDoc.
gotcha VSCode users must enable flat config in settings ↓
fix Set 'eslint.useFlatConfig': true in VSCode settings.
Install
npm install eslint-config-openlayers yarn add eslint-config-openlayers pnpm add eslint-config-openlayers Imports
- default wrong
const openlayers = require('eslint-config-openlayers');correctimport openlayers from 'eslint-config-openlayers'; - openlayers wrong
import openlayers from 'eslint-config-openlayers'; // correctcorrectimport openlayers from 'eslint-config-openlayers'; - FlatConfig wrong
module.exports = require('eslint-config-openlayers');correctimport openlayers from 'eslint-config-openlayers'; export default [...openlayers];
Quickstart
// eslint.config.js
import openlayers from 'eslint-config-openlayers';
export default [
...openlayers,
{
rules: {
// Custom overrides
'no-console': 'warn',
},
},
];