Search code examples
javascriptreactjsecmascript-6visual-studio-codeprettier

Disable prettier for a single file


I need to disable prettier for a single file (API URLs file) in my project in Vs-code. actually, I need each API and its URL to be in one line, but prettier breaks them in two lines.

before

export const GET_SEARCH_TEACHERS = params => myexampleFunction_app_base(`teachers/search/${params.search}`);

after

export const GET_SEARCH_TEACHERS = params =>
myexampleFunction_app_base(`teachers/search/${params.search}`);

Solution

  • If you want a certain file in a repo to never be formatted by prettier, you can add it to a .prettierignore file: Disable Prettier for one file

    From the docs:

    To exclude files from formatting, create a .prettierignore file in the root of your project. .prettierignore uses gitignore syntax.

    Example:

    # Ignore artifacts: 
    build 
    coverage
    
    # Ignore all HTML files:
    *.html