Skip to content

papaia/prettignore

Repository files navigation

Prettignore

Prettier but for ignore files!

Format any .*ignore file with ease!

npm version weekly downloads from npm code style: prettier

CLI

Run prettignore --help for details

Configuration

Make a .prettignorerc.json file in the root of your project.

The config should have the following structure:

interface PrettignoreConfig {
  files: string[];
  endOfLine?: 'lf' | 'crlf' | 'cr' | 'auto';
}

API

formatLine(line: string): string

formatLine(line);

formatFile(content: string, config: PrettignoreConfig): string

formatFile(content, { endOfLine: 'lf' });

Examples

Adds spaces after comments

#just a nice comment!

Becomes:

# just a nice comment!

Removes trailing and leading spaces and lines

        dist
              build

Becomes:

dist
build

Removes line gaps larger than one line

dist



build

Becomes:

dist

build

E v e r y t h i n g

dist      

    .ignored*



    #comment


  # another comment

  build/

  .secretfile.json



  

Becomes:

dist

.ignored*

# comment

# another

build/

.secretfile.json