Page MenuHomePhabricator

Move `ArcanistSpellingDefaultData` into a configurable JSON file
ClosedPublic

Authored by joshuaspence on Jul 2 2014, 10:06 PM.
Tags
None
Referenced Files
F13996869: D9805.id23544.diff
Thu, Oct 24, 12:37 AM
F13993393: D9805.diff
Tue, Oct 22, 10:34 PM
F13990904: D9805.diff
Tue, Oct 22, 7:13 AM
F13968772: D9805.diff
Wed, Oct 16, 10:59 PM
F13961910: D9805.id23532.diff
Tue, Oct 15, 6:58 AM
Unknown Object (File)
Fri, Oct 11, 3:56 PM
Unknown Object (File)
Thu, Oct 10, 9:34 AM
Unknown Object (File)
Oct 3 2024, 11:16 PM
Subscribers

Details

Summary

Currently, the ArcanistSpellingLinter loads data from ArcanistSpellingDefaultData, with no way to configure the linter from an .arclint file. Instead we should define a format for a "dictionary" file, of which the ArvcanistSpellingLinter can load and of which the paths are easily configured through .arclint.

Test Plan

Updated the test case and ran arc unit.

NOTE: I have removed the LINT_SPELLING_PICKY and LINT_SPELLING_IMPORTANT constants and replaced them with LINT_SPELLING_FULL and LINT_SPELLING_PARTIAL. This was done because it simplifies the implementation considerably and makes customization of the ArcanistSpellingLinter simpler, but also because these constants were not widely used in the existing implementation.

Diff Detail

Repository
rARC Arcanist
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence retitled this revision from to Move `ArcanistSpellingDefaultData` into a configurable JSON file.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.
epriestley added inline comments.
src/lint/linter/ArcanistSpellingLinter.php
107

Consider defining this relative to phutil_get_library_root('arcanist') so the class doesn't mysteriously stop working if it is moved.

This revision is now accepted and ready to land.Jul 3 2014, 1:52 AM
joshuaspence edited edge metadata.
  • Define dictionary relative to arcanist library root
  • Rename "fullword" to "exact"
src/lint/linter/ArcanistSpellingLinter.php
104–109

Do you think that this is the right approach? The alternative would be to require that a spelling linter explicitly load all relevant dictionaries (which would break backwards compatibility).

Another thought is that perhaps dictionaries should be able to be specified relative to the resources/spelling directory. i.e. if "spelling.dictionaries": ["foo/bar.json"] then a dictionary would be loaded the first existing path out of:

  1. 'arcanist/resources/spelling/foo/bar.json'
  2. $working_copy->getProjectRoot().'/foo/bar.json'
src/lint/linter/ArcanistSpellingLinter.php
94

Ironically, I appear to have misspelled "misspelling".

I think the given approach is reasonable. Copy/pasting the base data into your project or copy-pasting it to start your local file seem like mostly approaches (you aren't really going to miss that much by us adding 3 more words per year to the upstream) and they let you remove words. If there's a ton of demand for it or something we could add another config option later to include it explicitly, e.g.:

spelling.dictionaries = custom.json
spelling.include-default-dictionary = true

But I'd guess this won't come up for, like, at least a year.

mostly approaches

Er, mostly sensible approaches.

Yeah, I don't want to overcomplicate it right now (YAGNI). But I do want to add spelling.rules.exact and spelling.rules.partial configuration.

The spelling.include-default-dictionaries option is nice because it offers a more-sane way to provide a default without extending the .arclint stuff to support a default value.

resources/spelling/english.json
2

Any thoughts on why there's no syntax highlighting on JSON files? I can't remember if this is happening on my local install.