This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 889
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7975240
commit c16bd79
Showing
4 changed files
with
209 additions
and
48 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
45 changes: 45 additions & 0 deletions
45
test/rules/object-literal-shorthand/onlyMethods/test.ts.fix
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,45 @@ | ||
const badMethodsGoodProps = { | ||
w() {}, | ||
*x() {}, | ||
[y]() {}, | ||
z: z | ||
}; | ||
|
||
const goodMethodsBadProps = { | ||
w() {}, | ||
*x() {}, | ||
[y]() {}, | ||
z: z | ||
}; | ||
|
||
const arrows = { | ||
x: (y) => y // this is OK. | ||
}; | ||
|
||
const namedFunctions = { | ||
x: function y() {} // named function expressions are also OK. | ||
}; | ||
|
||
const quotes = { | ||
"foo-bar"() {}, | ||
"foo-bar"() {} | ||
}; | ||
|
||
const extraCases = { | ||
x: x, | ||
a: 123, | ||
b: "hello", | ||
c: 'c', | ||
["a" + "nested"]: { | ||
x: x | ||
} | ||
}; | ||
|
||
const asyncFn = { | ||
async foo() {}, | ||
async *bar() {} | ||
} | ||
|
||
({foo: foo} = {foo: foo}); | ||
({foo: foo} = {foo: foo}); | ||
|
58 changes: 58 additions & 0 deletions
58
test/rules/object-literal-shorthand/onlyMethods/test.ts.lint
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,58 @@ | ||
const badMethodsGoodProps = { | ||
w: function() {}, | ||
~~~~~~~~~~~ [LONGHAND_METHOD % ("('{w() {...}}')")] | ||
x: function *() {}, | ||
~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{*x() {...}}')")] | ||
[y]: function() {}, | ||
~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{[y]() {...}}')")] | ||
z: z | ||
}; | ||
|
||
const goodMethodsBadProps = { | ||
w() {}, | ||
*x() {}, | ||
[y]() {}, | ||
z | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
}; | ||
|
||
const arrows = { | ||
x: (y) => y // this is OK. | ||
}; | ||
|
||
const namedFunctions = { | ||
x: function y() {} // named function expressions are also OK. | ||
}; | ||
|
||
const quotes = { | ||
"foo-bar": function() {}, | ||
~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{\"foo-bar\"() {...}}')")] | ||
"foo-bar"() {} | ||
}; | ||
|
||
const extraCases = { | ||
x, | ||
~ [OBJECT_LITERAL_DISALLOWED] | ||
a: 123, | ||
b: "hello", | ||
c: 'c', | ||
["a" + "nested"]: { | ||
x: x | ||
} | ||
}; | ||
|
||
const asyncFn = { | ||
foo: async function() {}, | ||
~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async foo() {...}}')")] | ||
bar: async function*() {} | ||
~~~~~~~~~~~~~~~~~~~~ [LONGHAND_METHOD % ("('{async *bar() {...}}')")] | ||
} | ||
|
||
({foo: foo} = {foo: foo}); | ||
({foo} = {foo}); | ||
~~~ [OBJECT_LITERAL_DISALLOWED] | ||
~~~ [OBJECT_LITERAL_DISALLOWED] | ||
|
||
[OBJECT_LITERAL_DISALLOWED]: Shorthand property assignments have been disallowed. | ||
[LONGHAND_METHOD]: Expected method shorthand in object literal %s. | ||
[LONGHAND_PROPERTY]: Expected property shorthand in object literal %s. |
10 changes: 10 additions & 0 deletions
10
test/rules/object-literal-shorthand/onlyMethods/tslint.json
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,10 @@ | ||
{ | ||
"rules": { | ||
"object-literal-shorthand": [ | ||
true, | ||
{ | ||
"property": "never" | ||
} | ||
] | ||
} | ||
} |