This leaves the grouping up to you to do manually. Instead a comment on its own line starts a group. Unlike imports, there’s no automatic grouping of exports. Other types of exports are not reordered. Sequences of re-exports (exports with from) are sorted. See Custom grouping for more information. Note: The above groups are very loosely defined. import a from "/a": Absolute imports and other imports such as Vue-style import a from "./a": Relative imports.import react from "react": Packages (npm packages and Node.js builtins without node:).import * as fs from "node:fs": Node.js builtin modules prefixed with node.import "./setup": Side effect imports.Then, each chunk is grouped into sections with a blank line between each. Use import/first if you want to make sure that all imports end up in the same chunk. A “chunk” is a sequence of import statements with only comments and whitespace between. Grouping importsįirst, the plugin finds all chunks of imports. TL DR: First group, then sort alphabetically. This section is for learning how the sorting works, not for how to manually fix errors. This plugin is supposed to be used with autofix, ideally directly in your editor via an ESLint extension, or with eslint -fix otherwise. If you like it too – I’m very glad to hear! But everyone won’t like it. I use it in many little projects and I like it. Eventually it would have no reason to exist – effort would be better spent contributing to import/order. If we start adding more options to this plugin, it won’t be eslint-plugin- simple-import-sort anymore. Then why does this plugin exist? See How is this rule different from import/order?. It has plenty of options, and the maintainers seem interested in expanding the feature where it makes sense. If you want more options, I recommend using the import/order rule (from eslint-plugin-import) instead.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |