TSLint configuration that disables all formatting-related rules to enable seamless use of TSLint with Prettier
npx @tessl/cli install tessl/npm-tslint-config-prettier@1.18.0TSLint 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.
npm install --save-dev tslint-config-prettierFor 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");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"
]
}# 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.jsonimport { check } from "tslint-config-prettier/lib/checker";
// Check for conflicts in configuration files
check(["./tslint.json", "./other-tslint.json"]);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:
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.jsonBehavior:
Example Output:
Conflict rule(s) detected in ./tslint.json:
quotemark
semicolon
trailing-commaNode.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 foundError Handling:
process.exitCode = 1 when conflicts detected or errors occur// 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[];
}TSLint Config Prettier follows a simple but effective architecture:
lib/index.json with all discovered rules disabled (false)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.