Skip to content

Instantly share code, notes, and snippets.

@jimmyhoran
Last active January 3, 2023 08:27
Show Gist options
  • Save jimmyhoran/fc0c1d8e910ef292d87a83425b57df27 to your computer and use it in GitHub Desktop.
Save jimmyhoran/fc0c1d8e910ef292d87a83425b57df27 to your computer and use it in GitHub Desktop.
ESLint rc config with rules for import sorting and grouping. Requires `npm i -D eslint-plugin-import` to be installed.
{
"extends": ["prettier", "plugin:prettier/recommended"],
"plugins": ["prettier", "import"],
"rules": {
"import/order": [
"error",
{
"groups": ["builtin", "external", "parent", "sibling", "index"],
"pathGroups": [
{
"pattern": "@custom-lib/**",
"group": "external",
"position": "after"
}
],
"pathGroupsExcludedImportTypes": ["builtin"],
"alphabetize": {
"order": "asc"
},
"newlines-between": "always"
}
],
"sort-imports": [
"error",
{
"allowSeparatedGroups": true,
"ignoreDeclarationSort": true
}
],
"no-duplicate-imports": "error",
"no-multiple-empty-lines": [
"error",
{
"max": 1,
"maxEOF": 0,
"maxBOF": 0
}
],
"import/first": "error",
"import/newline-after-import": "error",
"import/no-duplicates": "error",
"import/no-unassigned-import": "error",
"prettier/prettier": [
"error",
{
"singleQuote": false,
"semi": false,
"jsxSingleQuote": true
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment