moz-fluent-linter 0.4.7__py3-none-any.whl → 0.4.8__py3-none-any.whl
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.
- fluent_linter/__init__.py +1 -1
- fluent_linter/linter.py +57 -39
- {moz_fluent_linter-0.4.7.dist-info → moz_fluent_linter-0.4.8.dist-info}/METADATA +4 -3
- moz_fluent_linter-0.4.8.dist-info/RECORD +8 -0
- {moz_fluent_linter-0.4.7.dist-info → moz_fluent_linter-0.4.8.dist-info}/WHEEL +1 -1
- moz_fluent_linter-0.4.7.dist-info/RECORD +0 -8
- {moz_fluent_linter-0.4.7.dist-info → moz_fluent_linter-0.4.8.dist-info}/entry_points.txt +0 -0
- {moz_fluent_linter-0.4.7.dist-info → moz_fluent_linter-0.4.8.dist-info/licenses}/LICENSE +0 -0
- {moz_fluent_linter-0.4.7.dist-info → moz_fluent_linter-0.4.8.dist-info}/top_level.txt +0 -0
fluent_linter/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = "0.4.
|
1
|
+
version = "0.4.8"
|
fluent_linter/linter.py
CHANGED
@@ -5,15 +5,19 @@
|
|
5
5
|
# This script is largely based on the Fluent Linter used in mozilla-central
|
6
6
|
# https://firefox-source-docs.mozilla.org/code-quality/lint/linters/fluent-lint.html
|
7
7
|
|
8
|
-
from fluent.syntax import ast, parse, serializer, visitor
|
9
|
-
from html.parser import HTMLParser
|
10
8
|
import argparse
|
11
9
|
import bisect
|
12
10
|
import os
|
13
11
|
import re
|
14
12
|
import sys
|
13
|
+
|
14
|
+
from html.parser import HTMLParser
|
15
|
+
|
15
16
|
import yaml
|
16
17
|
|
18
|
+
from fluent.syntax import ast, parse, serializer, visitor
|
19
|
+
|
20
|
+
|
17
21
|
try:
|
18
22
|
from fluent_linter import version
|
19
23
|
except Exception:
|
@@ -160,31 +164,42 @@ class Linter(visitor.Visitor):
|
|
160
164
|
f" hard-coded brand names ({', '.join(found_brands)})",
|
161
165
|
)
|
162
166
|
|
163
|
-
if
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
167
|
+
if (
|
168
|
+
self.config.get("TE01", {}).get("enabled", True)
|
169
|
+
and self.apostrophe_re.search(cleaned_str)
|
170
|
+
and not self.exclude_message("TE01", message_id)
|
171
|
+
):
|
172
|
+
self.add_error(
|
173
|
+
node,
|
174
|
+
message_id,
|
175
|
+
"TE01",
|
176
|
+
"Strings with apostrophes should use foo\u2019s instead of foo's.",
|
177
|
+
)
|
178
|
+
if (
|
179
|
+
self.config.get("TE02", {}).get("enabled", True)
|
180
|
+
and self.incorrect_apostrophe_re.search(cleaned_str)
|
181
|
+
and not self.exclude_message("TE02", message_id)
|
182
|
+
):
|
183
|
+
self.add_error(
|
184
|
+
node,
|
185
|
+
message_id,
|
186
|
+
"TE02",
|
187
|
+
"Strings with apostrophes should use foo\u2019s instead of foo\u2018s.",
|
188
|
+
)
|
189
|
+
if (
|
190
|
+
self.config.get("TE03", {}).get("enabled", True)
|
191
|
+
and self.single_quote_re.search(cleaned_str)
|
192
|
+
and not self.exclude_message("TE03", message_id)
|
193
|
+
):
|
194
|
+
self.add_error(
|
195
|
+
node,
|
196
|
+
message_id,
|
197
|
+
"TE03",
|
198
|
+
"Single-quoted strings should use Unicode \u2018foo\u2019 instead of 'foo'.",
|
199
|
+
)
|
200
|
+
if self.config.get("TE04", {}).get(
|
201
|
+
"enabled", True
|
202
|
+
) and self.double_quote_re.search(cleaned_str):
|
188
203
|
# Ignore parameterized terms and other functions
|
189
204
|
for regex in self.ftl_syntax_re:
|
190
205
|
cleaned_str = regex.sub("", cleaned_str)
|
@@ -198,15 +213,18 @@ class Linter(visitor.Visitor):
|
|
198
213
|
"TE04",
|
199
214
|
'Double-quoted strings should use Unicode \u201cfoo\u201d instead of "foo".',
|
200
215
|
)
|
201
|
-
if
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
216
|
+
if (
|
217
|
+
self.config.get("TE05", {}).get("enabled", True)
|
218
|
+
and self.ellipsis_re.search(cleaned_str)
|
219
|
+
and not self.exclude_message("TE05", message_id)
|
220
|
+
):
|
221
|
+
self.add_error(
|
222
|
+
node,
|
223
|
+
message_id,
|
224
|
+
"TE05",
|
225
|
+
"Strings with an ellipsis should use the Unicode \u2026 character"
|
226
|
+
" instead of three periods",
|
227
|
+
)
|
210
228
|
|
211
229
|
def generic_visit(self, node):
|
212
230
|
node_name = type(node).__name__
|
@@ -418,9 +436,9 @@ class Linter(visitor.Visitor):
|
|
418
436
|
and not self.config["PS01"]["disabled"]
|
419
437
|
and type(node.expression) not in [ast.SelectExpression]
|
420
438
|
):
|
421
|
-
if
|
439
|
+
if isinstance(node.expression, ast.VariableReference):
|
422
440
|
placeable_name = f"${node.expression.id.name}"
|
423
|
-
elif
|
441
|
+
elif isinstance(node.expression, ast.TermReference):
|
424
442
|
placeable_name = f"-{node.expression.id.name}"
|
425
443
|
else:
|
426
444
|
placeable_name = node.expression.id.name
|
@@ -455,7 +473,7 @@ class Linter(visitor.Visitor):
|
|
455
473
|
# Store the variable used for the SelectExpression, excluding functions
|
456
474
|
# like PLATFORM()
|
457
475
|
if (
|
458
|
-
|
476
|
+
isinstance(node.selector, ast.VariableReference)
|
459
477
|
and node.selector.id.name not in self.state["variables"]
|
460
478
|
):
|
461
479
|
self.state["variables"].append(node.selector.id.name)
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: moz-fluent-linter
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.8
|
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
|
@@ -18,6 +18,7 @@ License-File: LICENSE
|
|
18
18
|
Requires-Dist: fluent.syntax~=0.19.0
|
19
19
|
Requires-Dist: pyyaml
|
20
20
|
Requires-Dist: six
|
21
|
+
Dynamic: license-file
|
21
22
|
|
22
23
|
# Fluent Linter
|
23
24
|
|
@@ -41,7 +42,7 @@ Using [pre-commit](https://pre-commit.com/), add this to the `.pre-commit-config
|
|
41
42
|
```yaml
|
42
43
|
repos:
|
43
44
|
- repo: https://github.com/mozilla-l10n/moz-fluent-linter
|
44
|
-
rev: v0.4.
|
45
|
+
rev: v0.4.8
|
45
46
|
hooks:
|
46
47
|
- id: fluent_linter
|
47
48
|
files: \.ftl$
|
@@ -0,0 +1,8 @@
|
|
1
|
+
fluent_linter/__init__.py,sha256=U86LejrmMsdC6N-YT7_w8TPLE0rJkGNw9YkhBt378b8,18
|
2
|
+
fluent_linter/linter.py,sha256=onOdmqgbj2f9yCHWFHDtT30SK8VJWwG4bv40qYrCv2I,25551
|
3
|
+
moz_fluent_linter-0.4.8.dist-info/licenses/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
4
|
+
moz_fluent_linter-0.4.8.dist-info/METADATA,sha256=SjtC23VlGZZ5BTT3ajsYZ2zFxHjbhCoSwVt-ovSaIpU,2134
|
5
|
+
moz_fluent_linter-0.4.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
6
|
+
moz_fluent_linter-0.4.8.dist-info/entry_points.txt,sha256=-7bz7GIrEJyjG8EUMDKgS6FudRSpGZ9kf7jKQCp1MEg,62
|
7
|
+
moz_fluent_linter-0.4.8.dist-info/top_level.txt,sha256=UZi4ExOI1JTsfp5RPbNYAvFFLLZdzKnzPaCbcaEK_d0,14
|
8
|
+
moz_fluent_linter-0.4.8.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
fluent_linter/__init__.py,sha256=m3H0nxC6dWftoBK74_V3kjhpRmKkLX6wTCtSlFvMbjI,18
|
2
|
-
fluent_linter/linter.py,sha256=d6s8I4PWIeIOgu-WwfvB2wHDLF0WKm3lOMszerdfqf8,25204
|
3
|
-
moz_fluent_linter-0.4.7.dist-info/LICENSE,sha256=HyVuytGSiAUQ6ErWBHTqt1iSGHhLmlC8fO7jTCuR8dU,16725
|
4
|
-
moz_fluent_linter-0.4.7.dist-info/METADATA,sha256=Ybkvoa27Hl4c_3JXajZ2w3cpsCcE4H_lFlwl0CnBwJ4,2112
|
5
|
-
moz_fluent_linter-0.4.7.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
6
|
-
moz_fluent_linter-0.4.7.dist-info/entry_points.txt,sha256=-7bz7GIrEJyjG8EUMDKgS6FudRSpGZ9kf7jKQCp1MEg,62
|
7
|
-
moz_fluent_linter-0.4.7.dist-info/top_level.txt,sha256=UZi4ExOI1JTsfp5RPbNYAvFFLLZdzKnzPaCbcaEK_d0,14
|
8
|
-
moz_fluent_linter-0.4.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|