Migrate to Netlify Today

Netlify announces the next evolution of Gatsby Cloud. Learn more

ContactSign Up
Community Plugin
View plugin on GitHub

gatsby-plugin-tslint

Provides drop-in support for TSLint. Based off of gatsby-plugin-eslint.

NOTE: This plugin is currently only available for Gatsby v2.

Installation

  1. Install the gatsby-plugin-tslint plugin:

    npm install --save-dev gatsby-plugin-tslint

    or

    yarn add --dev gatsby-plugin-tslint

  2. Install TSLint and tslint-loader:

    npm install --save-dev tslint tslint-loader

    or

    yarn add --dev tslint tslint-loader

Usage

Add into gatsby-config.js.

// gatsby-config.js

module.exports = {
  plugins: [
    'gatsby-plugin-tslint'
  ]
}

If no options are specified, the plugin defaults to:

  1. Lint .ts and .tsx files.
  2. Exclude node_modules, .cache, and public folders from linting.

You can specify your own linting filetypes and exclusions:

// gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: 'gatsby-plugin-tslint',
      options: {
        test: /\.ts$|\.tsx$/,
        exclude: /(node_modules|cache|public)/
      }
    }
  ]
}

Configuring TSLint

This plugin assumes that you use a tslint.json file to configure TSLint. Use those files to do all of your configuration.

© 2023 Gatsby, Inc.