IanVS / prettier-plugin-sort-imports

An opinionated but flexible prettier plugin to sort import statements
Apache License 2.0
1.02k stars 25 forks source link

importOrderCombineTypeAndValueImports: true throws error for specific type syntax for flow projects #56

Closed andidev closed 1 year ago

andidev commented 1 year ago

Your Environment

Describe the bug This only seem to happens for flow projects. Sorting imports with type prefix with option importOrderCombineTypeAndValueImports: true throws error. Not sure maybe I am missing something setting here but I think I confugured prettier babel plugin correctly to prase flow files.

image

is causing following error:

image

Expected behavior No error is expected since its valid flow syntax

Configuration File (cat .prettierrc, prettier.config.js, .prettier.js)

/**
 * @prettier
 */
module.exports = {
    arrowParens: 'avoid',
    printWidth: 200,
    tabWidth: 4,
    semi: true,
    singleQuote: true,
    jsxSingleQuote: true,
    trailingComma: 'es5',
    requirePragma: true,
    bracketSpacing: true,
    parser: 'flow',
    quoteProps: 'as-needed',
    overrides: [
        {
            files: 'src/constants/*.js',
            options: {
                quoteProps: 'consistent',
            },
        },
        {
            files: 'src/i18n/*.js',
            options: {
                printWidth: 10000,
                quoteProps: 'consistent',
            },
        },
    ],
    importOrder: ['<THIRD_PARTY_MODULES>', '^rootpath$', '^(scripts/.*)$', '(^src/.*)$', '^(test/.*)$'],
    importOrderSeparation: false,
    importOrderSortSpecifiers: true,
    importOrderBuiltinModulesToTop: true,
    importOrderMergeDuplicateImports: true,
    importOrderCombineTypeAndValueImports: true,
    importOrderParserPlugins: ['flow', 'jsx'],
};

Contribute to @ianvs/prettier-plugin-sort-imports

IanVS commented 1 year ago

Thanks, I can reproduce this as well, it seems that the flow AST differs from TypeScript here, and we didn't test it sufficiently.

andidev commented 1 year ago

thanks for speed of the fix and the awesome work!