Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(eslint-plugin): add key-spacing rule extension for interface & type declarations #6211

Merged
merged 43 commits into from Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
eb02b4d
🚧 key-spacing for interface on default settings
coyotte508 Dec 14, 2022
6d78fe8
🚧 Support type literals as welll
coyotte508 Dec 14, 2022
259a3ca
🚧 Add full typing for the options
coyotte508 Dec 14, 2022
8f32b5d
🚧 Add 'mode' param
coyotte508 Dec 14, 2022
34bb6d8
🐛 Fix index signatures
coyotte508 Dec 15, 2022
ecaafa7
✨ Support classes
coyotte508 Dec 15, 2022
b17665b
🩹 fixes
coyotte508 Dec 15, 2022
18bb8ab
✅ Add tests on mode, multiLine, singleLine
coyotte508 Dec 15, 2022
4113478
🏷️ Allow options.multiline.align to be an object
coyotte508 Dec 15, 2022
5e951ba
🎨 Use ast utils to locate last character before token
coyotte508 Dec 15, 2022
b12c530
✨ Support comments in-between properties
coyotte508 Dec 15, 2022
729e642
✅ Add test cases for nested type declarations & multiline type annota…
coyotte508 Dec 15, 2022
d93c1a7
✨ Autofix for non-aligned values
coyotte508 Dec 15, 2022
ee519e3
✨ Autofix for aligned values
coyotte508 Dec 15, 2022
bc3b5d2
✏️
coyotte508 Dec 15, 2022
eebb18f
🚨
coyotte508 Dec 15, 2022
179aca2
🐛 Support optional ? token
coyotte508 Dec 15, 2022
db2d1bd
✅ Add tests with class property assignments
coyotte508 Dec 15, 2022
dbe502d
📝 Add documentation on key-spacing
coyotte508 Dec 15, 2022
8d5d3dd
🎨 Use .at() to access last element of array
coyotte508 Dec 15, 2022
af0a489
✅ Fix tests
coyotte508 Dec 15, 2022
c18b929
fixup! ✅ Fix tests
coyotte508 Dec 15, 2022
37eecdc
✅ Add some coverage
coyotte508 Dec 16, 2022
75ac325
Merge branch 'main' into key-spacing
coyotte508 Dec 16, 2022
1b62445
🐛 Fix edge case in determining aligned groups
coyotte508 Dec 16, 2022
4b0759c
⚡️ Use Array.concat instead of .push(...)
coyotte508 Dec 16, 2022
6d61144
🎨 Improve readability
coyotte508 Jan 24, 2023
47156ec
🎨 Use tempate literals in tests
coyotte508 Jan 24, 2023
ae33b9b
✅ Add test with anonymous types
coyotte508 Jan 24, 2023
722e092
✅ Add test with quoted keys
coyotte508 Jan 24, 2023
301731b
➕ Add grapheme-splitter to deal with emojis
coyotte508 Jan 24, 2023
9eaebb2
✅ Add test case for multiline comments
coyotte508 Jan 24, 2023
ee6d9bc
🚨 Remove 'in' statements, reduce amount of null-assertions
coyotte508 Jan 24, 2023
dbc6a91
✅ Add test case for properties without type annotation or assignments
coyotte508 Jan 24, 2023
b1033ef
✅ Add wacky test cases
coyotte508 Jan 24, 2023
a7a5b2c
✅ Add coverage
coyotte508 Jan 24, 2023
cb5876e
✅ Add coverage, again
coyotte508 Jan 24, 2023
2787762
✅ Add coverage, again
coyotte508 Jan 24, 2023
79d8ec0
✅ Add coverage when align is an object, but align.on is missing
coyotte508 Jan 24, 2023
2092487
KeyTypeNodeWithTypeAnnotation
JoshuaKGoldberg Jan 24, 2023
23036de
Merge branch 'main' into key-spacing
JoshuaKGoldberg Jan 24, 2023
e483407
Merge branch 'main' into key-spacing
JoshuaKGoldberg Jan 24, 2023
0184de9
Extract to shared helper
JoshuaKGoldberg Jan 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/eslint-plugin/docs/rules/key-spacing.md
@@ -0,0 +1,12 @@
---
description: 'Enforce consistent spacing between property names and type annotations in types and interfaces.'
---

> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/key-spacing** for documentation.

## Examples

This rule extends the base [`eslint/keyword-spacing`](https://eslint.org/docs/rules/key-spacing) rule.
This version adds support for type annotations on interfaces, classes and type literals properties.
1 change: 1 addition & 0 deletions packages/eslint-plugin/package.json
Expand Up @@ -49,6 +49,7 @@
"@typescript-eslint/utils": "5.46.1",
"debug": "^4.3.4",
"ignore": "^5.2.0",
"grapheme-splitter": "^1.0.4",
"natural-compare-lite": "^1.4.0",
"regexpp": "^3.2.0",
"semver": "^7.3.7",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/configs/all.ts
Expand Up @@ -37,6 +37,8 @@ export = {
'@typescript-eslint/indent': 'error',
'init-declarations': 'off',
'@typescript-eslint/init-declarations': 'error',
'key-spacing': 'off',
'@typescript-eslint/key-spacing': 'error',
'keyword-spacing': 'off',
'@typescript-eslint/keyword-spacing': 'error',
'lines-between-class-members': 'off',
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/src/rules/index.ts
Expand Up @@ -22,6 +22,7 @@ import explicitModuleBoundaryTypes from './explicit-module-boundary-types';
import funcCallSpacing from './func-call-spacing';
import indent from './indent';
import initDeclarations from './init-declarations';
import keySpacing from './key-spacing';
import keywordSpacing from './keyword-spacing';
import linesBetweenClassMembers from './lines-between-class-members';
import memberDelimiterStyle from './member-delimiter-style';
Expand Down Expand Up @@ -153,6 +154,7 @@ export default {
'func-call-spacing': funcCallSpacing,
indent: indent,
'init-declarations': initDeclarations,
'key-spacing': keySpacing,
'keyword-spacing': keywordSpacing,
'lines-between-class-members': linesBetweenClassMembers,
'member-delimiter-style': memberDelimiterStyle,
Expand Down