or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

index.mdplugin-configuration.mdstylistic-rules.md

plugin-configuration.mddocs/

0

# Plugin Configuration

1

2

Plugin configuration capabilities for integrating @stylistic/eslint-plugin-ts with ESLint, including predefined configuration presets and individual rule access.

3

4

## Capabilities

5

6

### Main Plugin Export

7

8

The default export provides the complete plugin object with rules and configurations.

9

10

```typescript { .api }

11

/**

12

* Main plugin export containing rules and configuration presets

13

*/

14

declare const plugin: {

15

rules: Rules;

16

configs: {

17

"disable-legacy": Linter.Config;

18

"all": Linter.Config;

19

"all-flat": Linter.Config;

20

};

21

};

22

23

export default plugin;

24

```

25

26

**Usage Examples:**

27

28

```typescript

29

import stylistic from "@stylistic/eslint-plugin-ts";

30

31

// Basic plugin registration

32

export default [

33

{

34

plugins: {

35

"@stylistic/ts": stylistic,

36

},

37

rules: {

38

"@stylistic/ts/indent": ["error", 2],

39

"@stylistic/ts/quotes": ["error", "single"],

40

},

41

},

42

];

43

44

// Access individual rules

45

const indentRule = stylistic.rules.indent;

46

```

47

48

### Configuration Presets

49

50

Pre-configured ESLint configurations for common use cases.

51

52

```typescript { .api }

53

interface ConfigPresets {

54

/** Disable all legacy TypeScript formatting rules from @typescript-eslint */

55

"disable-legacy": Linter.Config;

56

/** Enable all stylistic rules with default settings */

57

"all": Linter.Config;

58

/** @deprecated use 'all' instead - Enable all stylistic rules */

59

"all-flat": Linter.Config;

60

}

61

```

62

63

#### Disable Legacy Configuration

64

65

Disables all legacy @typescript-eslint formatting rules to prevent conflicts.

66

67

```typescript { .api }

68

/**

69

* Configuration that disables all legacy @typescript-eslint formatting rules

70

* Use this to prevent conflicts when migrating from @typescript-eslint

71

*/

72

declare const disableLegacy: Linter.Config;

73

```

74

75

**Usage Examples:**

76

77

```typescript

78

import stylistic from "@stylistic/eslint-plugin-ts";

79

80

// Disable legacy rules

81

export default [

82

stylistic.configs["disable-legacy"],

83

{

84

plugins: {

85

"@stylistic/ts": stylistic,

86

},

87

rules: {

88

"@stylistic/ts/indent": ["error", 2],

89

},

90

},

91

];

92

```

93

94

#### All Rules Configuration

95

96

Enables all stylistic rules with their default settings.

97

98

```typescript { .api }

99

/**

100

* Configuration that enables all stylistic rules

101

* Recommended for comprehensive style enforcement

102

*/

103

declare const allConfig: Linter.Config;

104

```

105

106

**Usage Examples:**

107

108

```typescript

109

import stylistic from "@stylistic/eslint-plugin-ts";

110

111

// Enable all rules with defaults

112

export default [stylistic.configs.all];

113

114

// Combine with custom overrides

115

export default [

116

stylistic.configs.all,

117

{

118

rules: {

119

"@stylistic/ts/indent": ["error", 4], // Override default indent

120

"@stylistic/ts/quotes": "off", // Disable quotes rule

121

},

122

},

123

];

124

```

125

126

### Individual Rule Access

127

128

Direct access to specific rules for custom configurations.

129

130

```typescript { .api }

131

/**

132

* Access individual rules from the plugin

133

* Each rule is a standard ESLint Rule.RuleModule

134

*/

135

interface RuleAccess {

136

rules: {

137

[ruleName: string]: Rule.RuleModule;

138

};

139

}

140

```

141

142

**Usage Examples:**

143

144

```typescript

145

import stylistic from "@stylistic/eslint-plugin-ts";

146

import indentRule from "@stylistic/eslint-plugin-ts/rules/indent";

147

148

// Direct rule import

149

export default [

150

{

151

plugins: {

152

"@stylistic/ts": stylistic,

153

},

154

rules: {

155

"@stylistic/ts/indent": ["error", 2],

156

},

157

},

158

];

159

160

// Using directly imported rule

161

const customConfig = {

162

plugins: {

163

"custom-indent": indentRule,

164

},

165

rules: {

166

"custom-indent": ["error", 4],

167

},

168

};

169

```

170

171

## Configuration Examples

172

173

### Basic Setup

174

175

```typescript

176

import stylistic from "@stylistic/eslint-plugin-ts";

177

178

export default [

179

{

180

plugins: {

181

"@stylistic/ts": stylistic,

182

},

183

rules: {

184

// Spacing rules

185

"@stylistic/ts/block-spacing": "error",

186

"@stylistic/ts/comma-spacing": "error",

187

"@stylistic/ts/key-spacing": "error",

188

189

// Style rules

190

"@stylistic/ts/brace-style": ["error", "1tbs"],

191

"@stylistic/ts/indent": ["error", 2],

192

"@stylistic/ts/quotes": ["error", "single"],

193

"@stylistic/ts/semi": ["error", "always"],

194

},

195

},

196

];

197

```

198

199

### Migration from @typescript-eslint

200

201

```typescript

202

import stylistic from "@stylistic/eslint-plugin-ts";

203

204

export default [

205

// First disable legacy rules

206

stylistic.configs["disable-legacy"],

207

208

// Then configure stylistic rules

209

{

210

plugins: {

211

"@stylistic/ts": stylistic,

212

},

213

rules: {

214

"@stylistic/ts/member-delimiter-style": [

215

"error",

216

{

217

multiline: { delimiter: "semi" },

218

singleline: { delimiter: "semi" },

219

},

220

],

221

"@stylistic/ts/type-annotation-spacing": "error",

222

},

223

},

224

];

225

```

226

227

### Comprehensive Style Enforcement

228

229

```typescript

230

import stylistic from "@stylistic/eslint-plugin-ts";

231

232

export default [

233

// Start with all rules

234

stylistic.configs.all,

235

236

// Customize specific rules

237

{

238

rules: {

239

// Adjust indentation

240

"@stylistic/ts/indent": ["error", 4],

241

242

// Prefer single quotes

243

"@stylistic/ts/quotes": ["error", "single"],

244

245

// Require semicolons

246

"@stylistic/ts/semi": ["error", "always"],

247

248

// Configure member delimiters

249

"@stylistic/ts/member-delimiter-style": [

250

"error",

251

{

252

multiline: {

253

delimiter: "semi",

254

requireLast: true,

255

},

256

singleline: {

257

delimiter: "semi",

258

requireLast: false,

259

},

260

},

261

],

262

},

263

},

264

];

265

```