Examples

Basic usage

The file .gitignore must have a line with the content /dist/.

style = "style.json"

project-config self configuration

project-config is defining a valid configuration, forcing the definition of styles as an array for styles and a valid cache value.

style = ["style.json5"]
cache = "5 minutes"

Files absence

The files readme.md and index.md must not exist.

style = "style.yaml"

Conditionals

If .gitignore includes the line __pycache__/ a pyproject.toml file must be present.

style = "style.json"

Conditionals files existence

Follows the next rules:
  • If the directory src/ exists, the file pyproject.toml must exists too.

  • If the file pyproject.toml exists, a Python file must be present in the root directory.

style = "style.json5"

Compare values between serializable files

The version defined in __version__ inside a Python script must match the metadata defined in pyproject.toml file.

style = "style.toml"

JMESPath against online sources

Check that the license field of package.json file is defined with a valid OSI approved SPDX license identifier.

style = "style.json5"

Assert root directory name

Check that the name of the directory that is the root of the project matches against certain regular expression.

style = "style.json5"

TOML sections order

Check that the section [foo] of a TOML file is placed before the section [bar].

style = "style.json5"

Editing a .gitignore file

Enforce the existence of certain lines in a .gitignore file.

style = "style.json5"

Replacing code blocks languages in RST documents

Don’t allow code blocks in RST documentation files:
  • Bash is not a POSIX compliant shell, use Shell lexer.

  • Pygments’ JSON5 lexer is not implemented yet, use Javascript lexer.

style = "style.json5"

Autofixing .editorconfig

If you run the next example using project-config fix subcommand without creating an .editorconfig file it will be created and populated with the sections defined in the rule.

style = "style.json5"

Setting hooks in .pre-commit-config.yaml

Set a pre-commit hook for editorconfig-checker inside .pre-commit-config.yaml with manual fixes.

style = "style.json5"

Tip

For more complex examples check my own styles at mondeja/project-config-styles.