Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Obey object-literal-sort-keys-rule #1528

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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