Contributing

Contributions to UnCSS are welcome! Whether you're fixing a bug, improving documentation, or proposing a new feature, your help is appreciated.

Setting Up the Development Environment

To get started with development, you'll need to clone the repository and install the dependencies.

  1. Fork and Clone the Repository

    First, fork the repository on GitHub. Then, clone your fork locally:

    git clone https://github.com/YOUR_USERNAME/uncss.git
    cd uncss
  2. Install Dependencies

    This project uses npm. We recommend using npm ci to install dependencies for a clean, reproducible build based on the package-lock.json file.

    npm ci

Running Tests

UnCSS has a comprehensive test suite to ensure code quality and prevent regressions. Before submitting any changes, please ensure all tests pass.

  • Run all checks (linting + tests):

    npm test
  • Run only the test suite (Mocha):

    npm run mocha
  • Generate a test coverage report:

    The project uses c8 for coverage.

    npm run cover

    A detailed HTML report will be generated in the coverage/ directory.

Code Style and Linting

The project uses ESLint for code analysis and Prettier for code formatting to maintain a consistent style.

  • Run the linter:

    npm run lint

Pre-commit Hook

This project uses husky and lint-staged to automatically format and lint your code before you commit. When you run git commit, it will automatically:

  1. Run prettier --write on staged .js, .css, .json, and .md files.
  2. Run eslint --fix on staged .js files.

This helps ensure that all committed code adheres to the project's style guidelines.

Submitting a Pull Request

  1. Create a new branch for your feature or bugfix:

    git checkout -b my-awesome-feature
  2. Make your changes and commit them with a descriptive message.

  3. Ensure all tests and linting checks pass (npm test).

  4. Push your branch to your fork:

    git push origin my-awesome-feature
  5. Open a pull request from your fork to the master branch of the uncss/uncss repository.

Thank you for contributing!