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

Configure default formatter for TypeScript React #52

Open
zamber opened this issue Dec 7, 2022 · 1 comment
Open

Configure default formatter for TypeScript React #52

zamber opened this issue Dec 7, 2022 · 1 comment

Comments

@zamber
Copy link

zamber commented Dec 7, 2022

On 0.33.0 with 0.13.5, I'm trying to setup formatting on-save and got this when running format document by hand from the command palette:

image

workspace settings.json

{
    "editor.defaultFormatter": "dprint.dprint",
    "editor.formatOnSave": true,
    "editor.trimAutoWhitespace": true,
    "eslint.format.enable": false,
    "eslint.trace.server": "messages",
    "[javascript]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    },
    "[javascriptreact]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    },
    "[typescript]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    },
    "[typescriptreact]": {
        "editor.defaultFormatter": "dprint.dprint",
        "editor.formatOnSave": true
    },
    "dprint.verbose": true
}

I disabled formatting for JS and TS in user settings.json. It seems to format json:

image

dprint.json

{
    "indentWidth": 4,
    "useTabs": false,
    "typescript": {
        "lineWidth": 120,
        "quoteStyle": "preferSingle",
        "jsx.quoteStyle": "preferDouble",
        "quoteProps": "asNeeded"
    },
    "includes": ["**/*.{ts,tsx,js,jsx,cjs,mjs}", "**/*.{json}"],
    "excludes": [
        "**/node_modules",
        "packages/",
        "__tests__/fixtures/*.json",
        "__mocks__/*.json",
        "**/*.fixture.json",
        "**/*.fixtures.json"
    ],
    "plugins": [
        "https://plugins.dprint.dev/typescript-0.78.0.wasm",
        "https://plugins.dprint.dev/json-0.16.0.wasm"
    ]
}
@zamber
Copy link
Author

zamber commented Dec 8, 2022

OK, I see where the issue is. If I open the file from source control and I get an absolute path like this:
image
then dprint formatting fails even of the path is the same as the workspace path (and especially then).
If I open the file from the VS Code explorer then everything is fine and the formatter works.
image

Not sure if this is a regression to the fix done in 0.13.5, I literally set up dprint yesterday.

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