@we-are-singular/eslint-config
v3.4.0
Published
singular eslint stuff
Downloads
577
Readme
@we-are-singular/eslint-config
This package provides a shared ESLint configuration for Singular projects, using ESLint 9's flat config format. (for eslint8 check out version 2.X)
Installation
npm install --save-dev @we-are-singular/eslint-configPeer Dependencies
Some configurations require additional peer dependencies to be installed:
- TypeScript configuration: Requires
typescriptversion 5 or higher
Usage
This package now uses ESLint 9's flat config format. The old .eslintrc.js format and legacy helpers like config() and extend() have been removed in favor of the new flat config approach.
presets
Collection of ESLint config arrays for different technologies:
astro- Configuration for Astro projectsmarkdown- Configuration for Markdown filesmdx- MDX file configurationmonorepo- Configuration for monorepo projectsprettier- Prettier integrationreact- React-specific rulestypescript- TypeScript configurationyaml- YAML file configuration
overrides
Override functions that generate config objects for specific use cases:
vitestNode(patterns)- Vitest configuration for Node.js testsvitestReact(patterns)- Vitest configuration for React testsnamingConvention(options)- Naming convention rulesfileNamingConvention(options)- File naming convention rules
Example with Flat Config
// eslint.config.js
import { presets, overrides } from "@we-are-singular/eslint-config"
export default [
// Apply presets
...presets.typescript,
...presets.react,
// Add custom rules
{
rules: {
"no-console": "warn",
},
},
// Apply overrides for specific file patterns
overrides.vitestNode(["apps/backend/test/", "packages/logger/test/"]),
// Custom override
{
files: ["**/*.test.ts", "**/*.test.tsx"],
rules: {
"no-console": "off",
},
},
]Migration from ESLint 8
If you're migrating from the previous version that used ESLint 8:
- Update your config file: Replace
.eslintrc.jswitheslint.config.js - Remove legacy helpers: The
config(),extend(), and.allpreset have been removed - Use flat config format: Import presets and overrides directly and spread them into your config array
- Update file patterns: Flat configs use different glob patterns (use
**for recursive matching)
Before (ESLint 8)
// .eslintrc.js
const { extend, overrides } = require("@we-are-singular/eslint-config")
module.exports = extend({
rules: { "no-console": "warn" },
overrides: [overrides.vitestNode(["apps/backend"])],
})After (ESLint 9)
// eslint.config.js
import { presets, overrides } from "@we-are-singular/eslint-config"
export default [
...presets.typescript,
...presets.react,
{ rules: { "no-console": "warn" } },
overrides.vitestNode(["apps/backend/**"]),
]Releasing a new version
To release a new version, you need to have access to the @we-are-singular npm organization.
- Make sure you are logged in to the
@we-are-singularnpm organization by runningnpm loginand following the instructions. - Run
npm run releaseto trigger the release process. - Follow the instructions and make sure to select the correct version type.
- The release will be published to npm and github automatically.
