@dcl/eslint-config
v3.1.0
Published
Decentraland ESLint config
Readme
DCL ESLint & Prettier Config
Installation
# Using Yarn
yarn add -D @dcl/eslint-config
# Using npm
npm install -D @dcl/eslint-configPrerequisites
- Node.js >= 18.18.0
- ESLint >= 9.0.0
- TypeScript (for TypeScript-based presets)
Usage (ESLint 9, eslint.config.js)
In your eslint.config.js:
const coreDapps = require("@dcl/eslint-config/core-dapps.config");
module.exports = [...coreDapps];Other presets available:
@dcl/eslint-config/core-services.config@dcl/eslint-config/dapps.config@dcl/eslint-config/ui.config@dcl/eslint-config/sdk.config
Legacy usage with .eslintrc (ESLint 8 / transition)
In your .eslintrc.cjs:
module.exports = {
extends: ["@dcl/eslint-config/core-dapps"],
};Type-aware rules without manual parserOptions.project
TypeScript presets (for example core-dapps) auto-detect a tsconfig in the consumer repo:
tsconfig.eslint.json(preferred)tsconfig.jsontsconfig.app.json/tsconfig.node.json(Vite)
If no tsconfig is found, rules that require type information are disabled to avoid crashes.
npm-package-json-lint (shareable config)
In your .npmpackagejsonlintrc.json:
{
"extends": "@dcl/eslint-config/npm-package-json-lint"
}Key rules:
dependenciesanddevDependenciesmust use exact versions- automatic exception (computed from your
package.json): internal packages (@dcl/*,decentraland-*) may use version ranges (^)
How the exception works:
@dcl/eslint-config/npm-package-json-lintis a JavaScript config module.- When
npmPkgJsonLintloads it, it reads the consumer repopackage.jsonfromprocess.cwd()and builds the exception list from the package names found independencies/devDependenciesthat match@dcl/*ordecentraland-*. - That means you don't need to list exceptions manually: if you add
@dcl/schemaswith^it will be allowed; if you addreactwith^it will be reported.
Monorepos: run npmPkgJsonLint from the package folder you want to lint (so process.cwd() points to the right package.json), or override rules locally.
Peer dependencies
This package publishes most tooling as peerDependencies. In the consumer repo you'll need (depending on the preset):
eslint@typescript-eslint/parser,@typescript-eslint/eslint-pluginprettier,eslint-plugin-prettier,eslint-config-prettiereslint-plugin-import,eslint-import-resolver-typescripteslint-plugin-react(if you use React presets)eslint-plugin-autofix
Note: some presets configure the
babel-moduleresolver; if you use it, installeslint-import-resolver-babel-moduleand its peers (@babel/core,babel-plugin-module-resolver).
Upgrading from v2 to v3
Breaking changes
- ESLint 9 required – The new flat config (
eslint.config.js) requires ESLint >= 9.0.0 - Peer dependencies – Plugins are now peer dependencies (you install them in your project)
- New entrypoints – Use
*.config.jsfor ESLint 9, keep*(without.config) for legacy.eslintrc - Removed presets –
gatsbypreset has been removed
Migration steps
- Update the package:
# Yarn
yarn add -D @dcl/eslint-config@^3.0.0
# npm
npm install -D @dcl/eslint-config@^3.0.0- Install peer dependencies (if not already present):
# Yarn
yarn add -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin \
prettier eslint-plugin-prettier eslint-config-prettier \
eslint-plugin-import eslint-import-resolver-typescript eslint-plugin-autofix
# npm
npm install -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin \
prettier eslint-plugin-prettier eslint-config-prettier \
eslint-plugin-import eslint-import-resolver-typescript eslint-plugin-autofix- Update your ESLint config:
// eslint.config.js (ESLint 9)
const coreDapps = require("@dcl/eslint-config/core-dapps.config");
module.exports = [...coreDapps];- If you encounter peer dependency conflicts:
# Yarn - Remove conflicting old versions first
yarn remove eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
# Then reinstall with exact versions
yarn add -D [email protected] @typescript-eslint/[email protected] @typescript-eslint/[email protected]# npm - Remove conflicting old versions first
npm uninstall eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
# Then reinstall with exact versions
npm install -D [email protected] @typescript-eslint/[email protected] @typescript-eslint/[email protected]Note: Avoid using
--legacy-peer-depsunless absolutely necessary, as it can mask version incompatibilities.
License
Apache 2.0
