Skip to content

Instantly share code, notes, and snippets.

@montasim
Created July 6, 2024 14:19
Show Gist options
  • Save montasim/62b7f440f23ae69ab78ef897db2ae953 to your computer and use it in GitHub Desktop.
Save montasim/62b7f440f23ae69ab78ef897db2ae953 to your computer and use it in GitHub Desktop.
Ignoring these files and directories ensures that Prettier only formats the code files you actively develop and maintain, such as .js, .jsx, .ts, .tsx, .css, .html, etc. This helps maintain the integrity and readability of configuration files and directories that either contain generated code, package dependencies, or configuration settings that…
# Ignore artifacts:
.idea
node_modules
build
logs
documentation
yarn.lock
LICENSE
SECURITY.md
.prettierignore
.babelrc
.env
.env.development
@montasim
Copy link
Author

montasim commented Jul 6, 2024

File Overview

.prettierignore is used to exclude certain files and directories from Prettier's formatting process. This is particularly useful for minimizing disruption in files that may not benefit from formatting, or where formatting might introduce errors or stylistic conflicts.

Descriptions of Ignored Items

.idea: This directory typically contains project settings specific to JetBrains IDEs like IntelliJ IDEA. It includes user-specific settings that do not need formatting and should not be altered by tools like Prettier.

node_modules: A directory where npm or yarn installs the project’s npm package dependencies. It should be ignored as it contains third-party code that you don’t need to format.

build: Often contains compiled or transpiled code generated from your source files. Since this is output code, it should not be formatted by Prettier.

logs: This might refer to a directory that stores log files. Formatting log files is unnecessary and can potentially alter their readability.

documentation: If your documentation includes auto-generated files or specific markdown formatting that shouldn’t be altered, ignoring this directory can prevent unwanted changes.

yarn.lock: This file is automatically generated by Yarn to lock the versions of package dependencies. It should not be formatted as its structure is managed by Yarn itself.

LICENSE: Typically a plain text file outlining the license under which the project is provided. Formatting this could alter its legal phrasing or structure unintentionally.

SECURITY.md: A markdown file typically used to provide security-related information. This might contain specific formatting that should not be altered.

.prettierignore: Including this file in the ignore list ensures that Prettier doesn’t attempt to format its own configuration files.

.babelrc: Configuration file for Babel, a JavaScript compiler. This is typically a JSON file and should retain its format for Babel to read correctly.

.env and .env.development: Environment variable files that should not be altered by formatting tools to prevent potential issues in how values are read at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment