moz-fluent-linter 0.4.4__tar.gz → 0.4.6__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.
- {moz-fluent-linter-0.4.4/src/moz_fluent_linter.egg-info → moz_fluent_linter-0.4.6}/PKG-INFO +3 -3
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/README.md +1 -1
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/setup.cfg +1 -1
- moz_fluent_linter-0.4.6/src/fluent_linter/__init__.py +1 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/fluent_linter/linter.py +36 -29
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6/src/moz_fluent_linter.egg-info}/PKG-INFO +3 -3
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/SOURCES.txt +1 -1
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_brands.py +8 -3
- moz-fluent-linter-0.4.4/src/fluent_linter/__init__.py +0 -1
- /moz-fluent-linter-0.4.4/LICENSE.md → /moz_fluent_linter-0.4.6/LICENSE +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/pyproject.toml +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/setup.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/dependency_links.txt +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/entry_points.txt +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/requires.txt +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/top_level.txt +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_banned_words.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_comments.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_comments_variables.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_ids.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_placeable_style.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_syntax.py +0 -0
- {moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/tests/test_typography.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: moz-fluent-linter
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.6
|
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,7 +14,7 @@ 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
|
17
|
+
License-File: LICENSE
|
18
18
|
Requires-Dist: fluent.syntax<0.19,>=0.18.0
|
19
19
|
Requires-Dist: pyyaml
|
20
20
|
Requires-Dist: six
|
@@ -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.
|
44
|
+
rev: v0.4.6
|
45
45
|
hooks:
|
46
46
|
- id: fluent_linter
|
47
47
|
files: \.ftl$
|
@@ -0,0 +1 @@
|
|
1
|
+
version = "0.4.6"
|
@@ -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",
|
164
|
+
if not self.exclude_message("TE01", message_id):
|
141
165
|
self.add_error(
|
142
166
|
node,
|
143
|
-
|
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",
|
172
|
+
if not self.exclude_message("TE02", message_id):
|
149
173
|
self.add_error(
|
150
174
|
node,
|
151
|
-
|
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",
|
180
|
+
if not self.exclude_message("TE03", message_id):
|
157
181
|
self.add_error(
|
158
182
|
node,
|
159
|
-
|
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",
|
193
|
+
"TE04", message_id
|
170
194
|
):
|
171
195
|
self.add_error(
|
172
196
|
node,
|
173
|
-
|
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",
|
202
|
+
if not self.exclude_message("TE05", message_id):
|
179
203
|
self.add_error(
|
180
204
|
node,
|
181
|
-
|
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
|
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
|
):
|
@@ -534,7 +541,7 @@ class Linter(visitor.Visitor):
|
|
534
541
|
def add_error(self, node, message_id, rule, msg):
|
535
542
|
(col, line) = self.span_to_line_and_col(node.span)
|
536
543
|
|
537
|
-
file_path = os.path.relpath(self.path
|
544
|
+
file_path = os.path.relpath(self.path)
|
538
545
|
message_id = message_id if message_id is not None else "-"
|
539
546
|
error_msg = f"""
|
540
547
|
File path: {file_path}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: moz-fluent-linter
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.6
|
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,7 +14,7 @@ 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
|
17
|
+
License-File: LICENSE
|
18
18
|
Requires-Dist: fluent.syntax<0.19,>=0.18.0
|
19
19
|
Requires-Dist: pyyaml
|
20
20
|
Requires-Dist: six
|
@@ -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.
|
44
|
+
rev: v0.4.6
|
45
45
|
hooks:
|
46
46
|
- id: fluent_linter
|
47
47
|
files: \.ftl$
|
@@ -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),
|
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
|
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.4"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/entry_points.txt
RENAMED
File without changes
|
{moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/requires.txt
RENAMED
File without changes
|
{moz-fluent-linter-0.4.4 → moz_fluent_linter-0.4.6}/src/moz_fluent_linter.egg-info/top_level.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|