Gathering detailed insights and metrics for @radum/eslint-config
Gathering detailed insights and metrics for @radum/eslint-config
Gathering detailed insights and metrics for @radum/eslint-config
Gathering detailed insights and metrics for @radum/eslint-config
My personal eslint config that I use across all my projects.
npm install @radum/eslint-config
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (80.84%)
JavaScript (12.61%)
Vue (5.06%)
HTML (0.59%)
Astro (0.5%)
CSS (0.21%)
Svelte (0.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
241 Commits
1 Forks
1 Watchers
4 Branches
4 Contributors
Updated on Apr 09, 2025
Latest Version
10.0.0
Package Id
@radum/eslint-config@10.0.0
Unpacked Size
858.05 kB
Size
139.05 kB
File Count
9
NPM Version
11.1.0
Node Version
22.14.0
Published on
Apr 09, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
39
15
37
Personal recommended shareable config for eslint. Started as a rip-off of Anthony's ESLint config preset amazing config but added my own flavour to it. Use it as is or as a foundation for your own config. You can extend or clone and change.
.gitignore
by default[!NOTE] Since v7.0.0, this config is rewritten to the new ESLint Flat config, check the release note for more details.
Since v8.0.0, ESLint v9.5.0+ is now required.
[!WARNING] Please keep in mind that this is a personal config with a lot opinions. Changes might not always be pleased by everyone and every use cases.
If you are using this config directly, I'd suggest you review the changes everytime you update. Or if you want more control over the rules, always feel free to fork it. Thanks!
We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
1pnpm dlx @radum/eslint-config@latest
If you prefer to set up manually:
1pnpm i -D eslint @radum/eslint-config
And create eslint.config.mjs
in your project root:
1// eslint.config.mjs 2import radum from '@radum/eslint-config'; 3 4export default radum();
If you still use some configs from the legacy eslintrc format, you can use the @eslint/eslintrc
package to convert them to the flat config.
1import { FlatCompat } from '@eslint/eslintrc'; 2// eslint.config.mjs 3import radum from '@radum/eslint-config'; 4 5const compat = new FlatCompat(); 6 7export default radum( 8 { 9 ignores: [], 10 }, 11 12 // Legacy config 13 ...compat.config({ 14 extends: [ 15 'eslint:recommended', 16 // Other extends... 17 ], 18 }) 19 20 // Other flat configs... 21);
Note that
.eslintignore
no longer works in Flat config, see customization for more details.
For example:
1{ 2 "scripts": { 3 "lint": "eslint", 4 "lint:fix": "eslint --fix" 5 } 6}
Install VS Code ESLint extension
Add the following settings to your .vscode/settings.json
:
1{ 2 // Disable the default formatter, use eslint instead 3 "prettier.enable": false, 4 "editor.formatOnSave": false, 5 6 // Auto fix 7 "editor.codeActionsOnSave": { 8 "source.fixAll.eslint": "explicit", 9 "source.organizeImports": "never" 10 }, 11 12 // Silent the stylistic rules in you IDE, but still auto fix them 13 "eslint.rules.customizations": [ 14 { "rule": "style/*", "severity": "off", "fixable": true }, 15 { "rule": "format/*", "severity": "off", "fixable": true }, 16 { "rule": "*-indent", "severity": "off", "fixable": true }, 17 { "rule": "*-spacing", "severity": "off", "fixable": true }, 18 { "rule": "*-spaces", "severity": "off", "fixable": true }, 19 { "rule": "*-order", "severity": "off", "fixable": true }, 20 { "rule": "*-dangle", "severity": "off", "fixable": true }, 21 { "rule": "*-newline", "severity": "off", "fixable": true }, 22 { "rule": "*quotes", "severity": "off", "fixable": true }, 23 { "rule": "*semi", "severity": "off", "fixable": true } 24 ], 25 26 // Enable eslint for all supported languages 27 "eslint.validate": [ 28 "javascript", 29 "javascriptreact", 30 "typescript", 31 "typescriptreact", 32 "vue", 33 "html", 34 "markdown", 35 "json", 36 "jsonc", 37 "yaml", 38 "toml", 39 "xml", 40 "gql", 41 "graphql", 42 "astro", 43 "svelte", 44 "css", 45 "less", 46 "scss", 47 "pcss", 48 "postcss" 49 ] 50}
Update your configuration to use the following:
1local customizations = { 2 { rule = 'style/*', severity = 'off', fixable = true }, 3 { rule = 'format/*', severity = 'off', fixable = true }, 4 { rule = '*-indent', severity = 'off', fixable = true }, 5 { rule = '*-spacing', severity = 'off', fixable = true }, 6 { rule = '*-spaces', severity = 'off', fixable = true }, 7 { rule = '*-order', severity = 'off', fixable = true }, 8 { rule = '*-dangle', severity = 'off', fixable = true }, 9 { rule = '*-newline', severity = 'off', fixable = true }, 10 { rule = '*quotes', severity = 'off', fixable = true }, 11 { rule = '*semi', severity = 'off', fixable = true }, 12} 13 14local lspconfig = require('lspconfig') 15-- Enable eslint for all supported languages 16lspconfig.eslint.setup( 17 { 18 filetypes = { 19 "javascript", 20 "javascriptreact", 21 "javascript.jsx", 22 "typescript", 23 "typescriptreact", 24 "typescript.tsx", 25 "vue", 26 "html", 27 "markdown", 28 "json", 29 "jsonc", 30 "yaml", 31 "toml", 32 "xml", 33 "gql", 34 "graphql", 35 "astro", 36 "svelte", 37 "css", 38 "less", 39 "scss", 40 "pcss", 41 "postcss" 42 }, 43 settings = { 44 -- Silent the stylistic rules in you IDE, but still auto fix them 45 rulesCustomizations = customizations, 46 }, 47 } 48)
There's few ways you can achieve format on save in neovim:
nvim-lspconfig
has a EslintFixAll
command predefined, you can create a autocmd to call this command after saving file.1lspconfig.eslint.setup({ 2 --- ... 3 on_attach = function(client, bufnr) 4 vim.api.nvim_create_autocmd("BufWritePre", { 5 buffer = bufnr, 6 command = "EslintFixAll", 7 }) 8 end, 9})
Since v7.0, we migrated to ESLint Flat config. It provides much better organization and composition.
Normally you only need to import the radum
preset:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum();
And that's it! Or you can configure each integration individually, for example:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5// Type of the project. 'lib' for libraries, the default is 'app' 6 type: 'lib', 7 8 // Enable stylistic formatting rules 9 // stylistic: true, 10 11 // Or customize the stylistic rules 12 stylistic: { 13 indent: 2, // 4, or 'tab' 14 quotes: 'single', // or 'double' 15 }, 16 17 // TypeScript and Vue are autodetected, you can also explicitly enable them: 18 typescript: true, 19 vue: true, 20 21 // Disable jsonc and yaml support 22 jsonc: false, 23 yaml: false, 24 25 // `.eslintignore` is no longer supported in Flat config, use `ignores` instead 26 ignores: [ 27 '**/fixtures', 28 // ...globs 29 ] 30});
The radum
factory function also accepts any number of arbitrary custom config overrides:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum( 5 { 6 // Configures for radum's config 7 }, 8 9 // From the second arguments they are ESLint Flat Configs 10 // you can have multiple configs 11 { 12 files: ['**/*.ts'], 13 rules: {}, 14 }, 15 { 16 rules: {}, 17 }, 18);
Going more advanced, you can also import fine-grained configs and compose them as you wish:
We wouldn't recommend using this style in general unless you know exactly what they are doing, as there are shared options between configs and might need extra care to make them consistent.
1// eslint.config.js 2import { 3 combine, 4 comments, 5 ignores, 6 imports, 7 javascript, 8 jsdoc, 9 jsonc, 10 markdown, 11 node, 12 sortPackageJson, 13 sortTsconfig, 14 stylistic, 15 toml, 16 typescript, 17 unicorn, 18 vue, 19 yaml, 20} from '@radum/eslint-config'; 21 22export default combine( 23 ignores(), 24 javascript(/* Options */), 25 comments(), 26 node(), 27 jsdoc(), 28 imports(), 29 unicorn(), 30 typescript(/* Options */), 31 stylistic(), 32 vue(), 33 jsonc(), 34 yaml(), 35 toml(), 36 markdown(), 37);
Check out the configs and factory for more details.
Thanks to sxzz/eslint-config for the inspiration and reference.
Since flat config requires us to explicitly provide the plugin names (instead of the mandatory convention from npm package name), we renamed some plugins to make the overall scope more consistent and easier to write.
New Prefix | Original Prefix | Source Plugin |
---|---|---|
import/* | import-x/* | eslint-plugin-import-x |
node/* | n/* | eslint-plugin-n |
yaml/* | yml/* | eslint-plugin-yml |
ts/* | @typescript-eslint/* | @typescript-eslint/eslint-plugin |
style/* | @stylistic/* | @stylistic/eslint-plugin |
test/* | vitest/* | @vitest/eslint-plugin |
test/* | no-only-tests/* | eslint-plugin-no-only-tests |
When you want to override rules, or disable them inline, you need to update to the new prefix:
1-// eslint-disable-next-line @typescript-eslint/consistent-type-definitions 2+// eslint-disable-next-line ts/consistent-type-definitions 3type foo = { bar: 2 }
[!NOTE] About plugin renaming - it is actually rather a dangerous move that might leading to potential naming collisions, pointed out here and here. As this config also very personal and opinionated, I ambitiously position this config as the only "top-level" config per project, that might pivots the taste of how rules are named.
This config cares more about the user-facings DX, and try to ease out the implementation details. For example, users could keep using the semantic
import/order
without ever knowing the underlying plugin has migrated twice toeslint-plugin-i
and then toeslint-plugin-import-x
. User are also not forced to migrate to the impliciti/order
halfway only because we swapped the implementation to a fork.That said, it's probably still not a good idea. You might not want to doing this if you are maintaining your own eslint config.
Feel free to open issues if you want to combine this config with some other config presets but faced naming collisions. I am happy to figure out a way to make them work. But at this moment I have no plan to revert the renaming.
This preset will automatically rename the plugins also for your custom configs. You can use the original prefix to override the rules directly.
If you really want to use the original prefix, you can revert the plugin renaming by:
1import radum from '@radum/eslint-config'; 2 3export default radum() 4 .renamePlugins({ 5 ts: '@typescript-eslint', 6 yaml: 'yml', 7 node: 'n' 8 // ... 9 });
Certain rules would only be enabled in specific files, for example, ts/*
rules would only be enabled in .ts
files and vue/*
rules would only be enabled in .vue
files. If you want to override the rules, you need to specify the file extension:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum( 5 { 6 vue: true, 7 typescript: true 8 }, 9 { 10 // Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files 11 files: ['**/*.vue'], 12 rules: { 13 'vue/operator-linebreak': ['error', 'before'], 14 }, 15 }, 16 { 17 // Without `files`, they are general rules for all files 18 rules: { 19 'style/semi': ['error', 'never'], 20 }, 21 } 22);
We also provided the overrides
options in each integration to make it easier:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 vue: { 6 overrides: { 7 'vue/operator-linebreak': ['error', 'before'], 8 }, 9 }, 10 typescript: { 11 overrides: { 12 'ts/consistent-type-definitions': ['error', 'interface'], 13 }, 14 }, 15 yaml: { 16 overrides: { 17 // ... 18 }, 19 }, 20});
The factory function radum()
returns a FlatConfigComposer
object from eslint-flat-config-utils
where you can chain the methods to compose the config even more flexibly.
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum() 5 .prepend( 6 // some configs before the main config 7 ) 8 // overrides any named configs 9 .override( 10 'radum/imports', 11 { 12 rules: { 13 'import/order': ['error', { 'newlines-between': 'always' }], 14 } 15 } 16 ) 17 // rename plugin prefixes 18 .renamePlugins({ 19 'old-prefix': 'new-prefix', 20 // ... 21 }); 22// ...
Vue support is detected automatically by checking if vue
is installed in your project. You can also explicitly enable/disable it:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 vue: true 6});
We have limited support for Vue 2 (as it's already reached EOL). If you are still using Vue 2, you can configure it manually by setting vueVersion
to 2
:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 vue: { 6 vueVersion: 2 7 }, 8});
As it's in maintenance mode, we only accept bug fixes for Vue 2. It might also be removed in the future when eslint-plugin-vue
drops support for Vue 2. We recommend upgrading to Vue 3 if possible.
To enable Vue accessibility support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 vue: { 6 a11y: true 7 } 8});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D eslint-plugin-vuejs-accessibility
We provide some optional configs for specific use cases, that we don't include their dependencies by default.
Use external formatters to format files that ESLint cannot handle yet (.css
, .html
, etc). Powered by eslint-plugin-format
.
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 formatters: { 6 // Format CSS, LESS, SCSS files, also the `<style>` blocks in Vue 7 // By default uses Prettier 8 css: true, 9 // Format HTML files 10 // By default uses Prettier 11 html: true, 12 // Format Markdown files 13 // Supports Prettier and dprint 14 // By default uses Prettier 15 markdown: 'prettier' 16 } 17});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D eslint-plugin-format
To enable React support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 react: true, 6});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
To enable svelte support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 svelte: true, 6});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D eslint-plugin-svelte
To enable astro support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 astro: true, 6});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D eslint-plugin-astro
To enable Solid support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 solid: true, 6});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D eslint-plugin-solid
To enable UnoCSS support, you need to explicitly turn it on:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 unocss: true, 6});
Running npx eslint
should prompt you to install the required dependencies, otherwise, you can install them manually:
1npm i -D @unocss/eslint-plugin
This config also provides some optional plugins/rules for extended usage.
command
Powered by eslint-plugin-command
. It is not a typical rule for linting, but an on-demand micro-codemod tool that triggers by specific comments.
For a few triggers, for example:
/// to-function
- converts an arrow function to a normal function/// to-arrow
- converts a normal function to an arrow function/// to-for-each
- converts a for-in/for-of loop to .forEach()
/// to-for-of
- converts a .forEach()
to a for-of loop/// keep-sorted
- sorts an object/array/interfaceYou can add the trigger comment one line above the code you want to transform, for example (note the triple slash):
1/// to-function 2const foo = async (msg: string): void => { 3 console.log(msg) 4}
Will be transformed to this when you hit save with your editor or run eslint --fix
:
1async function foo(msg: string): void { 2 console.log(msg); 3}
The command comments are usually one-off and will be removed along with the transformation.
You can optionally enable the type aware rules by passing the options object to the typescript
config:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 typescript: { 6 tsconfigPath: 'tsconfig.json', 7 }, 8});
Auto-fixing for the following rules are disabled when ESLint is running in a code editor:
They are non-fixable using this helper.
This is to prevent unused imports from getting removed by the editor during refactoring to get a better developer experience. Those rules will be applied when you run ESLint in the terminal or Lint Staged. If you don't want this behavior, you can disable them:
1// eslint.config.js 2import radum from '@radum/eslint-config'; 3 4export default radum({ 5 isInEditor: false 6});
If you want to apply lint and auto-fix before every commit, you can add the following to your package.json
:
1{ 2 "simple-git-hooks": { 3 "pre-commit": "pnpm lint-staged" 4 }, 5 "lint-staged": { 6 "*": "eslint --fix" 7 } 8}
and then
1npm i -D lint-staged simple-git-hooks 2 3// to active the hooks 4npx simple-git-hooks
I built a visual tool to help you view what rules are enabled in your project and apply them to what files, @eslint/config-inspector
Go to your project root that contains eslint.config.js
and run:
1npx @eslint/config-inspector
This project follows Semantic Versioning for releases. However, since this is just a config and involves opinions and many moving parts, we don't treat rules changes as breaking changes.
I pretty much agree with everything Antfu says here: Why I don't use Prettier.
Well, you can still use Prettier to format files that are not supported well by ESLint yet, such as .css
, .html
, etc. See formatters for more details.
dprint is also a great formatter that with more abilities to customize. However, it's in the same model as Prettier which reads the AST and reprints the code from scratch. This means it's similar to Prettier, which ignores the original line breaks and might also cause the inconsistent diff. So in general, we prefer to use ESLint to format and lint JavaScript/TypeScript code.
Meanwhile, we do have dprint integrations for formatting other files such as .md
. See formatters for more details.
You can opt-in to the formatters
feature to format your CSS. Note that it's only doing formatting, but not linting. If you want proper linting support, give stylelint
a try.
I am a very opinionated person, so as this config. I prefer the top-level functions always using the function declaration over arrow functions; I prefer one-line if statements without braces and always wraps, and so on. I even wrote some custom rules to enforce them.
I know they are not necessarily the popular opinions. If you really want to get rid of them, you can disable them with:
1import radum from '@radum/eslint-config'; 2 3export default radum({ 4 lessOpinionated: true 5});
Sure, you can configure and override rules locally in your project to fit your needs. If that still does not work for you, you can always fork this repo and maintain your own.
You can run the following command to check what are the latest dependencies:
1# For all dependencies and devDependencies 2npx npm-check-updates --format group -i 3# For only peer dependencies 4npx npm-check-updates --dep peer --format group -i
This config is heavily inspired by the following configs and tools:
MIT License © 2019-PRESENT Radu Micu
Thanks goes to these wonderful people (emoji key):
Radu Micu 📖 💻 🚇 ⚠️ |
This project follows the all-contributors specification. Contributions of any kind welcome!
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/21 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More