ThisisacollectionofcustomArcanistlintersthatwe'vewrittenatPinterest.
ApacheThriftApacheThriftGeneratedBlackCheckstyleESLintFlake8FlawfinderGoVetGraphQLSchemaLinterOpenAPIValidatorPrettierPrettierESLintPylintPyrightPythonImportsPythonisortPythonRequirementsSpectralThriftCheckWealsowelcomeadditionalcontributions.
LintersApacheThriftLintsforerrorsinApacheThriftIDL(schema)filesusingthethriftcompiler.
{"type":"thrift","include":"(\\.thrift$)","flags":["--allow-64bit-consts"],"version":">=0.9.0","thrift.generators":["py:dynamic,utf8strings,new_style,slots","java","go","erl"],"thrift.includes":[".","common"]}ApacheThriftGeneratedLintsfilesgeneratedbytheApacheThriftcompilertoensuretheyweregeneratedusingasupportedThriftcompiler.
{"type":"thrift-gen","include":"(^schemas/.*\\.py$)","thrift-gen.version":">=0.9.3"}Note:CurrentlyonlygeneratedPythonfilesaresupported.
BlackUsestheBlackopinionatedcodeformattertonormalizetheformatofPythoncode.
{"type":"black","include":"(\\.py$)","flags":["-S","--line-length=132"]}CheckstyleUsestheCheckstyletooltocheckJavacodeagainstacodingstandard.
{"type":"checkstyle","include":"(\\.java$)","checkstyle.config":"google_check.xml"}ESLintLintsJavaScriptandJSXfilesusingESLint.
{"type":"eslint","include":"(\\.js$)","bin":"./node_modules/.bin/eslint","eslint.config":"~/my-eslint.json","eslint.env":"browser,node"}Flake8LintsPythonsourcefilesusingFlake8.ThisisanextendedversionofthestockArcanistFlake8LinterthataddssupportforcheckingrequiredPythonandextensionversions.
{"type":"flake8ext","include":"(\\.py$)","flake8.python":"<3.0","flake8.extensions":{"assertive":"1.0.1","naming":"0.7.0"}}FlawfinderLintsC/C++sourcefilesusingflawfinder.
{"type":"flawfinder","include":"(\\.(c|cc|cpp|h)$)"}GraphQLSchemaLinterLintGraphQLSchemaDefinitionLanguage(SDL)usinggraphql-schema-linter.
{"type":"graphql-schema","include":"(\\.(graphql|gql)$)","graphql-schema.rules":["fields-have-descriptions","types-have-descriptions"],"graphql-schema.config":"config","graphql-schema.custom-rules":["config/custom-rules/*.js","vendor/extra-graphql-rules/*.js"],"graphql-schema.ignore":{"fields-have-descriptions":["Obvious","Query.obvious","Query.something.obvious"]},"graphql-schema.comment-descriptions":false,"graphql-schema.old-implements-syntax":false}GoVetUsestheGovetcommandtolintforsuspiciouscodeconstructs.
{"type":"govet","include":"(^src/example.com/.*\\.go$)"}OpenAPIValidatorLintOpenAPIspecificationsusingopenapi-validator.
(Supportsopenapi-validatorversion0.36.0andlater.)
{"type":"openapi-spec","version":">=0.36.0","openapi-spec.config":".validaterc","openapi-spec.debug":false,"openapi-spec.errors_only":true,"include":["(\\.yaml$)"]}PrettierFormatsJavaScriptusingPrettier.
{"type":"prettier","include":"(\\.js$)","bin":"./node_modules/.bin/prettier","prettier.cwd":"./"}PrettierESLintFormatsJavaScriptusingPrettierandthenfixeswithESLint.
{"type":"prettier-eslint","include":"(\\.js$)","bin":"./node_modules/.bin/prettier-eslint","prettier-eslint.cwd":"./"}PythonImportsLintsforillegalPythonmoduleimports.
{"type":"python-imports","python-imports.pattern":"(mock)","include":"(\\.py$)","exclude":"(^tests/)"}PythonisortLintsPythonimportsusingisort.
{"type":"isort","include":"(\\.py$)"}PylintLintsPythonusingpylint.UnlikethemodulethatshipswithArcanist,thisimplementationworkswithrecentreleasesofPylintandalsosupportsvirtualenvironments.
{"type":"pinterest-pylint","include":"(\\.py$)"}PyrightType-checksPythoncodeusingPyright.
{"type":"pyright","include":"(\\.py$)"}PythonRequirementsEnsuresPythonpackagerequirementsinrequirements.txtfilesaresorted,unique,andpinnedtoexactversions.
{"type":"requirements-txt","include":"(requirements.txt$)"}Individualrequirementlinescanbeexcludedbyaddinga#noqacomment:
six>=1.10.0#noqa:allowanyrecentversionofsixSpectralLintsOpenAPIdocumentsusingSpectral.
{"type":"spectral","include":"(openapi.yaml)","spectral.ruleset":".spectral.yml",}ThriftCheckLintsThriftIDLfilesusingThriftCheck.
{"type":"thriftcheck","include":"(\\.thrift$)","thriftcheck.config":".thriftcheck.toml","thriftcheck.includes":[".","common"]}InstallationInshort,you'llneedtoaddthisrepositorytoyourlocalmachineandtellArcanisttoloadtheextension.Youeithercandothisgloballyoronaper-projectbasis.
Onceinstalled,theindividuallinterscanbeenabledandconfiguredviatheproject's.arclintfile.SeetheArcanistLintUserGuidefordetails.
GlobalInstallationArcanistcanloadmodulesfromanabsolutepath,butbecauseitalsosearchesformodulesonelevelupfromitselfonthefilesystem,it'sconvenienttoclonethisrepositoryatthesamelevelasarcanistandlibphutil.
$gitclonehttps://github.com/pinterest/arcanist-linters.gitpinterest-linters$lsarcanistpinterest-linterslibphutilThen,tellArcanisttoloadthemodulebyediting~/.arcconfig(or/etc/arcconfig):
{"load":["pinterest-linters"]}ProjectInstallationYoucanalsoloadarcanist-lintersonaper-projectbasis.Inthatcase,usingagitsubmoduleisprobablythemostconvenientapproach.
$gitsubmoduleaddhttps://github.com/pinterest/arcanist-linters.git.pinterest-linters$gitsubmoduleupdate--initThen,enablethemoduleinyourproject-level.arcconfigfile:
{"load":[".pinterest-linters"]}
评论