Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Breaking] Remove importOrderBuiltinModulesToTop (always true) #60

Merged
merged 2 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Since then more critical features & fixes have been added. As a result, this rep
- Do not re-order across side-effect imports
- Combine imports from the same source ([`importOrderMergeDuplicateImports`](#importordermergeduplicateimports))
- Combine type and value imports ([`importOrderCombineTypeAndValueImports`](#importordercombinetypeandvalueimports))
- Sort node.js builtin modules to top ([`importOrderBuiltinModulesToTop`](#importorderbuiltinmodulestotop))
- Sorts node.js builtin modules to top
- Custom import order separation ([`importOrderSeparation`](#importorderseparation))

[We welcome contributions!](./CONTRIBUTING.md)
Expand All @@ -35,7 +35,6 @@ Since then more critical features & fixes have been added. As a result, this rep
- [`importOrderMergeDuplicateImports`](#importordermergeduplicateimports)
- [`importOrderCombineTypeAndValueImports`](#importordercombinetypeandvalueimports)
- [`importOrderParserPlugins`](#importorderparserplugins)
- [`importOrderBuiltinModulesToTop`](#importorderbuiltinmodulestotop)
- [Prevent imports from being sorted](#prevent-imports-from-being-sorted)
- [FAQ / Troubleshooting](#faq--troubleshooting)
- [Compatibility](#compatibility)
Expand Down Expand Up @@ -131,7 +130,6 @@ module.exports = {
singleQuote: true,
semi: true,
importOrder: ['^@core/(.*)$', '^@server/(.*)$', '^@ui/(.*)$', '^[./]'],
importOrderBuiltinModulesToTop: true,
importOrderCaseInsensitive: true,
importOrderParserPlugins: ['typescript', 'jsx', 'decorators-legacy'],
importOrderMergeDuplicateImports: true,
Expand Down Expand Up @@ -352,14 +350,6 @@ with options as a JSON string of the plugin array:
"importOrderParserPlugins": []
```

#### `importOrderBuiltinModulesToTop`

**type**: `boolean`

**default value:** `false`

A boolean value to enable sorting of [`node builtins`](https://nodejs.org/api/module.html#modulebuiltinmodules) to the top of all import groups.

### Prevent imports from being sorted

This plugin supports standard prettier ignore comments. By default, side-effect imports (like
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { builtinModules } from 'module';

import { ParserPlugin } from '@babel/parser';
import { expressionStatement, stringLiteral } from '@babel/types';
import { builtinModules } from 'module';

export const flow: ParserPlugin = 'flow';
export const typescript: ParserPlugin = 'typescript';
Expand Down
6 changes: 0 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ export const options: Record<
default: false,
description: 'Should specifiers be sorted?',
},
importOrderBuiltinModulesToTop: {
type: 'boolean',
category: 'Global',
default: false,
description: 'Should node-builtins be hoisted to the top?',
},
importOrderMergeDuplicateImports: {
type: 'boolean',
category: 'Global',
Expand Down
2 changes: 0 additions & 2 deletions src/preprocessors/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function preprocessor(code: string, options: PrettierOptions): string {
const {
importOrderParserPlugins,
importOrder,
importOrderBuiltinModulesToTop,
importOrderCaseInsensitive,
importOrderGroupNamespaceSpecifiers,
importOrderMergeDuplicateImports,
Expand Down Expand Up @@ -70,7 +69,6 @@ export function preprocessor(code: string, options: PrettierOptions): string {

const nodesToOutput = getSortedNodes(allOriginalImportNodes, {
importOrder,
importOrderBuiltinModulesToTop,
importOrderCaseInsensitive,
importOrderGroupNamespaceSpecifiers,
importOrderMergeDuplicateImports,
Expand Down
1 change: 0 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export type GetSortedNodes = (
options: Pick<
PrettierOptions,
| 'importOrder'
| 'importOrderBuiltinModulesToTop'
| 'importOrderCaseInsensitive'
| 'importOrderGroupNamespaceSpecifiers'
| 'importOrderMergeDuplicateImports'
Expand Down
1 change: 0 additions & 1 deletion src/utils/__tests__/get-all-comments-from-nodes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const getSortedImportNodes = (code: string, options?: ParserOptions) => {

return getSortedNodes(importNodes, {
importOrder: [],
importOrderBuiltinModulesToTop: false,
importOrderCaseInsensitive: false,
importOrderGroupNamespaceSpecifiers: false,
importOrderMergeDuplicateImports: false,
Expand Down
2 changes: 0 additions & 2 deletions src/utils/__tests__/get-code-from-ast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import a from 'a';
const importNodes = getImportNodes(code);
const sortedNodes = getSortedNodes(importNodes, {
importOrder: [],
importOrderBuiltinModulesToTop: false,
importOrderCaseInsensitive: false,
importOrderGroupNamespaceSpecifiers: false,
importOrderMergeDuplicateImports: false,
Expand Down Expand Up @@ -60,7 +59,6 @@ import type {See} from 'c';
const importNodes = getImportNodes(code, { plugins: ['typescript'] });
const sortedNodes = getSortedNodes(importNodes, {
importOrder: [],
importOrderBuiltinModulesToTop: false,
importOrderCaseInsensitive: false,
importOrderGroupNamespaceSpecifiers: false,
importOrderMergeDuplicateImports: true,
Expand Down
Loading