idahogurl / vs-code-prettier-eslint

A Visual Studio Code Extension to format JavaScript and TypeScript code using the prettier-eslint package.
MIT License
185 stars 46 forks source link

Prettier settings is not working #148

Closed behtgod closed 1 year ago

behtgod commented 1 year ago

I installed Eslint and Prettier Eslint only. But the file is not formated by my prettier settings on both auto saving and formatting manually( Shift+Alt+F). Using terminal command yarn eslint **/main.ts --fix is OK.

My example code named main.ts:

//Formatted by auto saving or Shift+Alt+F
//Wrong!

import { createApp } from "vue";
import "./style.css";
import App from "./App.vue";

function fun() {
    for (let i = 0; i < 10; i++);
}

fun();

createApp(App).mount("#app");

//Formatted by command `yarn eslint **/main.ts --fix`
//Right!
import { createApp } from 'vue';
import './style.css';
import App from './App.vue';

function fun() {
  for (let i = 0; i < 10; i++);
}

fun();

createApp(App).mount('#app');

My settings:

{
    "editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
    "editor.formatOnPaste": false, // required
    "editor.formatOnType": false, // required
    "editor.formatOnSave": true, // optional
    "editor.formatOnSaveMode": "file", // required to format on save
    "files.autoSave": "onFocusChange"
}

My eslint configuration.

module.exports = {
    env: {
        browser: true,
        es2021: true,
    },
    extends: [
        "eslint:recommended",
        "plugin:vue/vue3-recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:prettier/recommended",
    ],
    overrides: [],
    parser: "vue-eslint-parser",
    parserOptions: {
        ecmaVersion: "latest",
        sourceType: "module",
    },
    plugins: ["vue", "@typescript-eslint"],
    rules: {},
};

My prettier configuration:

{
    "tabWidth": 2,
    "singleQuote": true
}

VSCode version: 1.75.1

idahogurl commented 1 year ago

@behtgod You have to install eslint and prettier only.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.