******** Examples ******** Basic usage =========== The file `.gitignore` must inline a line with the content ``/dist/``. .. tabs:: .. tab:: .project-config.toml .. code-block:: toml style = "style.json" .. tab:: .gitignore .. code-block:: text /dist/ .. tab:: style.json .. code-block:: json { "rules": [ { "files": [".gitignore"], "includeLines": ["/dist/"] } ] } Project config self configuration ================================= Asserts that **project-config** is defining a valid configuration, forcing the definition of ``styles`` as an array for styles and a valid ``cache`` value. .. tabs:: .. tab:: .project-config.toml .. code-block:: toml style = ["style.json5"] cache = "5 minutes" .. tab:: style.json5 .. code-block:: js { rules: [ { files: [".project-config.toml"], JMESPathsMatch: [ // `style` must be defined in the file ["contains(keys(@), 'style')", true], // `style` must be an array ["type(style)", "array"], // at least one style configured ["op(length(style), '>', `0`)", true], // configure cache explicitly ["contains(keys(@), 'cache')", true], // cache must have a valid value [ "regex_match('^(\\d+ ((seconds?)|(minutes?)|(hours?)|(days?)|(weeks?)))|(never)$', cache)", true, ], ], }, ], } Files absence ============= The files `readme.md` and `index.md` must not exist. .. tabs:: .. tab:: .project-config.toml .. code-block:: toml style = "style.yaml" .. tab:: style.yaml .. code-block:: yaml rules: - files: not: readme.md: Users expect are more used to seeing README.md file name in uppercase hint: Rename 'readme.md' to 'README.md' - files: not: - index.md Conditionals ============ If `.gitignore` includes the line ``__pycache__/`` a `pyproject.toml` file must be present. .. tabs:: .. tab:: .project-config.toml .. code-block:: toml style = "style.json" .. tab:: .gitignore .. code-block:: text __pycache__/ .. tab:: style.json .. code-block:: json { "rules": [ { "ifIncludeLines": { ".gitignore": ["__pycache__/"] }, "files": ["pyproject.toml"] } ] } .. tab:: pyproject.toml .. code-block:: toml .. raw:: html
.. tip:: For more complex examples check my own styles at `mondeja/project-config-styles`_. .. _mondeja/project-config-styles: https://github.com/mondeja/project-config-styles