Skip to content

SyntaxError in prettier parser #116

@renatoknb

Description

@renatoknb
"pre-commit": "precise-commits --whitelist=\"**/*.{js,ts,yml,yaml,md,html,css,scss}\""

"@softwareventures/precise-commits": "^4.0.19",
"prettier": "^3.5.3",

Errored code block

class DocumentFormStore {
  constructor() {
    extendObservable(this, {
      model: {
        operatingCostOn: '',
        operatingCostRaise: '',
        heatingCostOn: '',
        .
        .
        .
      }
   }
 }
}

My .prettierrc

{
  "bracketSpacing": true,
  "semi": false,
  "singleQuote": true,
  "trailingComma": "none",
  "tabWidth": 2,
  "printWidth": 80,
  "endOfLine": "lf",
  "arrowParens": "always",
  "useTabs": false,
  "jsxSingleQuote": false,
  "bracketSameLine": false,
  "overrides": [
    {
      "files": "*.js",
      "options": {
        "parser": "babel"
      }
    },
    {
      "files": "*.store.js",
      "options": {
        "parser": "babel"
      }
    },
    {
      "files": "*.ts",
      "options": {
        "parser": "typescript"
      }
    },
    {
      "files": "*.tsx",
      "options": {
        "parser": "typescript"
      }
    },
    {
      "files": "*.jsx",
      "options": {
        "parser": "babel"
      }
    },
    {
      "files": "*.json",
      "options": {
        "parser": "json"
      }
    },
    {
      "files": "*.md",
      "options": {
        "parser": "markdown"
      }
    },
    {
      "files": "*.yaml",
      "options": {
        "parser": "yaml"
      }
    },
    {
      "files": "*.yml",
      "options": {
        "parser": "yaml"
      }
    },
    {
      "files": "*.css",
      "options": {
        "parser": "css"
      }
    },
    {
      "files": "*.scss",
      "options": {
        "parser": "scss"
      }
    },
    {
      "files": "*.html",
      "options": {
        "parser": "html"
      }
    }
  ]
}

and given error

✖ An Error occurred
SyntaxError: Missing semicolon. (1:14)
> 1 | constructor() {
    |              ^
  2 |     extendObservable(this, {
  3 |       model: {
  4 |         operatingCostOn: '',

It also seems like it's not following .prettierignore file at all. This can be verified by comparing npx prettier --check . and npx precise-commits --check-only. Although those two commands check "different" files, meaning that first one checks entire folder and subfolders while other checks only staged files, I expect it to follow .prettierignore for staged files too. Feel free to correct me if I am wrong or this is wanted behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions