This is a plugin we use at CodeBox for some analysis rules and fixers that are missing in other plugins, namely
codebox/sort-imports (fixable) - allows to sort imports in a variety of ways:
import { foo } from 'bar')import React from 'react')imports * as foo from 'bar')import './foo')Moreover, this rule is fixable, which means, that ESLint will reorder your imports when you run eslint --fix automagically. Use this rule with caution, as it may break your code if it depends on the order of imports (tip: it should not)
codebox/sort-named-imports (fixable) - allows to sort components inside named imports alphabetically, i.e.
Incorrect code for this rule:
import { b, a } from 'foo'
Correct code:
import { a, b } from 'foo'
This plugin is still in a very early stage of development. More features will be added in the upcoming time, if you still wish to use it:
npm install --saveDev eslint-plugin-codebox
Add to plugins sections of your .eslintrc:
"plugins": [
"codebox"
]
Configure the rules you want:
module.exports = {
"rules": {
"codebox/sort-imports": ["error", {
"groups": [
"builtin", // builtin dependencies go first
"external", // then external dependencies
"parent", // then parent
"sibling", // ...ok, you got it
"index",
["unknown", "absolute"] // An array inside array of groups means that these two groups share same priority for sorting
],
"importTypes": [
"default", // Default imports are at top of each group
"named", // After that - named imports
"all", // Imports of the whole namespace
"none" // Plain import
],
"ignoreCase": true // Indicates whether we want to ignore case during alphabetical sorting
}],
"codebox/sort-named-imports": ["error", {
"ignoreCase": true // Indicates whether we want to ignore case during alphabetical sorting
}]
}
}
10 commits
JavaScript
100.0%
This is a plugin we use at CodeBox for some analysis rules and fixers that are missing in other plugins, namely
codebox/sort-imports (fixable) - allows to sort imports in a variety of ways:
import { foo } from 'bar')import React from 'react')imports * as foo from 'bar')import './foo')Moreover, this rule is fixable, which means, that ESLint will reorder your imports when you run eslint --fix automagically. Use this rule with caution, as it may break your code if it depends on the order of imports (tip: it should not)
codebox/sort-named-imports (fixable) - allows to sort components inside named imports alphabetically, i.e.
Incorrect code for this rule:
import { b, a } from 'foo'
Correct code:
import { a, b } from 'foo'
This plugin is still in a very early stage of development. More features will be added in the upcoming time, if you still wish to use it:
npm install --saveDev eslint-plugin-codebox
Add to plugins sections of your .eslintrc:
"plugins": [
"codebox"
]
Configure the rules you want:
module.exports = {
"rules": {
"codebox/sort-imports": ["error", {
"groups": [
"builtin", // builtin dependencies go first
"external", // then external dependencies
"parent", // then parent
"sibling", // ...ok, you got it
"index",
["unknown", "absolute"] // An array inside array of groups means that these two groups share same priority for sorting
],
"importTypes": [
"default", // Default imports are at top of each group
"named", // After that - named imports
"all", // Imports of the whole namespace
"none" // Plain import
],
"ignoreCase": true // Indicates whether we want to ignore case during alphabetical sorting
}],
"codebox/sort-named-imports": ["error", {
"ignoreCase": true // Indicates whether we want to ignore case during alphabetical sorting
}]
}
}
10 commits
JavaScript
100.0%