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 #5436

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

developers-mylermedia
Copy link

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.

@SwiftLintBot
Copy link

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:47: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:137: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:46: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:311:13: 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:26: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:33: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.92s vs 1.18s on main (62% slower)
📖 Linting Alamofire with this PR took 1.65s vs 1.63s on main (1% slower)
📖 Linting Brave with this PR took 9.36s vs 7.7s on main (21% slower)
📖 Linting DuckDuckGo with this PR took 5.0s vs 5.0s on main (0% slower)
📖 Linting Firefox with this PR took 11.11s vs 11.11s on main (0% slower)
📖 Linting Kickstarter with this PR took 11.27s vs 11.2s on main (0% slower)
📖 Linting Moya with this PR took 0.63s vs 0.62s on main (1% slower)
📖 Linting NetNewsWire with this PR took 3.35s vs 3.33s on main (0% slower)
📖 Linting Nimble with this PR took 0.92s vs 0.91s on main (1% slower)
📖 Linting PocketCasts with this PR took 9.03s vs 9.02s on main (0% slower)
📖 Linting Quick with this PR took 0.42s vs 0.4s on main (4% slower)
📖 Linting Realm with this PR took 5.76s vs 5.75s on main (0% slower)
📖 Linting Sourcery with this PR took 2.76s vs 2.77s on main (0% faster)
📖 Linting Swift with this PR took 5.61s vs 5.58s on main (0% slower)
📖 Linting VLC with this PR took 1.58s vs 1.59s on main (0% faster)
📖 Linting Wire with this PR took 20.23s vs 20.23s on main (0% slower)
📖 Linting WordPress with this PR took 13.41s vs 13.42s on main (0% faster)

Generated by 🚫 Danger

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