Skip to content

Commit

Permalink
Upgrade output, allow JSON, improve naming scheme
Browse files Browse the repository at this point in the history
Closes #1, #21.
  • Loading branch information
laraross committed Sep 28, 2015
1 parent 3b1d5d4 commit e1dc641
Show file tree
Hide file tree
Showing 58 changed files with 186 additions and 116 deletions.
13 changes: 9 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ def lint():
for i, e in enumerate(job.result):
app.logger.debug(e)
errors.append({
"line": e[0],
"column": e[1],
"err": e[2],
"msg": e[3],
"check": e[0],
"message": e[1],
"line": e[2],
"column": e[3],
"start": e[4],
"end": e[5],
"extent": e[6],
"severity": e[7],
"replacements": e[8],
})
return jsonify(
status="success",
Expand Down
2 changes: 1 addition & 1 deletion plugins/sublime/SublimeLinter-contrib-proselint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Proselint(Linter):
version_re = r'(?P<version>\d+\.\d+\.\d+)'
version_requirement = '>= 0.0.0'
regex = (
r'^.+?:(?P<line>\d+):(?P<col>\d+): (?P<message>.+)'
r'^.+?:(?P<line>\d+):(?P<col>\d+): \S* (?P<message>.+)'
)
multiline = True
line_col_base = (1, 1)
Expand Down
18 changes: 9 additions & 9 deletions proselint/.proselintrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
"butterick.symbols" : true,
"misc.annotations" : true,
"misc.chatspeak" : true,
"misc.creditcard" : true,
"misc.credit_card" : true,
"misc.currency" : true,
"misc.hyperbolic" : true,
"misc.linkchecker" : true,
"misc.link_checker" : true,
"misc.password" : true,
"misc.yelling" : true,
"pinker.apologizing" : true,
Expand All @@ -39,14 +39,14 @@
"pinker.metaconcepts" : true,
"pinker.narcisissm" : true,
"pinker.scare_quotes" : true,
"strunkwhite.composition" : true,
"strunkwhite.greylist" : true,
"strunkwhite.usage" : true,
"strunk_white.composition" : true,
"strunk_white.greylist" : true,
"strunk_white.usage" : true,
"wallace.tense_present" : true,
"wallace.uncomparables" : true,
"wallstreetjournal.misspelling" : true,
"writegood.cliches" : true,
"writegood.lexical_illusions" : true,
"writegood.weasel_words" : true
"wsj.athletes" : true,
"write_good.cliches" : true,
"write_good.lexical_illusions" : true,
"write_good.weasel_words" : true
}
}
10 changes: 5 additions & 5 deletions proselint/checks/butterick/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check_ellipsis(blob):
"""Use an ellipsis instead of three dots."""
err = "BTR101"
err = "butterick.symbols.ellipsis"
msg = u"'...' is an approximation, use the ellipsis symbol '…'."
regex = "\.\.\."

Expand All @@ -31,7 +31,7 @@ def check_ellipsis(blob):
@memoize
def check_copyright_symbol(blob):
"""Use the copyright symbol instead of (c)."""
err = "BTR102"
err = "butterick.symbols.copyright"
msg = u"(c) is a goofy alphabetic approximation, use the symbol ©."
regex = "\([cC]\)"

Expand All @@ -42,7 +42,7 @@ def check_copyright_symbol(blob):
@memoize
def check_trademark_symbol(blob):
"""Use the trademark symbol instead of (c)."""
err = "BTR103"
err = "butterick.symbols.trademark"
msg = u"(TM) is a goofy alphabetic approximation, use the symbol ™."
regex = "\(TM\)"

Expand All @@ -53,7 +53,7 @@ def check_trademark_symbol(blob):
@memoize
def check_registered_trademark_symbol(blob):
"""Use the registered trademark symbol instead of (R)."""
err = "BTR103"
err = "butterick.symbols.trademark"
msg = u"(R) is a goofy alphabetic approximation, use the symbol ®."
regex = "\([rR]\)"

Expand All @@ -64,7 +64,7 @@ def check_registered_trademark_symbol(blob):
@memoize
def check_sentence_spacing(blob):
"""Use the registered trademark symbol instead of (R)."""
err = "BTR104"
err = "butterick.symbols.sentence_spacing"
msg = u"More than two spaces after the period; use 1 or 2."
regex = "\. {3}"

Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/consistency/spacing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "CST200"
err = "consistency.spacing"
msg = "Inconsistent spacing after period (1 vs. 2 spaces)."

regex = ["[\.\?!] [A-Z]", "[\.\?!] [A-Z]"]
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/consistency/spelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "IEL100"
err = "consistency.spelling"
msg = "Inconsistent spelling of '{}' (vs. '{}')."

word_pairs = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/a_vs_an.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@memoize
def check(blob):
"""Define the check."""
err = "MAU101"
err = "garner.a_vs_an"
msg_a = "'a' should be 'an'."
msg_an = "'an' should be 'a'."

Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/airlinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU108"
err = "garner.airlinese"
msg = u"'{}' is airlinese."

airlinese = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/animal_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU118"
err = "garner.animal_labels"
msg = "There's a word for this: '{}'."

preferences = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/archaism.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU103"
err = "garner.archaism"
msg = u"'{}' is archaic."

archaisms = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/back_formations.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU102"
err = "garner.back_formations"
msg = "Back-formation. '{}' is the preferred form."

list = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/capitalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU102"
err = "garner.captalization"
msg = "Incorrect capitalization. '{}' is the preferred form."

list = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/cliches.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU101"
err = "garner.cliches"
msg = u"'{}' is cliché."

cliches = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/commercialese.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU104"
err = "garner.commercialese"
msg = u"'{}' is commercialese."

commercialese = [
Expand Down
10 changes: 5 additions & 5 deletions proselint/checks/garner/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
@memoize
def check_decade_apostrophes_short(blob):
"""Check the text for dates of the form X0's."""
err = "MAU103"
err = "garner.dates"
msg = u"Apostrophes aren't needed for decades."

regex = "\d0\'s"
Expand All @@ -33,7 +33,7 @@ def check_decade_apostrophes_short(blob):
@memoize
def check_decade_apostrophes_long(blob):
"""Check the text for dates of the form XXX0's."""
err = "MAU103"
err = "garner.dates"
msg = u"Apostrophes aren't needed for decades."

regex = "\d\d\d0\'s"
Expand All @@ -43,7 +43,7 @@ def check_decade_apostrophes_long(blob):
@memoize
def check_dash_and_from(blob):
"""Check the text."""
err = "MAU103"
err = "garner.dates"
msg = u"When specifying a date range, write 'from X to Y'."

regex = "from \d+[^ \t\n\r\f\va-zA-Z0-9_]\d+"
Expand All @@ -52,7 +52,7 @@ def check_dash_and_from(blob):

def check_month_year_comma(blob):
"""Check the text."""
err = "MAU103"
err = "garner.dates"
msg = u"When specifying a month and year, no comma is needed."

regex = "(?:" + "|".join(calendar.month_name[1:]) + "), \d{3,}"
Expand All @@ -62,7 +62,7 @@ def check_month_year_comma(blob):
@memoize
def check_month_of_year(blob):
"""Check the text."""
err = "MAU103"
err = "garner.dates"
msg = u"When specifying a month and year, 'of' is unnecessary."

regex = "(?:" + "|".join(calendar.month_name[1:]) + ") of \d{3,}"
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/denizen_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU109"
err = "garner.denizen_labels"
msg = "'{}' is the preferred denizen label."

preferences = [
Expand Down
1 change: 1 addition & 0 deletions proselint/checks/garner/errata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
? Page 82. Inconsistent spelling of "back-formations" as "backformation".
6 changes: 3 additions & 3 deletions proselint/checks/garner/illogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU105"
err = "garner.illogic"
msg = u"'{}' is illogical."

illogics = [
Expand All @@ -41,7 +41,7 @@ def check(blob):
@memoize
def check_coin_a_phrase_from(blob):
"""Check the text."""
err = "MAU104"
err = "garner.illogic.coin"
msg = "You can't coin an existing phrase. Did you mean 'borrow'?"

regex = "to coin a phrase from"
Expand All @@ -52,7 +52,7 @@ def check_coin_a_phrase_from(blob):
@memoize
def check_without_your_collusion(blob):
"""Check the textself."""
err = "MAU838"
err = "garner.illogic.collusion"
msg = "It's impossible to defraud yourself. Try 'aquiescence'."

regex = "without your collusion"
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/jargon.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU101"
err = "garner.jargon"
msg = u"'{}' is jargon. Can you replace it with something more standard?"

jargon = [
Expand Down
25 changes: 1 addition & 24 deletions proselint/checks/garner/malaproprisms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU105"
err = "garner.malaproprisms"
msg = u"'{}' is a malaproprism."

illogics = [
Expand All @@ -30,26 +30,3 @@ def check(blob):
]

return existence_check(blob, illogics, err, msg, offset=1)


@memoize
def check_coin_a_phrase_from(blob):
"""Check the text."""
err = "MAU104"
msg = "You can't coin an existing phrase. Did you mean 'borrow'?"

regex = "to coin a phrase from"

return existence_check(blob, [regex], err, msg, offset=1)


@memoize
def check_without_your_collusion(blob):
"""Check the textself."""
err = "MAU838"
msg = "It's impossible to defraud yourself. Try 'aquiescence'."

regex = "without your collusion"

return existence_check(
blob, [regex], err, msg, require_padding=False, offset=-1)
2 changes: 1 addition & 1 deletion proselint/checks/garner/misspelling.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU102"
err = "garner.misspellings"
msg = "Misspelling. '{}' is the preferred form."

misspellings = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/mixed_metaphors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU104"
err = "garner.mixed_metaphors"
msg = u"Mixed metaphor. Try '{}'."

preferences = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/needless_variants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU102"
err = "garner.needless_variants"
msg = "Needless variant. '{}' is the preferred form."

preferences = [
Expand Down
2 changes: 1 addition & 1 deletion proselint/checks/garner/oxymorons.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Check the text."""
err = "MAU120"
err = "garner.oxymorons"
msg = u"'{}' is an oxymoron."

oxymorons = [
Expand Down
8 changes: 4 additions & 4 deletions proselint/checks/garner/preferred_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@memoize
def check(blob):
"""Suggest the preferred forms."""
err = "MAU102"
err = "ganer.preferred_forms"
msg = "'{}' is the preferred form."

preferences = [
Expand Down Expand Up @@ -154,7 +154,7 @@ def check(blob):
@memoize
def check_able_ible(blob):
"""-able vs. -ible."""
err = "MAU102"
err = "garner.preferred_forms.ible"
msg = "-able vs. -ible. '{}' is the preferred form."

preferences = [
Expand Down Expand Up @@ -324,7 +324,7 @@ def check_able_ible(blob):
@memoize
def check_able_atable(blob):
"""-able vs. -ible."""
err = "MAU102"
err = "garner.preferred_forms.atable"
msg = "-able vs. -atable. '{}' is the preferred form."

preferences = [
Expand Down Expand Up @@ -405,7 +405,7 @@ def check_able_atable(blob):
@memoize
def check_em_vs_em_and_en_vs_in(blob):
"""em- vs. en-, im- vs. in-."""
err = "MAU102"
err = "garner.preferred_forms.em"
msg = "em-, im-, en-, and in-. '{}' is the preferred form."

preferences = [
Expand Down
Loading

0 comments on commit e1dc641

Please sign in to comment.