Skip to content

Commit 02b3955

Browse files
Merge pull request #4164 from digitalfabrik/4045-linting
4045: Add linting rule for consistent naming
2 parents f8239fb + 503d1ba commit 02b3955

67 files changed

Lines changed: 235 additions & 197 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-configs/TypographyType.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,7 @@ type FontStyleOptions = Partial<FontStyle> & {
3131
}
3232

3333
type NormalCssProperties = CSS.Properties<number | string>
34-
type Fontface = CSS.AtRule.FontFace & {
35-
fallbacks?: CSS.AtRule.FontFace[]
36-
}
37-
type BaseCSSProperties = NormalCssProperties & {
38-
'@font-face'?: Fontface | Fontface[]
39-
}
40-
type CSSProperties = BaseCSSProperties & {
34+
type CSSProperties = NormalCssProperties & {
4135
// Allow pseudo selectors and media queries
4236
// `unknown` is used since TS does not allow assigning an interface without
4337
// an index signature to one with an index signature. This is to allow type safe

e2e-tests/native/test/helpers/Selector.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export class Selector {
22
private queries: string[] = new Array<string>()
33

4-
public ByText(text: string): Selector {
4+
public byText(text: string): Selector {
55
if (driver.isAndroid) {
66
this.queries.push(`.text("${text}")`)
77
} else {
@@ -10,7 +10,7 @@ export class Selector {
1010
return this
1111
}
1212

13-
public ByBeginsWith(text: string): Selector {
13+
public byBeginsWith(text: string): Selector {
1414
if (driver.isAndroid) {
1515
this.queries.push(`.textStartsWith("${text}")`)
1616
} else {
@@ -19,7 +19,7 @@ export class Selector {
1919
return this
2020
}
2121

22-
public ByContainedText(text: string): Selector {
22+
public byContainedText(text: string): Selector {
2323
if (driver.isAndroid) {
2424
this.queries.push(`.textContains("${text}")`)
2525
} else {

e2e-tests/native/test/pageobjects/regions.page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RegionsPage extends Page {
1818
}
1919

2020
region(name: string) {
21-
const selector = $(new Selector().ByText(name).build())
21+
const selector = $(new Selector().byText(name).build())
2222
return Gestures.checkIfDisplayedWithSwipeUp(selector, MAX_SCROLLS)
2323
}
2424
}

e2e-tests/native/test/specs/changeLanguage.e2e.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ describe('change language', () => {
1010
})
1111

1212
it('should change language', async () => {
13-
const englishContent = $(new Selector().ByText('Welcome').build())
13+
const englishContent = $(new Selector().byText('Welcome').build())
1414
await englishContent.waitForDisplayed()
1515

1616
await dashboardPage.languageIcon.click()
1717

18-
await $(new Selector().ByText('Deutsch').build()).click()
18+
await $(new Selector().byText('Deutsch').build()).click()
1919

2020
await (
21-
await $(new Selector().ByContainedText('Loading').build())
21+
await $(new Selector().byContainedText('Loading').build())
2222
).waitForDisplayed({ timeout: 30000, interval: 2000, reverse: true })
2323

24-
await $(new Selector().ByText('Willkommen').build()).waitForDisplayed()
24+
await $(new Selector().byText('Willkommen').build()).waitForDisplayed()
2525
})
2626
})

e2e-tests/native/test/specs/navigateToLeafCategory.e2e.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ describe('navigate to leaf category', () => {
55
it('should open leaf category', async () => {
66
await navigateToDashboard()
77

8-
const firstLevelCategory = $(new Selector().ByText('Language').build())
8+
const firstLevelCategory = $(new Selector().byText('Language').build())
99
await firstLevelCategory.waitForDisplayed()
1010
await firstLevelCategory.click()
1111

12-
const secondLevelCategory = $(new Selector().ByText('Language courses').build())
12+
const secondLevelCategory = $(new Selector().byText('Language courses').build())
1313
await secondLevelCategory.waitForDisplayed()
1414
await secondLevelCategory.click()
1515

16-
const leafCategory = $(new Selector().ByText('Integration Courses').build())
16+
const leafCategory = $(new Selector().byText('Integration Courses').build())
1717
await leafCategory.waitForDisplayed()
1818
await leafCategory.click()
1919

20-
const leafCategoryContent = $(new Selector().ByContainedText('you will learn German').build())
20+
const leafCategoryContent = $(new Selector().byContainedText('you will learn German').build())
2121
await leafCategoryContent.waitForDisplayed({ timeout: 20000 })
2222
expect(await leafCategoryContent.isDisplayed()).toBeTruthy()
2323
})

e2e-tests/native/test/specs/navigateToOtherLocation.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('navigate to other location', () => {
3232
it('should open a new region on location change', async () => {
3333
await DashboardPage.headerOverflowButton.waitForDisplayed({ timeout: 20000 })
3434
await DashboardPage.headerOverflowButton.click()
35-
const changeLocation = $(new Selector().ByText('Change location').build())
35+
const changeLocation = $(new Selector().byText('Change location').build())
3636
await changeLocation.waitForDisplayed()
3737
await changeLocation.click()
3838

@@ -46,6 +46,6 @@ describe('navigate to other location', () => {
4646
await browser.waitUntil(async () => $(`~Dashboard-Page`).isDisplayed(), { timeout: 20000 })
4747
await DashboardPage.get()
4848

49-
await $(new Selector().ByText('Augsburg (Stadt)').build()).waitForDisplayed()
49+
await $(new Selector().byText('Augsburg (Stadt)').build()).waitForDisplayed()
5050
})
5151
})

e2e-tests/native/test/specs/navigateToSearchResult.e2e.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ describe('navigate to search result', () => {
1414
const searchBar = await SearchPage.search
1515
await searchBar.addValue(contentSearch)
1616

17-
const searchResult = $(new Selector().ByBeginsWith('Language').build())
17+
const searchResult = $(new Selector().byBeginsWith('Language').build())
1818
await searchResult.waitForDisplayed({ timeout: 20000 })
1919
await searchResult.click()
2020

21-
await $(new Selector().ByText('Language courses').build()).waitForDisplayed()
21+
await $(new Selector().byText('Language courses').build()).waitForDisplayed()
2222
})
2323
})

eslint.config.mjs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,43 @@ export default defineConfig([
138138
'@typescript-eslint/ban-ts-comment': 'error',
139139
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
140140
'@typescript-eslint/explicit-module-boundary-types': 'error',
141+
142+
'@typescript-eslint/naming-convention': [
143+
'error',
144+
{
145+
selector: 'default',
146+
format: ['camelCase'],
147+
leadingUnderscore: 'allowSingleOrDouble',
148+
trailingUnderscore: 'allowSingleOrDouble',
149+
filter: {
150+
regex: '^(_|Component)$',
151+
match: false,
152+
},
153+
},
154+
{
155+
selector: 'import',
156+
format: ['camelCase', 'PascalCase'],
157+
},
158+
{
159+
selector: 'variable',
160+
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
161+
leadingUnderscore: 'allow',
162+
trailingUnderscore: 'allow',
163+
},
164+
{
165+
selector: ['typeLike', 'enumMember'],
166+
format: ['PascalCase'],
167+
},
168+
{
169+
selector: 'typeProperty',
170+
format: ['camelCase', 'snake_case', 'PascalCase'],
171+
},
172+
{
173+
selector: ['objectLiteralProperty', 'objectLiteralMethod'],
174+
format: null,
175+
},
176+
],
177+
141178
'@typescript-eslint/no-empty-function': 'error',
142179
'@typescript-eslint/no-explicit-any': 'error',
143180
'@typescript-eslint/no-unnecessary-condition': 'error',

native/src/BottomTabNavigator.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const BottomTabNavigator = ({ navigation }: BottomTabNavigatorProps): ReactEleme
116116
const CategoriesIcon = useCallback(
117117
// eslint-disable-next-line react/no-unused-prop-types
118118
({ focused }: { focused: boolean }) => (
119-
<Icon Icon={SignPostIcon} color={focused ? theme.colors.onSurface : theme.colors.onSurfaceVariant} />
119+
<Icon icon={SignPostIcon} color={focused ? theme.colors.onSurface : theme.colors.onSurfaceVariant} />
120120
),
121121
[theme],
122122
)

native/src/components/Categories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ const Categories = ({
5959
content={category.content}
6060
lastUpdate={category.lastUpdate}
6161
language={language}
62-
AfterContent={category.organization && <OrganizationContentInfo organization={category.organization} />}
63-
Footer={
62+
afterContent={category.organization && <OrganizationContentInfo organization={category.organization} />}
63+
footer={
6464
children.length ? (
6565
<List
6666
items={children}

0 commit comments

Comments
 (0)