Skip to content

Commit

Permalink
Add importOrderCaseSensitive to ExtendedOptions so it passes through
Browse files Browse the repository at this point in the history
  • Loading branch information
acnebs committed Sep 28, 2024
1 parent d7cc4cf commit f070d8a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface PrettierOptions
/** Subset of options that need to be normalized, or affect normalization */
export type NormalizableOptions = Pick<
PrettierOptions,
'importOrder' | 'importOrderParserPlugins' | 'importOrderTypeScriptVersion'
'importOrder' | 'importOrderParserPlugins' | 'importOrderTypeScriptVersion' | 'importOrderCaseSensitive'
> &
// filepath can be undefined when running prettier via the api on text input
Pick<Partial<PrettierOptions>, 'filepath'>;
Expand Down Expand Up @@ -63,6 +63,7 @@ export type ImportRelated = ImportOrLine | SomeSpecifier;
export interface ExtendedOptions {
importOrder: PrettierOptions['importOrder'];
importOrderCombineTypeAndValueImports: boolean;
importOrderCaseSensitive: boolean;
hasAnyCustomGroupSeparatorsInImportOrder: boolean;
provideGapAfterTopOfFileComments: boolean;
plugins: ParserPlugin[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const defaultOptions = examineAndNormalizePluginOptions({
// First separator for top-of-file comments, second to separate side-effect and ignored chunks, for easier test readability
importOrder: testingOnly.normalizeImportOrderOption(['', '']),
importOrderTypeScriptVersion: '5.0.0',
importOrderCaseSensitive: false,
importOrderParserPlugins: [],
filepath: __filename,
});
Expand Down
13 changes: 13 additions & 0 deletions src/utils/__tests__/normalize-plugin-options.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('examineAndNormalizePluginOptions', () => {
examineAndNormalizePluginOptions({
importOrder: DEFAULT_IMPORT_ORDER,
importOrderParserPlugins: [],
importOrderCaseSensitive: false,
importOrderTypeScriptVersion: '1.0.0',
filepath: __filename,
} as NormalizableOptions),
Expand All @@ -107,6 +108,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[.]',
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: [],
provideGapAfterTopOfFileComments: false,
});
Expand All @@ -121,6 +123,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[./]',
],
importOrderParserPlugins: [],
importOrderCaseSensitive: false,
importOrderTypeScriptVersion: '1.0.0',
filepath: __filename,
} as NormalizableOptions),
Expand All @@ -133,6 +136,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[./]',
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: [],
provideGapAfterTopOfFileComments: false,
});
Expand All @@ -142,6 +146,7 @@ describe('examineAndNormalizePluginOptions', () => {
examineAndNormalizePluginOptions({
importOrder: [''],
importOrderParserPlugins: [],
importOrderCaseSensitive: false,
importOrderTypeScriptVersion: '1.0.0',
filepath: __filename,
} as NormalizableOptions),
Expand All @@ -153,6 +158,7 @@ describe('examineAndNormalizePluginOptions', () => {
THIRD_PARTY_MODULES_SPECIAL_WORD,
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: [],
provideGapAfterTopOfFileComments: true,
});
Expand All @@ -173,6 +179,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[.]',
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: ['typescript'],
provideGapAfterTopOfFileComments: false,
});
Expand All @@ -184,6 +191,7 @@ describe('examineAndNormalizePluginOptions', () => {
importOrder: DEFAULT_IMPORT_ORDER,
importOrderParserPlugins: ['typescript', 'jsx'],
importOrderTypeScriptVersion: '5.0.0',
importOrderCaseSensitive: false,
filepath: __filename,
} as NormalizableOptions),
).toEqual({
Expand All @@ -194,6 +202,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[.]',
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: ['typescript'],
provideGapAfterTopOfFileComments: false,
});
Expand All @@ -203,6 +212,7 @@ describe('examineAndNormalizePluginOptions', () => {
examineAndNormalizePluginOptions({
importOrder: DEFAULT_IMPORT_ORDER,
importOrderParserPlugins: [],
importOrderCaseSensitive: false,
importOrderTypeScriptVersion: '1.0.0',
filepath: undefined,
} as NormalizableOptions),
Expand All @@ -214,6 +224,7 @@ describe('examineAndNormalizePluginOptions', () => {
'^[.]',
],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: [],
provideGapAfterTopOfFileComments: false,
});
Expand All @@ -224,13 +235,15 @@ describe('examineAndNormalizePluginOptions', () => {
examineAndNormalizePluginOptions({
importOrder: [],
importOrderParserPlugins: [],
importOrderCaseSensitive: false,
importOrderTypeScriptVersion: '1.0.0',
filepath: __filename,
} as NormalizableOptions),
).toEqual({
hasAnyCustomGroupSeparatorsInImportOrder: false,
importOrder: [],
importOrderCombineTypeAndValueImports: true,
importOrderCaseSensitive: false,
plugins: [],
provideGapAfterTopOfFileComments: false,
});
Expand Down
1 change: 1 addition & 0 deletions src/utils/normalize-plugin-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export function examineAndNormalizePluginOptions(
return {
importOrder,
importOrderCombineTypeAndValueImports,
importOrderCaseSensitive: !!options.importOrderCaseSensitive,
hasAnyCustomGroupSeparatorsInImportOrder: importOrder.some(
isCustomGroupSeparator,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {cat, Dog} from "C";
import B from "B";
import A from "A";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import a from "a";
import A from "A";
import b from "b";
import B from "B";
import { Dog, cat } from "C";
import a from "a";
import b from "b";
import c from "c";
import { cat, Dog } from "C";
`;

0 comments on commit f070d8a

Please sign in to comment.