Skip to content

Commit

Permalink
Add documentation for member ordering presets and alphabetize option (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
grantwwu authored and adidahiya committed Jan 9, 2019
1 parent cda471e commit 068ad92
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/rules/memberOrderingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ const optionsDescription = Lint.Utils.dedent`
${namesMarkdown(PRESET_NAMES)}
\`fields-first\` puts, in order of precedence:
* fields before constructors before methods
* static members before instance members
* public members before protected members before private members
\`instance-sandwich\` puts, in order of precedence:
* fields before constructors before methods
* static fields before instance fields, but static methods *after* instance methods
* public members before protected members before private members
\`statics-first\` puts, in order of precedence:
* static members before instance members
* public members before protected members before private members
* fields before methods
* instance fields before constructors before instance methods
* fields before constructors before methods
* public members before protected members before private members
Note that these presets, despite looking similar, can have subtly different behavior due to the order in which these
rules are specified. A fully expanded ordering can be found in the PRESETS constant in
https://github.com/palantir/tslint/blob/master/src/rules/memberOrderingRule.ts.
(You may need to check the version of the file corresponding to your version of tslint.)
Alternatively, the value for \`order\` may be an array consisting of the following strings:
${namesMarkdown(allMemberKindNames)}
Expand Down Expand Up @@ -171,6 +197,9 @@ export class Rule extends Lint.Rules.AbstractRule {
},
],
},
alphabetize: {
type: "boolean",
},
},
additionalProperties: false,
},
Expand All @@ -190,6 +219,7 @@ export class Rule extends Lint.Rules.AbstractRule {
"protected-instance-method",
"private-instance-method",
],
alphabetize: true,
},
],
[
Expand Down Expand Up @@ -264,7 +294,7 @@ class MemberOrderingWalker extends Lint.AbstractWalker<Options> {
}

/**
* Check wether the passed members adhere to the configured order. If not, RuleFailures are generated and a single
* Check whether the passed members adhere to the configured order. If not, RuleFailures are generated and a single
* Lint.Replacement is generated, which replaces the entire NodeArray with a correctly sorted one. The Replacement
* is not immediately added to a RuleFailure, as incorrectly sorted nodes can be nested (e.g. a class declaration
* in a method implementation), but instead temporarily stored in `this.fixes`. Nested Replacements are manually
Expand Down

0 comments on commit 068ad92

Please sign in to comment.