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

Support for laravel blade files #369

Closed
5 tasks done
glennmichael123 opened this issue Dec 19, 2023 · 8 comments
Closed
5 tasks done

Support for laravel blade files #369

glennmichael123 opened this issue Dec 19, 2023 · 8 comments

Comments

@glennmichael123
Copy link

glennmichael123 commented Dec 19, 2023

Describe the bug

We tried configuring for .blade.php files but the auto-formatting did not work. Is support for blade files not there yet or did we misconfigure our configs?

Reproduction

https://github.com/ci-on/eslint-example/blob/main/eslint.config.js#L18C3-L29C5

System Info

System:
    OS: macOS 14.0
    CPU: (10) arm64 Apple M2 Pro
    Memory: 60.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v14.21.1/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
    pnpm: 8.10.4 - ~/.nvm/versions/node/v14.21.1/bin/pnpm
    bun: 1.0.17 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 119.0.6045.105
    Safari: 17.0

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@glennmichael123 glennmichael123 changed the title Support for laravel blade files. Support for laravel blade files Dec 19, 2023
@Dimava
Copy link
Contributor

Dimava commented Dec 19, 2023

@glennmichael123 you gonna need prettier-plugin-blade installed

@glennmichael123
Copy link
Author

@Dimava this package right here?

https://github.com/shufo/prettier-plugin-blade

@Dimava
Copy link
Contributor

Dimava commented Dec 19, 2023

@glennmichael123 yep, prettier itself also uses plugins for languages that are not built-in (html/js/css/gql/md/yaml)

@glennmichael123
Copy link
Author

@Dimava thank you for your response and apologies for the late reply, I tried installing that - I wasn't able to make it work, without somehow having to press cmd + shift + I, the desired output is just to make it behave the same way as JS/Vue files, which is to auto-format on save. I got nothing.

@Dimava
Copy link
Contributor

Dimava commented Dec 21, 2023

@glennmichael123 please update your example repo and link a couple of .blade files so I could try it

@glennmichael123
Copy link
Author

@Dimava updated it, i hope i knew what i was doing there 😅

https://github.com/ci-on/eslint-example

@glennmichael123
Copy link
Author

@Dimava

Hi, sorry for bothering you, were you able to take a look at the minimal reproduction and figure out something? Or do you need more info?

@Dimava
Copy link
Contributor

Dimava commented Jan 15, 2024

@glennmichael123

  1. eslint-plugin-format won't pick your .prettierrc
  2. eslint-plugin-format won't pick your overrides
export default [{
  files: ['**/*.blade.php'],
  plugins: { format },
  languageOptions: { parser: format.parserPlain },
  rules: {
    'format/prettier': ['error', {
      // "plugins": ["@shufo/prettier-plugin-blade"], "trailingCommaPHP": true,, etc
      ...JSON.parse(readFileSync('./.prettierrc', 'utf8')),
      // "parser": "blade", "tabWidth": 4
      ...JSON.parse(readFileSync('./.prettierrc', 'utf8')).overrides[0].options,
    }],
  },
}]

@antfu antfu closed this as completed May 2, 2024
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

3 participants