Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Latest commit

 

History

History
119 lines (83 loc) · 3.59 KB

CONTRIBUTING.md

File metadata and controls

119 lines (83 loc) · 3.59 KB

Contributing Guidelines

The Five Golden Rules

The simple steps of contributing to any GitHub project are as follows:

  1. Fork the repository(https://github.com/kata-ai/tslint-config-kata/fork)
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push -u origin my-new-feature
  5. Create a Pull Request!

To keep your fork of in sync with this repository, follow this guide.

Prerequisites

Windows, macOS and Linux

Development guide

Install dependencies using Yarn.

$ yarn

To start incremental build, run:

$ yarn start

After updating, test the changes against the code by building it:

$ yarn build

To build the package for publishing, run:

$ yarn publish

Project structure

Entry files

Just like ESLint, the TSLint config can either be written in JSON format, or plain JS format. In this case, we use the latter, but compiled from TypeScript.

The main entry point for our config is the .js files located at the root. Note that we separated the configurations into two:

  • ./index.js - Base config that overrides the default TSLint config.
  • ./react.js - Overrides to React-specific rules provided by tslint-react.

The entry files are written in the following format:

// ./index.js

// Point to the built index file, and specifically choose the config to use.
module.exports = require('./build/index').baseConfig;

Configuration files

Next comes the configuration file. This file is formatted the same as a regular tslint.json file, only in JavaScript. For an example on how to write rules in this format, see this example config.

It is very important to use a separate named export in this very file for creating additional configs.

// ./src/index.ts
import react from './config/react';
import base from './config/base';

export const baseConfig = {
  rulesDirectory: [
    // ...the custom rules we import
  ],
  extends: [
    // ...the configs/rulesets we extend
  ],
  rules: {
    ...base.rules,
    ...react.rules
    // ...add extra config sets below
  }
};

export const otherConfig = {
  // ...another config path using different configs
};

Further reading: The TSLint documentation on shareable configurations.

Custom rules directory

Any additional custom TSLint rules must be added inside the ./src/rules directory. Please follow the TSLint documentation on adding custom rules. Make sure to follow these conventions:

  • Rule identifiers are always kebab-cased.
  • Rule files are always camel-cased (camelCasedRule.ts).
  • Rule files must contain the suffix Rule.
  • The exported class must always be named Rule and extend from Lint.Rules.AbstractRule.

To load these custom rules into TSLint, make sure to add said folder to the rulesDirectory config.

// ./src/base.ts
module.exports = {
  rulesDirectory: ['./rules', ...otherRules],
  ...otherConfigs
};