Skip to content

Commit

Permalink
Add "any" order for "ordered-imports" rule
Browse files Browse the repository at this point in the history
  • Loading branch information
janslow committed Oct 5, 2016
1 parent cefe016 commit 13de341
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/rules/orderedImportsRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class Rule extends Lint.Rules.AbstractRule {
* \`"case-insensitive'\`: Correct order is \`"Bar"\`, \`"baz"\`, \`"Foo"\`. (This is the default.)
* \`"lowercase-first"\`: Correct order is \`"baz"\`, \`"Bar"\`, \`"Foo"\`.
* \`"lowercase-last"\`: Correct order is \`"Bar"\`, \`"Foo"\`, \`"baz"\`.
* \`"any"\`: Allow any order.
You may set the \`"named-imports-order"\` option to control the ordering of named
imports (the \`{A, B, C}\` in \`import {A, B, C} from "foo"\`).
Expand All @@ -51,18 +52,19 @@ export class Rule extends Lint.Rules.AbstractRule {
* \`"case-insensitive'\`: Correct order is \`{A, b, C}\`. (This is the default.)
* \`"lowercase-first"\`: Correct order is \`{b, A, C}\`.
* \`"lowercase-last"\`: Correct order is \`{A, C, b}\`.
* \`"any"\`: Allow any order.
`,
options: {
type: "object",
properties: {
"import-sources-order": {
type: "string",
enum: ["case-insensitive", "lowercase-first", "lowercase-last"],
enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"],
},
"named-imports-order": {
type: "string",
enum: ["case-insensitive", "lowercase-first", "lowercase-last"],
enum: ["case-insensitive", "lowercase-first", "lowercase-last", "any"],
},
},
additionalProperties: false,
Expand Down Expand Up @@ -110,6 +112,7 @@ function findUnsortedPair(xs: ts.Node[], transform: (x: string) => string): [ts.
// Transformations to apply to produce the desired ordering of imports.
// The imports must be lexicographically sorted after applying the transform.
const TRANSFORMS: {[ordering: string]: (x: string) => string} = {
any: () => "",
"case-insensitive": (x: string) => x.toLowerCase(),
"lowercase-first": flipCase,
"lowercase-last": (x: string) => x,
Expand Down

0 comments on commit 13de341

Please sign in to comment.