TypeScript stylistic rules for ESLint providing comprehensive code style enforcement for modern ESLint configurations.
npx @tessl/cli install tessl/npm-stylistic--eslint-plugin-ts@4.4.00
# ESLint Stylistic TypeScript Plugin
1
2
**⚠️ DEPRECATION NOTICE: This package is deprecated in favor of the unified @stylistic/eslint-plugin. Please consider migrating to the main package.**
3
4
ESLint Stylistic TypeScript Plugin provides TypeScript-specific stylistic and formatting rules for ESLint. This package serves as a community-maintained alternative after ESLint and typescript-eslint teams deprecated formatting rules from their core packages, offering comprehensive TypeScript code style enforcement for modern ESLint configurations.
5
6
## Package Information
7
8
- **Package Name**: @stylistic/eslint-plugin-ts
9
- **Package Type**: npm
10
- **Language**: TypeScript
11
- **Installation**: `npm install @stylistic/eslint-plugin-ts`
12
- **Migration**: Consider migrating to `@stylistic/eslint-plugin` (unified package)
13
14
## Core Imports
15
16
```typescript
17
import stylistic from "@stylistic/eslint-plugin-ts";
18
```
19
20
For CommonJS:
21
22
```javascript
23
const stylistic = require("@stylistic/eslint-plugin-ts");
24
```
25
26
For specific rules:
27
28
```typescript
29
import blockSpacing from "@stylistic/eslint-plugin-ts/rules/block-spacing";
30
```
31
32
## Basic Usage
33
34
```typescript
35
import stylistic from "@stylistic/eslint-plugin-ts";
36
37
// Basic ESLint configuration
38
export default [
39
{
40
plugins: {
41
"@stylistic/ts": stylistic,
42
},
43
rules: {
44
"@stylistic/ts/indent": ["error", 2],
45
"@stylistic/ts/quotes": ["error", "single"],
46
"@stylistic/ts/semi": ["error", "always"],
47
},
48
},
49
];
50
51
// Using predefined configurations
52
export default [
53
stylistic.configs.all, // Enable all stylistic rules
54
];
55
```
56
57
## Architecture
58
59
The plugin is built around several key components:
60
61
- **Plugin Object**: Main export containing rules and configurations
62
- **Rules Collection**: 25 TypeScript-specific stylistic rules
63
- **Configuration Presets**: Pre-configured rule sets for common use cases
64
- **Type Definitions**: Complete TypeScript interfaces for all rule options
65
- **Individual Rule Exports**: Direct access to specific rules for custom configurations
66
67
## Capabilities
68
69
### Plugin Configuration
70
71
Core plugin object providing rules and configuration presets for ESLint integration.
72
73
```typescript { .api }
74
interface Plugin {
75
rules: Rules;
76
configs: {
77
"disable-legacy": Linter.Config;
78
"all": Linter.Config;
79
"all-flat": Linter.Config; // @deprecated use 'all' instead
80
};
81
}
82
83
interface Rules {
84
[K in keyof UnprefixedRuleOptions]: Rule.RuleModule;
85
}
86
```
87
88
[Plugin Configuration](./plugin-configuration.md)
89
90
### Stylistic Rules
91
92
Collection of 25 TypeScript-specific formatting and style rules including spacing, indentation, quotes, semicolons, and object/array formatting.
93
94
```typescript { .api }
95
interface UnprefixedRuleOptions {
96
"block-spacing": BlockSpacingRuleOptions;
97
"brace-style": BraceStyleRuleOptions;
98
"comma-dangle": CommaDangleRuleOptions;
99
"comma-spacing": CommaSpacingRuleOptions;
100
"func-call-spacing": FunctionCallSpacingRuleOptions;
101
"function-call-spacing": FunctionCallSpacingRuleOptions;
102
"indent": IndentRuleOptions;
103
"key-spacing": KeySpacingRuleOptions;
104
"keyword-spacing": KeywordSpacingRuleOptions;
105
"lines-around-comment": LinesAroundCommentRuleOptions;
106
"lines-between-class-members": LinesBetweenClassMembersRuleOptions;
107
"member-delimiter-style": MemberDelimiterStyleRuleOptions;
108
"no-extra-parens": NoExtraParensRuleOptions;
109
"no-extra-semi": NoExtraSemiRuleOptions;
110
"object-curly-newline": ObjectCurlyNewlineRuleOptions;
111
"object-curly-spacing": ObjectCurlySpacingRuleOptions;
112
"object-property-newline": ObjectPropertyNewlineRuleOptions;
113
"padding-line-between-statements": PaddingLineBetweenStatementsRuleOptions;
114
"quote-props": QuotePropsRuleOptions;
115
"quotes": QuotesRuleOptions;
116
"semi": SemiRuleOptions;
117
"semi-spacing": SemiSpacingRuleOptions;
118
"space-before-blocks": SpaceBeforeBlocksRuleOptions;
119
"space-before-function-paren": SpaceBeforeFunctionParenRuleOptions;
120
"space-infix-ops": SpaceInfixOpsRuleOptions;
121
"type-annotation-spacing": TypeAnnotationSpacingRuleOptions;
122
}
123
```
124
125
[Stylistic Rules](./stylistic-rules.md)
126
127
## Types
128
129
```typescript { .api }
130
import type { Linter, Rule } from "eslint";
131
132
interface Rules {
133
[K in keyof UnprefixedRuleOptions]: Rule.RuleModule;
134
}
135
136
declare const plugin: {
137
rules: Rules;
138
configs: {
139
"disable-legacy": Linter.Config;
140
"all": Linter.Config;
141
"all-flat": Linter.Config;
142
};
143
};
144
```