dprint / dprint-plugin-exec

Formatting plugin for dprint that formats code via other formatting CLI tools.
MIT License
21 stars 1 forks source link

error creating plugin dprint-plugin-exec #16

Closed tomdavidson closed 2 years ago

tomdavidson commented 2 years ago

I must not understand the exec configuration correctly, because I get this error when I have a file that matches the exec associations globs.

error

$ dprint fmt package.json
Error creating plugin dprint-plugin-exec. Message: data did not match any variant of untagged enum ConfigKeyValue at line 1 column 183
Had 1 error(s) formatting.

dprint.json

{
    "$schema": "https://dprint.dev/schemas/v0.json",
    "lineWidth": 120,
    "indentWidth": 2,
    "includes": [
        "**/*.{ts,tsx,js,jsx,cjs,mjs}",
        "**/*.{json,md,toml}",
        "**/*.dockerfile",
        "**/Dockerfile",
        "**/package.json",
        "**/*.{bash,sh}"
    ],
    "excludes": [
        "**/node_modules",
        "**/*-lock.{json,yaml}",
        "__package_previews__",
        ".eslintcache",
        ".jest-cache",
        ".moon/cache",
        ".next/",
        ".parcel-cache",
        ".store",
        "**/build",
        "**/coverage",
        "**/storybook-static",
        "**/vendored"
    ],
    "typescript": {
        "associations": ["**/*.{ts,tsx,js,jsx,cjs,mjs}"],
        "binaryExpression.operatorPosition": "sameLine",
        "memberExpression.linePerExpression": true,
        "preferSingleLine": true,
        "quoteStyle": "preferSingle"
    },
    "json": {
        "associations": ["**/*.{json,jsonc}", "!**/package.json"]
    },
    "exec": {
        "associations": ["**/package.json", "**/*.{bash,sh}"],
        "prettier-package-json": "node_modules/.bin/prettier-package-json --write {{file_path}}",
        "prettier-package-json.associations": ["**/package.json"],
        "shfmt": "shfmt --write --simplify --filename {{file_path}} -i 2 -bn -ci -sr -kp -",
        "shfmt.associations": "**/*.{bash,sh}"
    },
    "plugins": [
        "https://plugins.dprint.dev/exec-0.3.1.json@9351b67ec7a6b58a69201c2834cba38cb3d191080aefc6422fb1320f03c8fc4d",
        "https://plugins.dprint.dev/typescript-0.78.0.wasm",
        "https://plugins.dprint.dev/json-0.16.0.wasm",
        "https://plugins.dprint.dev/markdown-0.14.1.wasm",
        "https://plugins.dprint.dev/toml-0.5.4.wasm",
        "https://plugins.dprint.dev/dockerfile-0.3.0.wasm",
        "https://plugins.dprint.dev/prettier-0.13.0.json@dc5d12b7c1bf1a4683eff317c2c87350e75a5a3dfcc127f3d5628931bfb534b1"
    ]
}

What am I doing wrong?

dsherret commented 2 years ago

What version of dprint do you have? Run dprint upgrade and if that doesn't work, you definitely have an old version so update by following: https://dprint.dev/install/

dsherret commented 2 years ago

Actually, I'm now able to reproduce. Looking into it.

dsherret commented 2 years ago

Change "prettier-package-json.associations": ["**/package.json"] to "prettier-package-json.associations": "**/package.json" for now. I'll look into fixing this.

dsherret commented 2 years ago

Run dprint config update in the directory of your configuration file to upgrade to 0.3.2 and this should be fixed now.

tomdavidson commented 2 years ago

@dsherret your amazing. Thank you for helping me out so quickly and Im happy to report that 0.3.2 does resolve!