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

cannot format associated files #637

Open
unicornware opened this issue May 24, 2024 · 0 comments
Open

cannot format associated files #637

unicornware opened this issue May 24, 2024 · 0 comments

Comments

@unicornware
Copy link

unicornware commented May 24, 2024

Describe the bug

dprint-plugin-typescript version: 0.90.5

Associated files cannot be formatted if the file extension is not a standard JavaScript or TypeScript extension.

Instead of the file being formatted, an error occurs:

Error formatting text. Error: Expected ',', got 'EmptyArray' at file:///__fixtures__/visit.ts.txt:10:8

Changing the extension to .ts makes the error go away, but this is not ideal when working with file fixtures. I want my fixtures formatted, but not linted or typechecked.

Input Code

import {
  define,
  isArray,
  isBoolean,
  isFalsy,
  isFunction,
  isNIL,
  isNumber,
  sift,
  type EmptyArray,
  type Fn,
  type Nullable,
  type Optional
} from '@flex-development/tutils'

Expected Output

See input code.

Actual Output

See input code.

.dprint.jsonc

{
  "$schema": "https://dprint.dev/schemas/v0.json",
  "excludes": [
    "!**/__fixtures__/**/dist/",
    "!**/__fixtures__/**/node_modules/",
    "!**/typings/**/dist/",
    "**/*.patch",
    "**/*.snap",
    "**/*config.*.timestamp*",
    "**/.temp/",
    "**/.vercel/",
    "**/__fixtures__/git/**/*.txt",
    "**/__tests__/benchmark.json",
    "**/__tests__/report.json",
    "**/__tests__/typecheck.json",
    "**/coverage/",
    "**/dist/",
    "**/node_modules",
    "**/tsconfig*temp.json",
    ".git/",
    ".husky/_/",
    ".yarn/",
    "CHANGELOG.md",
    "LICENSE.md",
    "RELEASE_NOTES.md",
    "yarn.lock"
  ],
  "exec": {
    "commands": [
      {
        "command": "node ./dprint/prettier.mjs {{file_path}}",
        "exts": ["css", "html", "json5", "scss", "yaml", "yml"],
        "stdin": true
      },
      {
        "command": "node ./dprint/shfmt.mjs {{file_path}}",
        "exts": ["sh", "txt", "zsh"],
        "fileNames": [
          ".editorconfig",
          ".env",
          ".env.local",
          ".env.repo",
          ".eslintcache",
          ".eslintignore",
          ".gitattributes",
          ".gitconfig",
          ".gitignore",
          ".markdownlintignore",
          ".npmrc",
          ".nvmrc",
          "Brewfile",
          "commit-msg",
          "pre-commit",
          "pre-push"
        ],
        "stdin": true
      }
    ]
  },
  "incremental": true,
  "indentWidth": 2,
  "json": {
    "associations": ["**/*.{jsonc,json}"],
    "array.preferSingleLine": false,
    "commentLine.forceSpaceAfterSlashes": true,
    "ignoreNodeCommentText": "dprint-ignore",
    "object.preferSingleLine": false,
    "trailingCommas": "never"
  },
  "lineWidth": 80,
  "markdown": {
    "associations": ["**/*.{md,mdx}"],
    "emphasisKind": "asterisks",
    "ignoreDirective": "dprint-ignore",
    "ignoreEndDirective": "dprint-ignore-end",
    "ignoreFileDirective": "dprint-ignore-file",
    "ignoreStartDirective": "dprint-ignore-start",
    "lineWidth": 120,
    "strongKind": "asterisks",
    "textWrap": "maintain"
  },
  "newLineKind": "lf",
  "plugins": [
    "https://plugins.dprint.dev/typescript-0.90.5.wasm",
    "https://plugins.dprint.dev/json-0.19.2.wasm",
    "https://plugins.dprint.dev/markdown-0.17.0.wasm",
    "https://plugins.dprint.dev/exec-0.4.4.json@c207bf9b9a4ee1f0ecb75c594f774924baf62e8e53a2ce9d873816a408cecbf7"
  ],
  "typescript": {
    "arrowFunction.useParentheses": "preferNone",
    "associations": ["**/*.{cjs,cts,js,jsx,mjs,mts,ts,tsx}", "**/*.ts.txt"],
    "binaryExpression.linePerExpression": false,
    "binaryExpression.operatorPosition": "sameLine",
    "binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator": true,
    "bracePosition": "sameLine",
    "commentLine.forceSpaceAfterSlashes": false,
    "constructSignature.spaceAfterNewKeyword": true,
    "constructor.spaceBeforeParentheses": false,
    "constructorType.spaceAfterNewKeyword": true,
    "doWhileStatement.spaceAfterWhileKeyword": true,
    "enumDeclaration.memberSpacing": "maintain",
    "exportDeclaration.forceMultiLine": "never",
    "exportDeclaration.forceSingleLine": false,
    "exportDeclaration.sortNamedExports": "maintain",
    "exportDeclaration.spaceSurroundingNamedExports": true,
    "forInStatement.spaceAfterForKeyword": true,
    "forOfStatement.spaceAfterForKeyword": true,
    "forStatement.spaceAfterForKeyword": true,
    "forStatement.spaceAfterSemiColons": true,
    "functionDeclaration.spaceBeforeParentheses": false,
    "functionExpression.spaceAfterFunctionKeyword": false,
    "functionExpression.spaceBeforeParentheses": false,
    "getAccessor.spaceBeforeParentheses": false,
    "ifStatement.spaceAfterIfKeyword": true,
    "ignoreFileCommentText": "dprint-ignore-file",
    "ignoreNodeCommentText": "dprint-ignore",
    "importDeclaration.forceMultiLine": "never",
    "importDeclaration.forceSingleLine": false,
    "importDeclaration.sortNamedImports": "maintain",
    "importDeclaration.spaceSurroundingNamedImports": true,
    "jsx.bracketPosition": "nextLine",
    "jsx.forceNewLinesSurroundingContent": false,
    "jsx.multiLineParens": "prefer",
    "jsx.quoteStyle": "preferSingle",
    "jsxExpressionContainer.spaceSurroundingExpression": false,
    "jsxSelfClosingElement.spaceBeforeSlash": true,
    "memberExpression.linePerExpression": false,
    "method.spaceBeforeParentheses": false,
    "module.sortExportDeclarations": "caseSensitive",
    "module.sortImportDeclarations": "caseSensitive",
    "newLineKind": "lf",
    "nextControlFlowPosition": "sameLine",
    "objectExpression.spaceSurroundingProperties": true,
    "objectPattern.spaceSurroundingProperties": true,
    "operatorPosition": "nextLine",
    "preferHanging": true,
    "preferSingleLine": false,
    "quoteProps": "asNeeded",
    "quoteStyle": "alwaysSingle",
    "semiColons": "asi",
    "setAccessor.spaceBeforeParentheses": false,
    "singleBodyPosition": "sameLine",
    "spaceAround": false,
    "spaceSurroundingProperties": true,
    "taggedTemplate.spaceBeforeLiteral": false,
    "trailingCommas": "never",
    "typeAnnotation.spaceBeforeColon": false,
    "typeAssertion.spaceBeforeExpression": false,
    "typeLiteral.separatorKind.singleLine": "semiColon",
    "typeLiteral.spaceSurroundingProperties": true,
    "useBraces": "maintain",
    "whileStatement.spaceAfterWhileKeyword": true
  },
  "useTabs": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant