Skip to content

Latest commit

 

History

History
337 lines (231 loc) · 12.5 KB

CONTRIBUTING.md

File metadata and controls

337 lines (231 loc) · 12.5 KB
id title
contributing
Contributing Guideline

You can contribute to textlint in various ways:

  • Reporting issues
  • Submitting pull request which fixes known issues, improve documentation, or implement new feature
  • Creating an enhancement request or suggestions
  • Writing your own rules or plugins
  • Writing an article about textlint on your blog

Although we are accepting pull request, we recommend creating an issue first as it enables us to discuss your proposal before you put significant effort into it.

Reporting New Issues or Feature Suggestions

Please create a new issue on GitHub if you found a bug, got a question, or had an idea for improvement. All work on textlint happens on GitHub in English.

As described at the ISSUE_TEMPLATE.md, please include following information when reporting a bug:

  • What version of textlint are you using? (textlint -v)
  • What file type (Markdown, plain text, etc.) are you using?
  • What did you do? Please include the actual source code causing the issue.
  • What did you expect to happen?
  • What actually happened? Please include the actual, raw output from textlint. (textlint --debug <options> ...)

Creating a new repository that can reproduce the issue helps us understand your situation. This repository for example.

Development Workflow

Here you can see how to get the source of textlint, build it, and run tests locally. We use GitHub Flow as development workflow.

If you want to contribute to textlint, please check issues labeled good first issue. These issues are suitable for your first contribution.

Installing Prerequisites

Please install following development prerequisites. You also need a GitHub account for contribution.

  • Git
  • Node.js -- We tend to use the latest stable Node.js
  • Text editor
  • Terminal emulator

Cloning Copy of textlint

Forking a repository allows you to work with textlint codebase without special permission to the textlint repository itself.

  1. Click Fork textlint

  2. Fork textlint repository to your account

  3. Create a clone of the fork locally in your terminal:

    $ git clone --recursive https://github.com/YOUR_ACCOUNT/textlint
    $ cd textlint/

See Fork A Repo: GitHub Help for further detail.

Building textlint

After getting your clone, you can start playing with textlint.

  1. Enable Corepack that help with managing versions of your package managers.

    $ corepack enable npm
  2. Install dependencies and build packages:

    $ npm install
  3. Build textlint:

    $ npm run build
  4. Building website if you needed:

    $ npm run website

Under the hood, textlint uses Lerna to manage multiple packages:

  • packages/*
  • packages/@textlint/*
  • examples/*
  • scripts/release
  • test/integration-test
  • website

If you are new to Lerna, it seems to add another layer of complexity but it's simpler than you think; you can edit codes, run tests, commit changes, etc. as usual in most cases.

Note that npm install also builds a codebase, you can manually build by running npm run build. We have separate task npm run website since code and documentation have different life cycle.

Creating a Branch for Your Work

Before adding changes to your clone, please create a new branch (typically called feature branch). Changes made to feature branch don't affect or corrupt master branch so you will feel safe. In Git, creating a branch is easy and fast:

$ git checkout -b your-new-feature

Making Changes

You have your feature branch with working textlint then it's time to start making changes! Edit codes with text editor of your choice and add commits as you work on. Please don't forget to add or modify test cases and documents according to your changes.

Note: TypeScript's Project References

This monorepo use Project References for faster building.

You can update Project References from package.json's dependencies.

npm run update:projectReferences

Also, You can check Project References if it is correct.

npm run test:projectReferences

Coding Guideline

Languages

While working with your idea, please use:

We are migrating entire codes to TypeScript.

Linting and Style

This repository uses ESLint for JavaScript linter and Prettier for code formatter. We use lint-staged and Git Hooks to make coding style consistent before commit, but if you have your own Git hooks locally, these setup doesn't work. In such case, please run ESLint and Prettier manually as below after making changes.

  • Run ESLint:

    $ npm run eslint
  • Run ESLint with --fix feature to fix some wrong style automatically:

    $ npm run eslint:fix
  • Run Prettier to reformat code:

    $ npm run format
Commit Message Format

We use Angular Convention for commit message.

In order to make repository history clean, please use the following guideline as possible as you can. It also enables us creating comprehensive changelog semi–automatically.

                      component        commit title
       commit type       /                /      
               \        |                |
                feat(rule-context): add template url parameter to events
                (a blank line)
       body ->  The `src` (i.e. the url of the template to load) is now provided to the
                `$includeContentRequested`, `$includeContentLoaded` and `$includeContentError`
                events.

referenced  ->  Closes #8453
issues          Ref. #8454
  • commit type:
    • docs: create or update document
    • feat: add new feature
    • fix: fix a bug
    • style: change formatting
    • perf: performance related change
    • test: update on tests
    • chore: house–keeping
    • refactor: refactoring related change
  • component: package or file name
  • commit title:
    • Limit to 50 characters including commit type and component (as possible as you can)
    • Do not capitalize first character
    • Do not end with a period
    • Use imperative mood, in present tense; commit title should always be able to complete the following sentence:
      • If applied, this commit will commit title here
  • body:
    • Separate from subject with a blank line
    • Wrap texts at 72 characters
    • Explain what and why, not how
    • GitHub flavored Markdown is ok to use
    • Start with BREAKING CHANGE: when you made significant change in the commit (see versioning section below).

Example commit message:

test(textlint-formatter): check types while testing

- Add strict type check option to `ts-node` to make sure future
  interface changes will be took into account while running test.
- Update test case for interface changes made at #430.

Closes #448.

Please see Commit Message Format and How to Write a Git Commit Message for detail.

Versioning

We care version number while releasing packages to npm registry so you should not modify version field of package.json. For the record, we use Semantic Versioning.

  • Patch release (intended to not break your lint build)
    • A bug fix to the CLI or core (including formatters)
    • Improvements to documentation
    • Non-user-facing changes such as refactoring
    • Re-releasing after a failed release (i.e., publishing a release that doesn't work for anyone)
  • Minor release (might break your lint build)
    • A new option
    • An existing rule is deprecated
    • A new CLI capability is created
    • New public API are added (new classes, new methods, new arguments to existing methods, etc.)
      • It might break type interface(.d.ts)
    • A new formatter is created
  • Major release (break your lint build)
    • A new option to an existing rule that results in ESLint reporting more errors by default
    • An existing formatter is removed
    • Part of the public API is removed or changed in an incompatible way

Running Tests

We have four type of tests. You should run at least unit test or documentation test according to your type of changes before submitting a pull request.

All tests should be run at the top directory of your fork.

Unit Test

Run tests under packages/:

$ npm run test

While developing, it would be good to run package level unit test since it will run faster:

$ cd packages/PACKAGE
$ npm run test

Example Test

Run examples as test:

$ npm run test:examples

Integration Test

Run tests with real–world documents:

$ git submodule update --init
$ npm run test:integration

Documentation Test

Run textlint to docs/, .github/, and README (we are dog–fooding!):

$ npm run test:docs

All Tests

Also, you can run all of the above by:

$ npm run test:all

Pushing the Commit and Opening a Pull Request

After finishing your changes and unit tests or documentation test ran fine, you can push your feature branch to GitHub. Please see GitHub Help for detail but typically, run git push at your terminal.

$ git push origin feature-branch

Then follow another GitHub Help to create a pull request.

Working with Reviews (if any)

Once a pull request has been created, it will initiate continuous integration builds and we can work on your changes. You can push additional commits to your fork according to feedback.

Merging

After all participants on pull request are satisfied to the changes, we will merge your code into the textlint master branch. Yay!

Release Flow

A Maintainer release new version of textlint by following way.

  1. Create Release PR via GitHub Actions: https://github.com/textlint/textlint/actions/workflows/create-release-pr.yml
    • Run workflow with version input
      • You can select new version with semver(patch,minor,major)
  2. [CI] Create Release PR
  3. Review the Release PR
    • You can modify PR body for changelog
  4. Merge the Release PR
  5. [CI] Publish new version to npm and GitHub Release

Warning If the publishing(Step 5) is failed, you can re-run the workflow.
Or, Open https://github.com/textlint/textlint/actions/workflows/release.yml and do "Run workflow".