123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
- /**
- * @fileoverview Detect unmarked translatable strings
- * @author Martin Gruner
- */
- //------------------------------------------------------------------------------
- // Requirements
- //------------------------------------------------------------------------------
- /* eslint-disable @typescript-eslint/no-require-imports */
- const { RuleTester } = require('eslint')
- const rule = require('../../../lib/rules/zammad-detect-translatable-string.js')
- /* eslint-enable @typescript-eslint/no-require-imports */
- //------------------------------------------------------------------------------
- // Tests
- //------------------------------------------------------------------------------
- const ruleTester = new RuleTester()
- ruleTester.run('zammad-detect-translatable-string', rule, {
- valid: [
- {
- filename: 'test.ts',
- code: `'OnlyOneWord'`,
- },
- {
- filename: 'test.ts',
- code: `'starts with lower case'`,
- },
- {
- filename: 'test.ts',
- code: `if (variable === 'Some test string') true`,
- },
- {
- filename: 'test.ts',
- code: `__('Already marked message.')`,
- },
- {
- filename: 'test.ts',
- code: `i18n.t('Already translated string.')`,
- },
- {
- filename: 'test.ts',
- code: `console.log('Some debug message.')`,
- },
- {
- filename: 'test.ts',
- // eslint-disable-next-line no-template-curly-in-string
- code: '"String with ${interpolation}..."', // Not fully correct, but a ``-template string does not seem to work.
- },
- ],
- invalid: [
- {
- filename: 'test.js',
- code: `'String that should be translatable'`,
- errors: [
- {
- message:
- 'This string looks like it should be marked as translatable via __(...)',
- },
- ],
- output: `__('String that should be translatable')`,
- },
- ],
- })
|