Skip to content

Commit

Permalink
chore: Add doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
naipaka committed Jul 27, 2024
1 parent 6f321cb commit 5f01f30
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions packages/altive_lints/lib/src/lints/avoid_hardcoded_japanese.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';

/// An `avoid_hardcoded_japanese` rule which detects
/// and reports hardcoded Japanese text strings within the code.
///
/// This rule ensures that all user-facing text is
/// properly internationalized to support Japanese localization efforts.
///
/// ### Example
///
/// #### BAD:
///
/// ```dart
/// final message = 'こんにちは'; // LINT
/// print('エラーが発生しました'); // LINT
/// ```
///
/// #### GOOD:
///
/// ```dart
/// final message = AppLocalizations.of(context).hello;
/// print(AppLocalizations.of(context).errorOccurred);
/// ```
///
class AvoidHardcodedJapanese extends DartLintRule {
const AvoidHardcodedJapanese() : super(code: _code);

Expand Down Expand Up @@ -35,8 +57,8 @@ class AvoidHardcodedJapanese extends DartLintRule {
});
}

// Checks if the string contains Japanese characters
// (Hiragana, Katakana, Kanji).
/// Checks if the string contains Japanese characters
/// (Hiragana, Katakana, Kanji).
bool isJapanese(String value) =>
RegExp(r'[\u3040-\u309F\u30A0-\u30FF\u4E00-\u9FD0]').hasMatch(value);
}

0 comments on commit 5f01f30

Please sign in to comment.