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

Add Accessibility Font Size Rule #5398

Conversation

MartijnAmbagtsheer
Copy link

@MartijnAmbagtsheer MartijnAmbagtsheer commented Dec 18, 2023

The text below has been taken from the rule request template.

1. Why should this rule be added? Share links to existing discussion about what the community thinks about this.
The increasing focus on accessibility in both America through the ADA (Americans with Disabilities Act) and the upcoming European legislation underscores the growing importance of accessible applications. To assist in this effort, we can identify existing inaccessible elements using tools such as SwiftLint, among others.

There are already two rules for testing the accessibility of images and buttons. With this new rule, I aim to align with the WCAG (Web Content Accessibility Guidelines) 1.4.4. This guideline stipulates that every text must be scalable.

2. Provide several examples of what would and wouldn't trigger violations.
Insofar as I have been able to find, SwiftUI inherently scales well on its own, but this can be forcibly disabled using the .font(.system()) modifier.

struct TestView: View {
	var body: some View {
		Text("Hello World!")
			.font(.system(size: 20))
	}
}

Using the default Text, without the .font(.system(size:)) modifier would work and not trigger the linter.

struct TestView: View {
	var body: some View {
		Text("Hello World!")
	}
}

This also applies to other view elements like a Button, TextField or SecureField.

3. Should the rule be configurable, if so what parameters should be configurable?
For this rule, no additional configuration is required.

4. Should the rule be opt-in or enabled by default? Why?
See README.md for guidelines on when to mark a rule as opt-in.

As stated in the rules in the README, this rule complies with the guidelines to be opt-in, as the rule, like the other accessibility rules, is opt-in due to potential false positives given the many possibilities to set up a view within SwiftUI.

@MartijnAmbagtsheer MartijnAmbagtsheer force-pushed the martijnambagtsheer/AccessibilityFontSizeRule branch from 2f69669 to 5c56216 Compare December 20, 2023 09:49
@SwiftLintBot
Copy link

SwiftLintBot commented Dec 20, 2023

64 Warnings
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/FavoritesWidget.swift:147:19: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/LockScreenFavoriteWidget.swift:102:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/LockScreenFavoriteWidget.swift:85:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/LockScreenShortcutWidget.swift:64:7: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/ShortcutsWidget.swift:93:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/ShortcutsWidget.swift:97:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/SingleStatWidget.swift:65:7: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/SingleStatWidget.swift:68:7: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/StatsWidget.swift:64:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/StatsWidget.swift:80:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/StatsWidget.swift:86:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsListWidget.swift:107:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsListWidget.swift:111:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsListWidget.swift:139:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsListWidget.swift:80:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsListWidget.swift:86:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:127:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:133:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:140:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:161:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:192:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:198:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /App/BraveWidgets/TopNewsWidget.swift:232:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/Brave/Frontend/Shields/SubmitReportSuccessView.swift:15:7: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/AssetIconView.swift:35:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/CryptoTabsView.swift:134:11: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/Market/MarketView.swift:72:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/NFT/NFTDetailView.swift:64:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/NFT/NFTView.swift:205:15: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/Crypto/NFTImageView.swift:82:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/BraveWallet/NetworkIcon.swift:45:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Brave: /Sources/Onboarding/Callouts/OnboardingPlaylistView.swift:70:5: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:280:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:298:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:352:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:358:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:375:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /DuckDuckGo/VPNWaitlistView.swift:383:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /LocalPackages/SyncUI/Sources/SyncUI/Views/SyncSettingsViewExtension.swift:314:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /LocalPackages/Waitlist/Sources/Waitlist/Views/InviteCodeView.swift:40:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/VPNWidget.swift:163:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/VPNWidget.swift:168:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/VPNWidget.swift:176:25: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/VPNWidget.swift:188:25: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/WidgetViews.swift:186:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/WidgetViews.swift:194:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in DuckDuckGo: /Widgets/WidgetViews.swift:58:29: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Firefox: /firefox-ios/WidgetKit/OpenTabs/OpenTabsWidget.swift:100:29: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Firefox: /firefox-ios/WidgetKit/OpenTabs/OpenTabsWidget.swift:44:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Firefox: /firefox-ios/WidgetKit/OpenTabs/OpenTabsWidget.swift:62:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in Firefox: /firefox-ios/WidgetKit/OpenTabs/OpenTabsWidget.swift:85:25: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Free to Paid Plans/DashboardDomainsCardSearchView.swift:12:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Free to Paid Plans/DashboardDomainsCardSearchView.swift:9:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsRelatedPostsView.swift:60:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsRelatedPostsView.swift:83:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Site Settings/SiteSettingsRelatedPostsView.swift:86:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Domains/Views/ShapeWithTextView.swift:24:9: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Me/App Settings/DebugMenuViewController.swift:132:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/NUX/ContentViews/Editor/UnifiedPrologueEditorContentView.swift:13:25: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/NUX/ContentViews/Editor/UnifiedPrologueEditorContentView.swift:28:21: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/JetpackStatsWidgets/LockScreenWidgets/Views/LockScreenFieldView.swift:27:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/JetpackStatsWidgets/LockScreenWidgets/Views/LockScreenFieldView.swift:34:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/JetpackStatsWidgets/LockScreenWidgets/Views/LockScreenSiteTitleView.swift:11:13: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
⚠️ This PR introduced a violation in WordPress: /WordPress/JetpackStatsWidgets/LockScreenWidgets/Views/LockScreenUnconfiguredView.swift:12:17: warning: Accessibility Font Size Violation: Fonts may not have a fixed size (accessibility_font_size)
17 Messages
📖 Linting Aerial with this PR took 1.16s vs 1.17s on main (0% faster)
📖 Linting Alamofire with this PR took 1.61s vs 1.61s on main (0% slower)
📖 Linting Brave with this PR took 9.16s vs 9.15s on main (0% slower)
📖 Linting DuckDuckGo with this PR took 4.91s vs 4.93s on main (0% faster)
📖 Linting Firefox with this PR took 10.91s vs 10.98s on main (0% faster)
📖 Linting Kickstarter with this PR took 11.13s vs 11.16s on main (0% faster)
📖 Linting Moya with this PR took 0.63s vs 0.62s on main (1% slower)
📖 Linting NetNewsWire with this PR took 3.28s vs 3.28s on main (0% slower)
📖 Linting Nimble with this PR took 0.89s vs 0.89s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.9s vs 8.97s on main (0% faster)
📖 Linting Quick with this PR took 0.39s vs 0.4s on main (2% faster)
📖 Linting Realm with this PR took 5.71s vs 5.69s on main (0% slower)
📖 Linting Sourcery with this PR took 2.84s vs 2.86s on main (0% faster)
📖 Linting Swift with this PR took 5.38s vs 5.38s on main (0% slower)
📖 Linting VLC with this PR took 1.58s vs 1.58s on main (0% slower)
📖 Linting Wire with this PR took 19.81s vs 19.86s on main (0% faster)
📖 Linting WordPress with this PR took 10.9s vs 13.36s on main (18% faster)

Generated by 🚫 Danger

@MartijnAmbagtsheer MartijnAmbagtsheer marked this pull request as ready for review December 20, 2023 10:21
@MartijnAmbagtsheer
Copy link
Author

The ownership of the code has been modified. A new PR can be found here: #5436

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants