question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

config file doesn't work at the way other libraries do

See original GitHub issue

First, It’s very exciting that config file support is out.

However, after a few tries, I find its usage is a bit ambiguous.

For example, I define a .prettierrc like the follow:

{
  "printWidth": 120,
  "tabWidth": 2,
  "singleQuote": true,
  "semi": false,
  "trailingComma": "all",
  "overrides": [
    {
      "files": "src/**/*.ts",
      "options": {
        "parser": "typescript",
        "tabWidth": 4
      }
    },
    {
      "files": "./**/*.js",
      "options": {
        "parser": "babylon",
        "singleQuote": false
      }
    },
    {
      "files": "src/**/*.{scss,css}",
      "options": {
        "parser": "postcss",
        "singleQuote": false,
        "semi": true
      }
    },
    {
      "files": "./**/*.json",
      "options": {
        "parser": "json"
      }
    },
    {
      "files": ".prettierrc",
      "options": {
        "parser": "json"
      }
    }
  ]
}

Since I specify the files in overrides, prettier should do the right job with prettier --write or prettier --list-difference.

However, prettier doesn’t work that way now. If I run the command above, prettier will only output the help message and exit. Apparently, prettier is waiting for source input. But it doesn’t make sense to specify input again.

There is a dirty workaround prettier --write ./**/**.{ts,js,json,scss,css}. But it lose the ability to prettier various specify path.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:15
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

10reactions
felixfbeckercommented, Oct 18, 2018

I would really like Prettier to just format all files in the cwd that it supports. Currently I have to construct a glob in every project, which is highly non-trivial when it comes to dotfiles like .travis.yml and other config files:

`prettier '**/{*.{js?(on),ts,y?(a)ml,graphql,md,scss},.*.y?(a)ml,.*.json,.prettierrc,.stylelintrc}'`
8reactions
thorn0commented, Feb 25, 2020

@trevordmiller Prettier 2.0 is going to support prettier --write ., see https://github.com/prettier/prettier/pull/7660.

Read more comments on GitHub >

github_iconTop Results From Across the Web

library configuration file not copied to referenced project - MSDN
config file was copied, below steps are what I did: 1. Create a C# console project and library project separately. 2. Add reference...
Read more >
codeigniter autoload config file doesn't work in library
1 Answer 1 ... Libraries do not share the same application scope as controllers or models. You need to retrieve the CI super...
Read more >
Configuration Files - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Config file processing in Spring Boot 2.4
So in Spring Boot 2.4 we're planning to make two significant changes to the way the properties and YAML files are loaded: Documents...
Read more >
What is a config file? - Opensource.com
Computer screen with files or windows open. Image by: ... Configuration files can be, and often are, very simple in structure.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found