or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-tslint-config-prettier

TSLint configuration that disables all formatting-related rules to enable seamless use of TSLint with Prettier

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/tslint-config-prettier@1.18.x

To install, run

npx @tessl/cli install tessl/npm-tslint-config-prettier@1.18.0

index.mddocs/

TSLint Config Prettier

TSLint Config Prettier is a TSLint configuration package that disables all formatting-related rules that conflict with Prettier. It ensures seamless integration between TSLint and Prettier by preventing rule conflicts, allowing TSLint to handle code quality while Prettier handles consistent formatting.

Package Information

  • Package Name: tslint-config-prettier
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install --save-dev tslint-config-prettier

Core Imports

For TSLint configuration usage (extends):

{
  "extends": [
    "tslint:latest",
    "tslint-config-prettier"
  ]
}

For programmatic conflict checking:

import { check } from "tslint-config-prettier/lib/checker";

CommonJS:

const { check } = require("tslint-config-prettier/lib/checker");

Basic Usage

As TSLint Configuration Extension

Add to your tslint.json file (must be at the end of extends array):

{
  "extends": [
    "tslint:latest",
    "tslint-react",
    "tslint-eslint-rules",
    "tslint-config-prettier"
  ]
}

Using the CLI Checker Tool

# Check for conflicts between TSLint config and Prettier
npx tslint-config-prettier-check ./tslint.json

# Check multiple configuration files
npx tslint-config-prettier-check ./tslint.json ./other-tslint.json

Programmatic Conflict Detection

import { check } from "tslint-config-prettier/lib/checker";

// Check for conflicts in configuration files
check(["./tslint.json", "./other-tslint.json"]);

Capabilities

TSLint Configuration

The main package export is a TSLint configuration that systematically disables 57 formatting rules that conflict with Prettier across 10 different rule providers.

Main Configuration File: lib/index.json

{
  "rules": {
    "align": false,
    "array-bracket-spacing": false,
    "arrow-parens": false,
    "block-spacing": false,
    "brace-style": false,
    "conditional-expression-parens": false,
    "eofline": false,
    "import-destructuring-spacing": false,
    "import-spacing": false,
    "indent": false,
    "jsx-alignment": false,
    "jsx-attribute-spacing": false,
    "jsx-curly-spacing": false,
    "jsx-equals-spacing": false,
    "jsx-expression-spacing": false,
    "jsx-no-closing-bracket-newline": false,
    "jsx-no-multiline-js": false,
    "jsx-space-before-trailing-slash": false,
    "jsx-wrap-multiline": false,
    "linebreak-style": false,
    "literal-spacing": false,
    "max-line-length": false,
    "multiline-arrow": false,
    "new-parens": false,
    "newline-per-chained-call": false,
    "no-consecutive-blank-lines": false,
    "no-empty-line-after-opening-brace": false,
    "no-extra-semi": false,
    "no-irregular-whitespace": false,
    "no-multi-spaces": false,
    "no-semicolon-interface": false,
    "no-trailing-whitespace": false,
    "no-unnecessary-parens-for-arrow-function-arguments": false,
    "no-unnecessary-semicolons": false,
    "number-literal-format": false,
    "object-curly-spacing": false,
    "object-literal-key-quotes": false,
    "one-line": false,
    "quotemark": false,
    "react-tsx-curly-spacing": false,
    "semicolon": false,
    "space-before-function-paren": false,
    "space-in-parens": false,
    "space-within-parens": false,
    "ter-arrow-parens": false,
    "ter-arrow-spacing": false,
    "ter-computed-property-spacing": false,
    "ter-func-call-spacing": false,
    "ter-indent": false,
    "ter-max-len": false,
    "ter-no-irregular-whitespace": false,
    "ter-no-tabs": false,
    "ter-padded-blocks": false,
    "trailing-comma": false,
    "type-literal-delimiter": false,
    "typedef-whitespace": false,
    "whitespace": false
  },
  "jsRules": {
    "align": false,
    "array-bracket-spacing": false,
    "arrow-parens": false,
    "block-spacing": false,
    "brace-style": false,
    "conditional-expression-parens": false,
    "eofline": false,
    "import-destructuring-spacing": false,
    "import-spacing": false,
    "indent": false,
    "jsx-alignment": false,
    "jsx-attribute-spacing": false,
    "jsx-curly-spacing": false,
    "jsx-equals-spacing": false,
    "jsx-expression-spacing": false,
    "jsx-no-closing-bracket-newline": false,
    "jsx-no-multiline-js": false,
    "jsx-space-before-trailing-slash": false,
    "jsx-wrap-multiline": false,
    "linebreak-style": false,
    "literal-spacing": false,
    "max-line-length": false,
    "multiline-arrow": false,
    "new-parens": false,
    "newline-per-chained-call": false,
    "no-consecutive-blank-lines": false,
    "no-empty-line-after-opening-brace": false,
    "no-extra-semi": false,
    "no-irregular-whitespace": false,
    "no-multi-spaces": false,
    "no-semicolon-interface": false,
    "no-trailing-whitespace": false,
    "no-unnecessary-parens-for-arrow-function-arguments": false,
    "no-unnecessary-semicolons": false,
    "number-literal-format": false,
    "object-curly-spacing": false,
    "object-literal-key-quotes": false,
    "one-line": false,
    "quotemark": false,
    "react-tsx-curly-spacing": false,
    "semicolon": false,
    "space-before-function-paren": false,
    "space-in-parens": false,
    "space-within-parens": false,
    "ter-arrow-parens": false,
    "ter-arrow-spacing": false,
    "ter-computed-property-spacing": false,
    "ter-func-call-spacing": false,
    "ter-indent": false,
    "ter-max-len": false,
    "ter-no-irregular-whitespace": false,
    "ter-no-tabs": false,
    "ter-padded-blocks": false,
    "trailing-comma": false,
    "type-literal-delimiter": false,
    "typedef-whitespace": false,
    "whitespace": false
  }
}

Supported Rule Providers:

  • codelyzer - Angular-specific TSLint rules
  • tslint - Core TSLint rules
  • tslint-consistent-codestyle - Consistent code style rules
  • tslint-divid - Additional linting rules
  • tslint-eslint-rules - ESLint rules ported to TSLint
  • tslint-immutable - Immutable programming rules
  • tslint-microsoft-contrib - Microsoft-contributed rules
  • tslint-misc-rules - Miscellaneous rules
  • tslint-react - React-specific TSLint rules
  • vrsource-tslint-rules - VRSource TSLint rules

CLI Conflict Checker

Command-line tool for detecting conflicts between TSLint configuration and Prettier formatting rules.

Binary: tslint-config-prettier-check

# Usage: tslint-config-prettier-check <pathToConfigFile> [pathToConfigFile2] [...]
tslint-config-prettier-check ./tslint.json
tslint-config-prettier-check ./tslint.json ./other-config.json

Behavior:

  • Analyzes provided TSLint configuration files
  • Detects rules that conflict with Prettier formatting
  • Reports conflicting rules to stderr with file paths
  • Exits with code 1 if conflicts found, 0 if no conflicts
  • Shows usage message if no configuration files provided

Example Output:

Conflict rule(s) detected in ./tslint.json:
  quotemark
  semicolon
  trailing-comma

Programmatic Conflict Detection

Node.js module providing programmatic access to conflict detection functionality.

/**
 * Check for conflicts between TSLint configuration files and Prettier
 * @param configFilePaths - Array of TSLint configuration file paths to check
 * @returns void - Logs conflicts and sets process.exitCode on conflicts/errors
 */
function check(configFilePaths: string[]): void;

Usage Example:

import { check } from "tslint-config-prettier/lib/checker";

// Check single configuration file
check(["./tslint.json"]);

// Check multiple configuration files  
check(["./tslint.json", "./shared-tslint.json"]);

// Check will log conflicts to console and set process.exitCode = 1 if conflicts found

Error Handling:

  • Logs usage information if empty array provided
  • Logs error messages for file reading errors or configuration parsing errors
  • Sets process.exitCode = 1 when conflicts detected or errors occur
  • Continues processing all provided files even if some fail

Types

// TSLint Configuration structure (from tslint library)
interface Configuration.RawConfigFile {
  rules?: { [key: string]: any };
  jsRules?: { [key: string]: any };
  extends?: string | string[];
}

// Internal conflict detection types
interface Configuration.IConfigurationFile {
  rules: Map<string, Configuration.IRule>;
  jsRules: Map<string, Configuration.IRule>;
}

interface Configuration.IRule {
  ruleSeverity: "error" | "warning" | "off";
  ruleArguments: any[];
}

Architecture

TSLint Config Prettier follows a simple but effective architecture:

  1. Rule Discovery: Build-time process scans source rule directories to identify all formatting rules across supported rule providers
  2. Configuration Generation: Automatically generates lib/index.json with all discovered rules disabled (false)
  3. Conflict Detection: Runtime analysis compares active TSLint rules against the comprehensive list of disabled formatting rules
  4. Multiple Interfaces: Provides both CLI and programmatic access to conflict detection functionality

The package operates as both a passive configuration (when extended in tslint.json) and an active analysis tool (via CLI or programmatic API) to ensure TSLint and Prettier work harmoniously together.