moz-fluent-linter 0.4.5__tar.gz → 0.4.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {moz-fluent-linter-0.4.5/src/moz_fluent_linter.egg-info → moz_fluent_linter-0.4.7}/PKG-INFO +5 -5
  2. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/README.md +1 -1
  3. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/setup.cfg +2 -2
  4. moz_fluent_linter-0.4.7/src/fluent_linter/__init__.py +1 -0
  5. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/src/fluent_linter/linter.py +35 -28
  6. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7/src/moz_fluent_linter.egg-info}/PKG-INFO +5 -5
  7. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/src/moz_fluent_linter.egg-info/SOURCES.txt +1 -1
  8. moz_fluent_linter-0.4.7/src/moz_fluent_linter.egg-info/requires.txt +3 -0
  9. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_brands.py +8 -3
  10. moz-fluent-linter-0.4.5/src/fluent_linter/__init__.py +0 -1
  11. moz-fluent-linter-0.4.5/src/moz_fluent_linter.egg-info/requires.txt +0 -3
  12. /moz-fluent-linter-0.4.5/LICENSE.md → /moz_fluent_linter-0.4.7/LICENSE +0 -0
  13. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/pyproject.toml +0 -0
  14. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/setup.py +0 -0
  15. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/src/moz_fluent_linter.egg-info/dependency_links.txt +0 -0
  16. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/src/moz_fluent_linter.egg-info/entry_points.txt +0 -0
  17. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/src/moz_fluent_linter.egg-info/top_level.txt +0 -0
  18. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_banned_words.py +0 -0
  19. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_comments.py +0 -0
  20. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_comments_variables.py +0 -0
  21. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_ids.py +0 -0
  22. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_placeable_style.py +0 -0
  23. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_syntax.py +0 -0
  24. {moz-fluent-linter-0.4.5 → moz_fluent_linter-0.4.7}/tests/test_typography.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: moz-fluent-linter
3
- Version: 0.4.5
3
+ Version: 0.4.7
4
4
  Summary: Linter package used to check Fluent files
5
5
  Home-page: https://github.com/mozilla-l10n/moz-fluent-linter
6
6
  Author: Francesco Lodolo
@@ -14,8 +14,8 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
14
  Classifier: Topic :: Software Development :: Localization
15
15
  Requires-Python: >=3.7
16
16
  Description-Content-Type: text/markdown
17
- License-File: LICENSE.md
18
- Requires-Dist: fluent.syntax<0.19,>=0.18.0
17
+ License-File: LICENSE
18
+ Requires-Dist: fluent.syntax~=0.19.0
19
19
  Requires-Dist: pyyaml
20
20
  Requires-Dist: six
21
21
 
@@ -41,7 +41,7 @@ Using [pre-commit](https://pre-commit.com/), add this to the `.pre-commit-config
41
41
  ```yaml
42
42
  repos:
43
43
  - repo: https://github.com/mozilla-l10n/moz-fluent-linter
44
- rev: v0.4.5
44
+ rev: v0.4.7
45
45
  hooks:
46
46
  - id: fluent_linter
47
47
  files: \.ftl$
@@ -20,7 +20,7 @@ Using [pre-commit](https://pre-commit.com/), add this to the `.pre-commit-config
20
20
  ```yaml
21
21
  repos:
22
22
  - repo: https://github.com/mozilla-l10n/moz-fluent-linter
23
- rev: v0.4.5
23
+ rev: v0.4.7
24
24
  hooks:
25
25
  - id: fluent_linter
26
26
  files: \.ftl$
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = moz-fluent-linter
3
- version = 0.4.5
3
+ version = 0.4.7
4
4
  author = Francesco Lodolo
5
5
  author_email = flod@mozilla.com
6
6
  description = Linter package used to check Fluent files
@@ -23,7 +23,7 @@ package_dir =
23
23
  packages = find:
24
24
  python_requires = >=3.7
25
25
  install_requires =
26
- fluent.syntax >=0.18.0, <0.19
26
+ fluent.syntax ~= 0.19.0
27
27
  pyyaml
28
28
  six
29
29
 
@@ -0,0 +1 @@
1
+ version = "0.4.7"
@@ -136,27 +136,51 @@ class Linter(visitor.Visitor):
136
136
  html_stripper.feed("".join(parts))
137
137
  cleaned_str = html_stripper.get_data()
138
138
 
139
+ message_id = node.id.name
140
+
141
+ # Check brand names here, so it's possible to also look for combination
142
+ # of text and terms.
143
+ if message_id is not None and not self.exclude_message(
144
+ "CO01", message_id, self.path
145
+ ):
146
+ found_brands = []
147
+ for brand in self.brand_names:
148
+ if brand == re.escape(brand):
149
+ brand_re = re.compile(r"\b" + brand + r"\b")
150
+ else:
151
+ brand_re = re.compile(brand)
152
+ if brand_re.search(cleaned_str):
153
+ found_brands.append(brand)
154
+ if found_brands:
155
+ self.add_error(
156
+ node,
157
+ message_id,
158
+ "CO01",
159
+ "Strings should use the corresponding terms instead of"
160
+ f" hard-coded brand names ({', '.join(found_brands)})",
161
+ )
162
+
139
163
  if self.apostrophe_re.search(cleaned_str):
140
- if not self.exclude_message("TE01", node.id.name):
164
+ if not self.exclude_message("TE01", message_id):
141
165
  self.add_error(
142
166
  node,
143
- node.id.name,
167
+ message_id,
144
168
  "TE01",
145
169
  "Strings with apostrophes should use foo\u2019s instead of foo's.",
146
170
  )
147
171
  if self.incorrect_apostrophe_re.search(cleaned_str):
148
- if not self.exclude_message("TE02", node.id.name):
172
+ if not self.exclude_message("TE02", message_id):
149
173
  self.add_error(
150
174
  node,
151
- node.id.name,
175
+ message_id,
152
176
  "TE02",
153
177
  "Strings with apostrophes should use foo\u2019s instead of foo\u2018s.",
154
178
  )
155
179
  if self.single_quote_re.search(cleaned_str):
156
- if not self.exclude_message("TE03", node.id.name):
180
+ if not self.exclude_message("TE03", message_id):
157
181
  self.add_error(
158
182
  node,
159
- node.id.name,
183
+ message_id,
160
184
  "TE03",
161
185
  "Single-quoted strings should use Unicode \u2018foo\u2019 instead of 'foo'.",
162
186
  )
@@ -166,19 +190,19 @@ class Linter(visitor.Visitor):
166
190
  cleaned_str = regex.sub("", cleaned_str)
167
191
 
168
192
  if self.double_quote_re.search(cleaned_str) and not self.exclude_message(
169
- "TE04", node.id.name
193
+ "TE04", message_id
170
194
  ):
171
195
  self.add_error(
172
196
  node,
173
- node.id.name,
197
+ message_id,
174
198
  "TE04",
175
199
  'Double-quoted strings should use Unicode \u201cfoo\u201d instead of "foo".',
176
200
  )
177
201
  if self.ellipsis_re.search(cleaned_str):
178
- if not self.exclude_message("TE05", node.id.name):
202
+ if not self.exclude_message("TE05", message_id):
179
203
  self.add_error(
180
204
  node,
181
- node.id.name,
205
+ message_id,
182
206
  "TE05",
183
207
  "Strings with an ellipsis should use the Unicode \u2026 character"
184
208
  " instead of three periods",
@@ -298,25 +322,8 @@ class Linter(visitor.Visitor):
298
322
  html_stripper.feed(node.value)
299
323
  cleaned_str = html_stripper.get_data()
300
324
 
301
- # If part of a message, check for brand and banned words
325
+ # If part of a message, check for banned words
302
326
  message_id = self.last_message_id
303
- if message_id is not None and not self.exclude_message(
304
- "CO01", message_id, self.path
305
- ):
306
- found_brands = []
307
- for brand in self.brand_names:
308
- brand_re = re.compile(r"\b" + brand + r"\b")
309
- if brand_re.search(cleaned_str):
310
- found_brands.append(brand)
311
- if found_brands:
312
- self.add_error(
313
- node,
314
- message_id,
315
- "CO01",
316
- "Strings should use the corresponding terms instead of"
317
- f" hard-coded brand names ({', '.join(found_brands)})",
318
- )
319
-
320
327
  if message_id is not None and not self.exclude_message(
321
328
  "CO02", message_id, self.path
322
329
  ):
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: moz-fluent-linter
3
- Version: 0.4.5
3
+ Version: 0.4.7
4
4
  Summary: Linter package used to check Fluent files
5
5
  Home-page: https://github.com/mozilla-l10n/moz-fluent-linter
6
6
  Author: Francesco Lodolo
@@ -14,8 +14,8 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
14
  Classifier: Topic :: Software Development :: Localization
15
15
  Requires-Python: >=3.7
16
16
  Description-Content-Type: text/markdown
17
- License-File: LICENSE.md
18
- Requires-Dist: fluent.syntax<0.19,>=0.18.0
17
+ License-File: LICENSE
18
+ Requires-Dist: fluent.syntax~=0.19.0
19
19
  Requires-Dist: pyyaml
20
20
  Requires-Dist: six
21
21
 
@@ -41,7 +41,7 @@ Using [pre-commit](https://pre-commit.com/), add this to the `.pre-commit-config
41
41
  ```yaml
42
42
  repos:
43
43
  - repo: https://github.com/mozilla-l10n/moz-fluent-linter
44
- rev: v0.4.5
44
+ rev: v0.4.7
45
45
  hooks:
46
46
  - id: fluent_linter
47
47
  files: \.ftl$
@@ -1,4 +1,4 @@
1
- LICENSE.md
1
+ LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
4
  setup.cfg
@@ -0,0 +1,3 @@
1
+ fluent.syntax~=0.19.0
2
+ pyyaml
3
+ six
@@ -36,6 +36,10 @@ good-mozilla2 = Welcome to { mozilla-message }
36
36
  bad-monitor = Monitor your email
37
37
  good-monitor = Monitored emails
38
38
  good-monitor2 = Set up your monitor.
39
+
40
+ bad-account = Set up your { -brand-short-name } account
41
+ good-account = Set up your { -brand-short-name }. Account.
42
+ good-account2 = Set up your { -brand-short-name } Account.
39
43
  """
40
44
 
41
45
  config = {
@@ -49,19 +53,20 @@ good-monitor2 = Set up your monitor.
49
53
  config = {
50
54
  "CO01": {
51
55
  "enabled": True,
52
- "brands": ["Firefox", "Mozilla"],
56
+ "brands": ["Firefox", "Mozilla", "{ -brand-short-name } account"],
53
57
  "exclusions": {
54
58
  "messages": ["bad-firefox-excluded"],
55
59
  },
56
60
  }
57
61
  }
58
62
  results = self.checkContent(config, content)
59
- self.assertEqual(len(results), 8)
63
+ self.assertEqual(len(results), 9)
60
64
  self.assertTrue("CO01" in results[0])
61
65
  self.assertTrue("Firefox" in results[0])
62
- self.assertTrue("line 5" in results[1])
66
+ self.assertTrue("line 4" in results[1])
63
67
  self.assertTrue("bad-firefox2" in results[1])
64
68
  self.assertTrue("Mozilla" in results[5])
69
+ self.assertTrue("{ -brand-short-name } account" in results[8])
65
70
 
66
71
  config = {
67
72
  "CO01": {
@@ -1 +0,0 @@
1
- version = "0.4.5"
@@ -1,3 +0,0 @@
1
- fluent.syntax<0.19,>=0.18.0
2
- pyyaml
3
- six