Skip to content

Commit 7c15bae

Browse files
committed
fix: also apply stylistic config within typescript
1 parent 0fed316 commit 7c15bae

File tree

2 files changed

+50
-43
lines changed

2 files changed

+50
-43
lines changed

configs/base.js

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,52 @@ export const importConfig = [
103103
},
104104
];
105105

106+
/** @type {Linter.Config[]} */
107+
export const stylisticConfig = [
108+
{
109+
plugins: {
110+
'@stylistic': stylistic,
111+
},
112+
rules: {
113+
'@stylistic/max-len': [
114+
'warn',
115+
{
116+
code: 120,
117+
tabWidth: 2,
118+
ignoreComments: true,
119+
ignoreTrailingComments: true,
120+
ignoreUrls: true,
121+
ignoreStrings: true,
122+
ignoreTemplateLiterals: true,
123+
ignoreRegExpLiterals: true,
124+
},
125+
],
126+
'@stylistic/indent': ['error', 'tab', {
127+
SwitchCase: 1,
128+
tabLength: 2,
129+
flatTernaryExpressions: true,
130+
offsetTernaryExpressions: true,
131+
}],
132+
'@stylistic/indent-binary-ops': ['error', 'tab'],
133+
134+
'@stylistic/quotes': ['error', 'single', {
135+
avoidEscape: true,
136+
}],
137+
'@stylistic/function-paren-newline': ['error', 'consistent'],
138+
'@stylistic/arrow-parens': ['error', 'as-needed', {requireForBlockBody: true}],
139+
'@stylistic/operator-linebreak': ['error', 'after'],
140+
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
141+
'@stylistic/no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
142+
'@stylistic/object-curly-newline': ['error', {
143+
ObjectExpression: {multiline: true, consistent: true},
144+
ObjectPattern: {multiline: true, consistent: true},
145+
ImportDeclaration: {multiline: true, consistent: true},
146+
ExportDeclaration: {multiline: true, consistent: true},
147+
}],
148+
},
149+
},
150+
];
151+
106152
/** @type {Linter.Config[]} */
107153
const baseConfig = [
108154
js.configs.recommended,
@@ -264,48 +310,7 @@ const baseConfig = [
264310
},
265311
},
266312

267-
{
268-
plugins: {
269-
'@stylistic': stylistic,
270-
},
271-
rules: {
272-
'@stylistic/max-len': [
273-
'warn',
274-
{
275-
code: 120,
276-
tabWidth: 2,
277-
ignoreComments: true,
278-
ignoreTrailingComments: true,
279-
ignoreUrls: true,
280-
ignoreStrings: true,
281-
ignoreTemplateLiterals: true,
282-
ignoreRegExpLiterals: true,
283-
},
284-
],
285-
'@stylistic/indent': ['error', 'tab', {
286-
SwitchCase: 1,
287-
tabLength: 2,
288-
flatTernaryExpressions: true,
289-
offsetTernaryExpressions: true,
290-
}],
291-
'@stylistic/indent-binary-ops': ['error', 'tab'],
292-
293-
'@stylistic/quotes': ['error', 'single', {
294-
avoidEscape: true,
295-
}],
296-
'@stylistic/function-paren-newline': ['error', 'consistent'],
297-
'@stylistic/arrow-parens': ['error', 'as-needed', {requireForBlockBody: true}],
298-
'@stylistic/operator-linebreak': ['error', 'after'],
299-
'@stylistic/multiline-ternary': ['error', 'always-multiline'],
300-
'@stylistic/no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
301-
'@stylistic/object-curly-newline': ['error', {
302-
ObjectExpression: {multiline: true, consistent: true},
303-
ObjectPattern: {multiline: true, consistent: true},
304-
ImportDeclaration: {multiline: true, consistent: true},
305-
ExportDeclaration: {multiline: true, consistent: true},
306-
}],
307-
},
308-
},
313+
...stylisticConfig,
309314
];
310315

311316
export default setFilesIfUndef(baseConfig, ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}']);

configs/typescript.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import xoTypescript from 'eslint-config-xo-typescript';
22
import importPlugin from 'eslint-plugin-import';
3-
import {importConfig} from './base.js';
3+
import {importConfig, stylisticConfig} from './base.js';
44
import {setFilesIfUndef} from './util.js';
55

66
/** @var {Linter.Config[]} */
@@ -87,5 +87,7 @@ const typescriptConfig = [
8787
'function-call-argument-newline': 'off',
8888
},
8989
},
90+
91+
...stylisticConfig,
9092
];
9193
export default setFilesIfUndef(typescriptConfig, ['**/*.{ts,mts,cts,tsx}']);

0 commit comments

Comments
 (0)