forked from palantir/tslint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhancement] object-literal-shorthand / config to disallow shorthand (…
- Loading branch information
1 parent
0f29468
commit 7a9579c
Showing
8 changed files
with
213 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"object-literal-shorthand": [true, "always"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const asyncFn = { | ||
f: async function() { | ||
await some_promise; | ||
}, | ||
fa: async function*() { | ||
await some_promise; | ||
} | ||
}; | ||
|
||
const bad = { | ||
w: function() {}, | ||
x: function*() {}, | ||
[y]: function() {}, | ||
z: z, | ||
nest: { | ||
nestBad: function() {}, | ||
nextGood: function(prop: string): void {} | ||
} | ||
}; | ||
|
||
const good = { | ||
w: function() {}, | ||
x: function *() {}, | ||
[y]: function() {} | ||
}; | ||
|
||
const arrows = { | ||
x: (y) => y // this is OK. | ||
}; | ||
|
||
const namedFunctions = { | ||
x: function y() {} // named function expressions are also OK. | ||
}; | ||
|
||
const quotes = { | ||
"foo-bar": function() {}, | ||
"foo-bar": function() {} | ||
}; | ||
|
||
const extraCases = { | ||
x: x, | ||
a: 123, | ||
b: "hello", | ||
c: 'c', | ||
["a" + "nested"]: { | ||
x: x | ||
} | ||
}; | ||
|
||
export class ClassA extends ClassZ { | ||
testMethod() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
const asyncFn = { | ||
async f() { | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
await some_promise; | ||
}, | ||
async* fa() { | ||
~~ [OBJECT_LITERAL_DISALLOWED] | ||
await some_promise; | ||
} | ||
}; | ||
|
||
const bad = { | ||
w() {}, | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
*x() {}, | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
[y]() {}, | ||
~~~ [OBJECT_LITERAL_DISALLOWED] | ||
z, | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
nest: { | ||
nestBad() {}, | ||
~~~~~~~ [OBJECT_LITERAL_DISALLOWED] | ||
nextGood: function(prop: string): void {} | ||
} | ||
}; | ||
|
||
const good = { | ||
w: function() {}, | ||
x: function *() {}, | ||
[y]: function() {} | ||
}; | ||
|
||
const arrows = { | ||
x: (y) => y // this is OK. | ||
}; | ||
|
||
const namedFunctions = { | ||
x: function y() {} // named function expressions are also OK. | ||
}; | ||
|
||
const quotes = { | ||
"foo-bar": function() {}, | ||
"foo-bar"() {} | ||
~~~~~~~~~ [OBJECT_LITERAL_DISALLOWED] | ||
}; | ||
|
||
const extraCases = { | ||
x, | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
a: 123, | ||
b: "hello", | ||
c: 'c', | ||
["a" + "nested"]: { | ||
x: x | ||
} | ||
}; | ||
|
||
export class ClassA extends ClassZ { | ||
testMethod() {} | ||
} | ||
[OBJECT_LITERAL_DISALLOWED]: Shorthand property assignments have been disallowed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"rules": { | ||
"object-literal-shorthand": [true, "never"] | ||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.