Centralized linting and code formatting toolkit for Diplodoc projects. Combines ESLint, Prettier, and Stylelint configurations and automates their setup.
- Automatic setup — one command to initialize all tools
- Automatic updates — synchronizes configurations across packages
- Metapackage and standalone support — works as part of the metapackage and as a standalone npm package
- Unified standards — shared linting rules for all Diplodoc packages
- Git hooks — automatic pre-commit hook setup via Husky
- TypeScript/JavaScript — full support for both languages
- CSS/SCSS — style support via Stylelint
npm install --save-dev @diplodoc/lintRun the initialization command in your package root:
npx @diplodoc/lint initThis command will:
- Add necessary scripts to
package.json - Create configuration files (
.eslintrc.js,.prettierrc.js,.stylelintrc.js) - Set up Git hooks via Husky
- Update
.gitignore,.eslintignore,.prettierignore,.stylelintignore
After initialization, commit the changes:
git add --all && git commit -m 'chore: init lint'Code checking:
npm run lintAutomatic fixing:
npm run lint:fixUpdate configurations:
npx @diplodoc/lint updateNote: The
updatecommand runs automatically before each check (npm run lint), so configurations are always up-to-date.
Initializes linting in a package:
- Adds scripts to
package.json:lint— code checkinglint:fix— automatic fixingpre-commit— pre-commit checkingprepare— Husky setup
- Copies configuration files from
scaffolding/ - Sets up Husky for Git hooks
- Updates ignore files
Updates configuration files to the latest versions:
- Updates
.eslintrc.js,.prettierrc.js,.stylelintrc.js - Updates ignore files with new patterns
- Does not re-initialize Husky
- Does not modify existing scripts in
package.json
Important: This command runs automatically before
lintandlint fix, so configurations are always synchronized.
Checks code for rule compliance:
- Automatically runs
lint update - Runs ESLint for JavaScript/TypeScript files
- Runs Prettier for formatting checks
- Runs Stylelint for CSS/SCSS files (if present)
Automatically fixes found issues:
- Automatically runs
lint update - Runs ESLint with
--fixflag - Runs Prettier with
--writeflag - Runs Stylelint with
--fixflag (if CSS/SCSS files exist)
The following configuration files are automatically generated and updated by @diplodoc/lint:
.eslintrc.js.prettierrc.js.stylelintrc.js.lintstagedrc.js.eslintignore.prettierignore.stylelintignore.gitignore(patterns are added automatically)
lint update (which runs automatically before each lint command).
If you need to customize configuration:
- Check if the customization can be done via package-level overrides (see below)
- If not, consider opening an issue or PR to
@diplodoc/lintto add the feature - For ignore patterns, they are managed automatically — if you need additional patterns, they should be added to
@diplodoc/lint'smodify-ignore.jsscript
After initialization, the following files are created in the package root:
module.exports = {
root: true,
extends: require.resolve('@diplodoc/lint/eslint-config'),
parserOptions: {
tsconfigRootDir: __dirname,
project: true,
},
};Packages can extend the configuration at the src/ level, but should not override base settings.
module.exports = require('@diplodoc/lint/prettier-config');module.exports = {
extends: require.resolve('@diplodoc/lint/stylelint-config'),
};Created only if CSS/SCSS files exist in the project.
- Configurations for TypeScript and JavaScript
- React support (via
eslint-config/client) - Node.js support (via
eslint-config/node) - Project-aware TypeScript parsing
- Unified formatting style for all packages
- Automatic formatting on save (via editor)
- CSS and SCSS support
- Uses
@gravity-ui/stylelint-configas base
- Git hooks management
- Pre-commit hook runs
lint-staged
- Checks only changed files
- Fast pre-commit checking
The package works in two modes:
When the package is installed as part of the metapackage via npm workspaces:
- Dependencies are resolved through shared
node_modules - Commands work through workspace links
package-lock.jsonis managed at the metapackage level
When the package is used as a standalone npm package:
- All dependencies are installed locally
- Commands work through
node_modules/.bin - For
package-lock.jsonmanagement, usenpm i --no-workspaces --package-lock-only
Both modes are supported automatically — the package detects the context and works accordingly.
After lint init, the following scripts are added to package.json:
{
"scripts": {
"lint": "lint update && lint",
"lint:fix": "lint update && lint fix",
"pre-commit": "lint update && lint-staged",
"prepare": "husky"
}
}lint— code checking (with auto-update)lint:fix— automatic fixing (with auto-update)pre-commit— pre-commit checking (runs via Husky)prepare— Husky setup when installing dependencies
The package automatically updates the following ignore files:
.gitignore— system files, dependencies, artifacts.eslintignore— system files, dependencies, artifacts,test/,scripts/,build/,esbuild/.prettierignore— system files, dependencies, artifacts.stylelintignore— system files, dependencies, artifacts
init and update, duplicates are not created. Manual edits will be overwritten.
If you need additional ignore patterns, they should be added to @diplodoc/lint's modify-ignore.js script.
The package includes a comprehensive test suite (34 tests):
# Run all tests
npm test
# Unit tests only
npm run test:unit
# Integration tests only
npm run test:integrationTests use Node.js built-in assert module and require no external dependencies.
@diplodoc/lint/
├── bin/ # Executable scripts
│ ├── lint # Main script
│ ├── eslint # ESLint proxy
│ ├── prettier # Prettier proxy
│ └── ...
├── scripts/ # Helper scripts
│ ├── modify-package.js
│ └── modify-ignore.js
├── scaffolding/ # Configuration templates
│ ├── .eslintrc.js
│ ├── .prettierrc.js
│ └── ...
└── test/ # Tests
├── unit/
├── integration/
└── helpers/
- Make code changes
- Run tests:
npm test - Check linting:
npm run lint - Test in a test package:
npx @diplodoc/lint init
- Auto-update: The
lint updatecommand runs automatically on eachlintexecution, ensuring configuration synchronization - Backward compatibility: When updating configs, backward compatibility is considered. Breaking changes require major version bumps
- Package independence: This package does not depend on other Diplodoc packages (except devops infrastructure)
- Replaces deprecated packages: This package replaces
@diplodoc/eslint-configand@diplodoc/prettier-config. Do not use deprecated packages - Critical package: This is a critical infrastructure dependency used by all Diplodoc packages. Changes should be thoroughly tested
MIT