diff --git a/src/options/attribute-sorting/index.ts b/src/options/attribute-sorting/index.ts index 1f808d4d..4ecf6ec5 100644 --- a/src/options/attribute-sorting/index.ts +++ b/src/options/attribute-sorting/index.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier'; -import { CATEGORY_PUG } from '..'; +import { CATEGORY_PUG } from '../constants'; const pugSortAttributesOption: PathArraySupportOption = { since: '1.7.0', diff --git a/src/options/common.ts b/src/options/common.ts index ba4ed00f..fa4bb18b 100644 --- a/src/options/common.ts +++ b/src/options/common.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption, IntSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug print width option. */ export const PUG_PRINT_WIDTH_OPTION: IntSupportOption = { diff --git a/src/options/constants.ts b/src/options/constants.ts new file mode 100644 index 00000000..0046f7c0 --- /dev/null +++ b/src/options/constants.ts @@ -0,0 +1,4 @@ +/** + * Category for Prettier's CLI. + */ +export const CATEGORY_PUG: string = 'Pug'; diff --git a/src/options/converge.ts b/src/options/converge.ts index 6af01a58..83598b81 100644 --- a/src/options/converge.ts +++ b/src/options/converge.ts @@ -1,6 +1,6 @@ import type { ParserOptions } from 'prettier'; -import type { PugParserOptions } from '.'; import type { PugPrinterOptions } from '../printer'; +import type { PugParserOptions } from './types'; /** * Convert and merge options from Prettier and `pug`-specific options into one option object with normalized default values. diff --git a/src/options/empty-attributes/index.ts b/src/options/empty-attributes/index.ts index c547f3f1..4f7f1eb1 100644 --- a/src/options/empty-attributes/index.ts +++ b/src/options/empty-attributes/index.ts @@ -1,5 +1,7 @@ import type { ChoiceSupportOption, PathArraySupportOption } from 'prettier'; -import { CATEGORY_PUG } from '..'; +import { CATEGORY_PUG } from '../constants'; + +import type { PugEmptyAttributes } from './types'; /** Pug empty attributes option. */ export const PUG_EMPTY_ATTRIBUTES_OPTION: ChoiceSupportOption = @@ -39,7 +41,7 @@ export const PUG_EMPTY_ATTRIBUTES_FORCE_QUOTES_OPTION: PathArraySupportOption = 'Define a list of patterns for attributes that will be forced to have empty quotes even with "none" selected.', }; -/** Pug empty attributes. */ -export type PugEmptyAttributes = 'as-is' | 'none' | 'all'; -/** Pug empty attributes force quotes. */ -export type PugEmptyAttributesForceQuotes = string[]; +export type { + PugEmptyAttributes, + PugEmptyAttributesForceQuotes, +} from './types'; diff --git a/src/options/empty-attributes/types.ts b/src/options/empty-attributes/types.ts new file mode 100644 index 00000000..03f20c57 --- /dev/null +++ b/src/options/empty-attributes/types.ts @@ -0,0 +1,4 @@ +/** Pug empty attributes. */ +export type PugEmptyAttributes = 'as-is' | 'none' | 'all'; +/** Pug empty attributes force quotes. */ +export type PugEmptyAttributesForceQuotes = string[]; diff --git a/src/options/empty-attributes/utils.ts b/src/options/empty-attributes/utils.ts index 837a2099..9f8b2792 100644 --- a/src/options/empty-attributes/utils.ts +++ b/src/options/empty-attributes/utils.ts @@ -1,5 +1,8 @@ import type { AttributeToken } from 'pug-lexer'; -import type { PugEmptyAttributes, PugEmptyAttributesForceQuotes } from '.'; +import type { + PugEmptyAttributes, + PugEmptyAttributesForceQuotes, +} from './types'; const EMPTY_VALUES: [boolean, string, string] = [true, '""', "''"]; diff --git a/src/options/index.ts b/src/options/index.ts index 1c979289..ab02707b 100644 --- a/src/options/index.ts +++ b/src/options/index.ts @@ -1,11 +1,9 @@ -import type { ParserOptions, SupportOptions } from 'prettier'; -import type { PugSortAttributes } from './attribute-sorting'; +import type { SupportOptions } from 'prettier'; import { PUG_SORT_ATTRIBUTES_BEGINNING_OPTION, PUG_SORT_ATTRIBUTES_END_OPTION, PUG_SORT_ATTRIBUTES_OPTION, } from './attribute-sorting'; -import type { ArrowParens } from './common'; import { PUG_ARROW_PARENS_OPTION, PUG_BRACKET_SAME_LINE_OPTION, @@ -16,26 +14,16 @@ import { PUG_TAB_WIDTH_OPTION, PUG_USE_TABS_OPTION, } from './common'; -import type { - PugEmptyAttributes, - PugEmptyAttributesForceQuotes, -} from './empty-attributes'; import { PUG_EMPTY_ATTRIBUTES_FORCE_QUOTES_OPTION, PUG_EMPTY_ATTRIBUTES_OPTION, } from './empty-attributes'; -import type { PugAttributeSeparator } from './pug-attribute-separator'; import { PUG_ATTRIBUTE_SEPARATOR_OPTION } from './pug-attribute-separator'; -import type { PugClassLocation } from './pug-class-location'; import { PUG_CLASS_LOCATION } from './pug-class-location'; -import type { PugClassNotation } from './pug-class-notation'; import { PUG_CLASS_NOTATION } from './pug-class-notation'; -import type { PugCommentPreserveSpaces } from './pug-comment-preserve-spaces'; import { PUG_COMMENT_PRESERVE_SPACES_OPTION } from './pug-comment-preserve-spaces'; import { PUG_EXPLICIT_DIV } from './pug-explicit-div'; -import type { PugFramework } from './pug-framework'; import { PUG_FRAMEWORK } from './pug-framework'; -import type { PugIdNotation } from './pug-id-notation'; import { PUG_ID_NOTATION } from './pug-id-notation'; import { PUG_SINGLE_FILE_COMPONENT_INDENTATION } from './pug-single-file-component-indentation'; import { @@ -43,61 +31,6 @@ import { PUG_WRAP_ATTRIBUTES_THRESHOLD, } from './pug-wrap-attributes'; -/** - * Category for Prettier's CLI. - */ -export const CATEGORY_PUG: string = 'Pug'; - -/** - * Extended pug option object. - */ -export interface PugParserOptions - extends Pick< - ParserOptions, - | 'printWidth' - | 'singleQuote' - | 'tabWidth' - | 'useTabs' - | 'bracketSpacing' - | 'arrowParens' - | 'semi' - | 'bracketSameLine' - > { - pugPrintWidth: number; - pugSingleQuote: boolean | null; - pugTabWidth: number; - pugUseTabs: boolean | null; - pugBracketSpacing: boolean | null; - pugArrowParens: ArrowParens | null; - pugSemi: boolean | null; - pugBracketSameLine: boolean | null; - - pugAttributeSeparator: PugAttributeSeparator; - - pugCommentPreserveSpaces: PugCommentPreserveSpaces; - - pugSortAttributes: PugSortAttributes; - pugSortAttributesBeginning: string[]; - pugSortAttributesEnd: string[]; - - pugWrapAttributesThreshold: number; - pugWrapAttributesPattern: string; - - pugClassNotation: PugClassNotation; - pugIdNotation: PugIdNotation; - - pugClassLocation: PugClassLocation; - - pugExplicitDiv: boolean; - - pugEmptyAttributes: PugEmptyAttributes; - pugEmptyAttributesForceQuotes: PugEmptyAttributesForceQuotes; - - pugSingleFileComponentIndentation: boolean; - - pugFramework: PugFramework; -} - /** * All supported options by `@prettier/plugin-pug`. */ @@ -126,3 +59,6 @@ export const options: SupportOptions = { pugSingleFileComponentIndentation: PUG_SINGLE_FILE_COMPONENT_INDENTATION, pugFramework: PUG_FRAMEWORK, }; + +export { CATEGORY_PUG } from './constants'; +export type { PugParserOptions } from './types'; diff --git a/src/options/pug-attribute-separator.ts b/src/options/pug-attribute-separator.ts index f2d93077..a65e284c 100644 --- a/src/options/pug-attribute-separator.ts +++ b/src/options/pug-attribute-separator.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug attribute separator option. */ export const PUG_ATTRIBUTE_SEPARATOR_OPTION: ChoiceSupportOption = diff --git a/src/options/pug-class-location.ts b/src/options/pug-class-location.ts index 68b28c5b..99717bda 100644 --- a/src/options/pug-class-location.ts +++ b/src/options/pug-class-location.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug class location. */ export const PUG_CLASS_LOCATION: ChoiceSupportOption = { diff --git a/src/options/pug-class-notation.ts b/src/options/pug-class-notation.ts index bfa67564..b1922dd4 100644 --- a/src/options/pug-class-notation.ts +++ b/src/options/pug-class-notation.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug class notation. */ export const PUG_CLASS_NOTATION: ChoiceSupportOption = { diff --git a/src/options/pug-comment-preserve-spaces.ts b/src/options/pug-comment-preserve-spaces.ts index a4f92f0c..0cf3c17d 100644 --- a/src/options/pug-comment-preserve-spaces.ts +++ b/src/options/pug-comment-preserve-spaces.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug comment preserve spaces option. */ export const PUG_COMMENT_PRESERVE_SPACES_OPTION: ChoiceSupportOption = diff --git a/src/options/pug-explicit-div.ts b/src/options/pug-explicit-div.ts index a5646229..c308d730 100644 --- a/src/options/pug-explicit-div.ts +++ b/src/options/pug-explicit-div.ts @@ -1,5 +1,5 @@ import type { BooleanSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug default div tag. */ export const PUG_EXPLICIT_DIV: BooleanSupportOption = { diff --git a/src/options/pug-framework.ts b/src/options/pug-framework.ts index 1dcb5c5d..bae083d8 100644 --- a/src/options/pug-framework.ts +++ b/src/options/pug-framework.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug Framework. */ export const PUG_FRAMEWORK: ChoiceSupportOption = { diff --git a/src/options/pug-id-notation.ts b/src/options/pug-id-notation.ts index 6bd9c3ad..f3dca824 100644 --- a/src/options/pug-id-notation.ts +++ b/src/options/pug-id-notation.ts @@ -1,5 +1,5 @@ import type { ChoiceSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug id notation. */ export const PUG_ID_NOTATION: ChoiceSupportOption = { diff --git a/src/options/pug-single-file-component-indentation.ts b/src/options/pug-single-file-component-indentation.ts index ae59af7c..f405fb15 100644 --- a/src/options/pug-single-file-component-indentation.ts +++ b/src/options/pug-single-file-component-indentation.ts @@ -1,5 +1,5 @@ import type { BooleanSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Pug single file component indentation. */ export const PUG_SINGLE_FILE_COMPONENT_INDENTATION: BooleanSupportOption = { diff --git a/src/options/pug-wrap-attributes.ts b/src/options/pug-wrap-attributes.ts index dbb43f95..d976c09c 100644 --- a/src/options/pug-wrap-attributes.ts +++ b/src/options/pug-wrap-attributes.ts @@ -1,5 +1,5 @@ import type { IntSupportOption, PathSupportOption } from 'prettier'; -import { CATEGORY_PUG } from '.'; +import { CATEGORY_PUG } from './constants'; /** Wrap attributes threshold. */ export const PUG_WRAP_ATTRIBUTES_THRESHOLD: IntSupportOption = { diff --git a/src/options/types.ts b/src/options/types.ts new file mode 100644 index 00000000..691a301e --- /dev/null +++ b/src/options/types.ts @@ -0,0 +1,63 @@ +import type { ParserOptions } from 'prettier'; +import type { PugSortAttributes } from './attribute-sorting'; +import type { ArrowParens } from './common'; +import type { + PugEmptyAttributes, + PugEmptyAttributesForceQuotes, +} from './empty-attributes'; +import type { PugAttributeSeparator } from './pug-attribute-separator'; +import type { PugClassLocation } from './pug-class-location'; +import type { PugClassNotation } from './pug-class-notation'; +import type { PugCommentPreserveSpaces } from './pug-comment-preserve-spaces'; +import type { PugFramework } from './pug-framework'; +import type { PugIdNotation } from './pug-id-notation'; + +/** + * Extended pug option object. + */ +export interface PugParserOptions + extends Pick< + ParserOptions, + | 'printWidth' + | 'singleQuote' + | 'tabWidth' + | 'useTabs' + | 'bracketSpacing' + | 'arrowParens' + | 'semi' + | 'bracketSameLine' + > { + pugPrintWidth: number; + pugSingleQuote: boolean | null; + pugTabWidth: number; + pugUseTabs: boolean | null; + pugBracketSpacing: boolean | null; + pugArrowParens: ArrowParens | null; + pugSemi: boolean | null; + pugBracketSameLine: boolean | null; + + pugAttributeSeparator: PugAttributeSeparator; + + pugCommentPreserveSpaces: PugCommentPreserveSpaces; + + pugSortAttributes: PugSortAttributes; + pugSortAttributesBeginning: string[]; + pugSortAttributesEnd: string[]; + + pugWrapAttributesThreshold: number; + pugWrapAttributesPattern: string; + + pugClassNotation: PugClassNotation; + pugIdNotation: PugIdNotation; + + pugClassLocation: PugClassLocation; + + pugExplicitDiv: boolean; + + pugEmptyAttributes: PugEmptyAttributes; + pugEmptyAttributesForceQuotes: PugEmptyAttributesForceQuotes; + + pugSingleFileComponentIndentation: boolean; + + pugFramework: PugFramework; +}