This package provides ESLint's shared config that designed to be strict as hell.
Install the base package with required dependencies:
npm install eslint-config-greenpie eslint --save-devThen install additional dependencies depending on your use case:
For oxlint users:
npm install oxlint --save-devFor ESLint users:
npm install @stylistic/eslint-plugin --save-devFor TypeScript projects:
npm install typescript-eslint --save-devFor Vue.js projects:
npm install eslint-plugin-vue --save-devIf using oxlint, create a .oxlintrc.jsonc file in the root of your project with the following content:
Run oxlint with the following command:
oxlintNote: The shared config has
reportUnusedDisableDirectivesenabled by default to prevent cluttering your project with unnecessary disable directives. If needed, you can override this in your local.oxlintrc.jsonc:{ "options": { "reportUnusedDisableDirectives": "off" } }
import { defineConfig } from 'eslint/config';
import { configs } from 'eslint-config-greenpie';
export default defineConfig(
...configs.default,
...configs.vue
);See more examples below.
Oxlint has one unified configuration for all supported languages (.js, .ts, .vue). You can granularly configure it in your local .oxlintrc.jsonc file.
Related ESLint rules are disabled by default if supported by oxlint.
| Config | Description |
|---|---|
default |
Includes js and ts configs |
js |
Includes JavaScript rules |
ts |
Includes TypeScript rules |
vue |
Includes rules for Vue.js |
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": [
"./node_modules/eslint-config-greenpie/configs/oxlintrc.jsonc"
],
"rules": {
"eslint/no-magic-numbers": "off",
},
"overrides": [{
"files": ["src/**/*.{ts,vue}"],
"env": {
"browser": true
}
}, {
"files": ["vite.config.mts"],
"env": {
"node": true
}
}]
}import { configs } from 'eslint-config-greenpie';
export default [
...configs.js
];import { configs } from 'eslint-config-greenpie';
export default [
...configs.js,
...configs.vue
];You will probably need to configure another parser for the <script> tag.
import { configs } from 'eslint-config-greenpie';
export default [
...configs.default,
...configs.vue
];The eslint/id-length rule enforces minimum identifier length (default: 2). If your project has legitimate short identifiers, add only those in your local .oxlintrc.jsonc.
{
"extends": [
"./node_modules/eslint-config-greenpie/configs/oxlintrc.jsonc"
],
"rules": {
"eslint/id-length": ["error", {
"max": 40,
"exceptions": [
"t", // translation function, e.g. from vue-i18n
"v" // valibot schema builder, e.g. `v.string()`, `v.object({...})`, etc.
]
}]
}
}The import/no-namespace rule disallows import * as syntax. If you need to use namespace imports for a specific package (e.g. valibot), you can override the rule in your local .oxlintrc.jsonc:
{
"extends": [
"./node_modules/eslint-config-greenpie/configs/oxlintrc.jsonc"
],
"rules": {
"import/no-namespace": ["error", {
"ignore": ["valibot"]
}]
}
}npm run testTests use Vitest and the ESLint programmatic API to lint code snippets directly against the configs defined in this repository.
{ "$schema": "./node_modules/oxlint/configuration_schema.json", "extends": [ "./node_modules/eslint-config-greenpie/configs/oxlintrc.jsonc" ] }