Skip to content

Commit

Permalink
Obey object-literal-sort-keys rule (palantir#1528)
Browse files Browse the repository at this point in the history
  • Loading branch information
bolatovumar authored and Nina Hartmann committed Aug 31, 2016
1 parent ca67559 commit 554fc2d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/configs/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const rules = {
"switch-default": true,
"trailing-comma": [true,
{
"singleline": "never",
"multiline": "always",
"singleline": "never",
},
],
"triple-equals": [true, "allow-null-check"],
Expand Down
16 changes: 8 additions & 8 deletions src/rules/memberOrderingRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ const PRESET_ORDERS: { [preset: string]: string[] } = {
"protected-instance-method",
"private-instance-method",
],
"statics-first": [
"instance-sandwich": [
"public-static-field",
"public-static-method",
"protected-static-field",
"protected-static-method",
"private-static-field",
"private-static-method",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method",
"public-static-method",
"protected-static-method",
"private-static-method",
],
"instance-sandwich": [
"statics-first": [
"public-static-field",
"public-static-method",
"protected-static-field",
"protected-static-method",
"private-static-field",
"private-static-method",
"public-instance-field",
"protected-instance-field",
"private-instance-field",
"constructor",
"public-instance-method",
"protected-instance-method",
"private-instance-method",
"public-static-method",
"protected-static-method",
"private-static-method",
],
};
/* end new options */
Expand Down
6 changes: 6 additions & 0 deletions test/configurationTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,13 @@ describe("Configuration", () => {
let config = loadConfigurationFromPath("./test/config/tslint-extends-package.json");

assert.isArray(config.rulesDirectory);
/* tslint:disable:object-literal-sort-keys */
assert.deepEqual(config.rules, {
"rule-one": true,
"rule-two": true,
"rule-three": false,
});
/* tslint:enable:object-literal-sort-keys */
});

it("extends with package without customization", () => {
Expand Down Expand Up @@ -130,12 +132,14 @@ describe("Configuration", () => {
assert.lengthOf(config.rulesDirectory, 2);
assert.isTrue(fs.existsSync(config.rulesDirectory[0]));
assert.isTrue(fs.existsSync(config.rulesDirectory[1]));
/* tslint:disable:object-literal-sort-keys */
assert.deepEqual(config.rules, {
"always-fail": false,
"rule-one": true,
"rule-two": true,
"rule-four": true,
});
/* tslint:enable:object-literal-sort-keys */
});

it("extends with array", () => {
Expand All @@ -153,11 +157,13 @@ describe("Configuration", () => {
it("can load .json files with comments", () => {
const config = loadConfigurationFromPath("./test/config/tslint-with-comments.json");

/* tslint:disable:object-literal-sort-keys */
assert.deepEqual(config.rules, {
"rule-two": true,
"rule-three": "//not a comment",
"rule-four": "/*also not a comment*/",
});
/* tslint:enable:object-literal-sort-keys */
});

it("can load .json files with BOM", () => {
Expand Down
2 changes: 2 additions & 0 deletions test/ruleLoaderTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ describe("Rule Loader", () => {
});

it("doesn't ignore leading or trailing underscores or dashes", () => {
/* tslint:disable:object-literal-sort-keys */
const invalidConfiguration: {[name: string]: any} = {
_indent: 6,
forin_: true,
"-quotemark": "single",
"eofline-": true,
};
/* tslint:enable:object-literal-sort-keys */

assert.throws(
() => loadRules(invalidConfiguration, {}, RULES_DIRECTORY),
Expand Down

0 comments on commit 554fc2d

Please sign in to comment.