Skip to content

Commit b151b61

Browse files
committed
Update configuration
Add test files to demonstrate new promise rules and update snapshot. Release version 2.0.1.
1 parent 6122432 commit b151b61

File tree

6 files changed

+59
-26
lines changed

6 files changed

+59
-26
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
'eslint-plugin-deprecate',
1313
'eslint-plugin-no-only-tests',
1414
'eslint-plugin-no-skip-tests',
15+
'eslint-plugin-promise',
1516
'eslint-plugin-sonarjs',
1617
'eslint-plugin-test-selectors' // NOTE: Only runs against JSX
1718
],

demo/example.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Example of a broken JSON file that should trigger the additional rules contained in ./index.js */
1+
/* Example of a broken JS file that should trigger the additional rules contained in ./index.js */
22

33
/*
44
* Since developers have the ability to disable linting in-line, we keep track of the times where this is done.
@@ -27,6 +27,16 @@ no-undefined
2727
function ONE_FUNCTION_TO_BRING_THEM_ALL_AND_IN_THE_DARKNESS_BIND_THEM (params) {
2828
}
2929

30+
let myPromise = new Promise();
31+
32+
myPromise.then((a) => {
33+
if (a) {
34+
return Promise.resolve()
35+
} else {
36+
forgotToReturn()
37+
}
38+
})
39+
3040
let variable = (true) ? true : true;
3141

3242
if (window === undefined && window === undefined && true === params) {

demo/test/snapshots/lint-output.js.md

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,36 @@ Generated by [AVA](https://ava.li).
2323
21:1 warning Missing JSDoc @description declaration jsdoc/require-description␊
2424
21:1 warning JSDoc @returns declaration present but return expression not available in function jsdoc/require-returns-check␊
2525
21:1 warning JSDoc syntax error valid-jsdoc␊
26-
23:0 warning Missing JSDoc @param "a" description jsdoc/require-param-description␊
2726
23:0 warning Expected @param names to be "params". Got "a, b" jsdoc/check-param-names␊
28-
24:0 warning Missing JSDoc @param "b" description jsdoc/require-param-description␊
27+
23:0 warning Missing JSDoc @param "a" description jsdoc/require-param-description␊
2928
24:0 warning Missing JSDoc @param "b" type jsdoc/require-param-type␊
30-
25:0 warning Missing JSDoc @returns type jsdoc/require-returns-type
29+
24:0 warning Missing JSDoc @param "b" description jsdoc/require-param-description
3130
25:0 warning Missing JSDoc @returns description jsdoc/require-returns-description␊
32-
30:5 error 'variable' is assigned a value but never used no-unused-vars␊
33-
30:16 warning This conditional operation returns the same value whether the condition is "true" or "false" sonarjs/no-all-duplicated-branches␊
34-
30:17 error Unexpected constant condition no-constant-condition␊
35-
30:25 error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary␊
36-
32:5 warning Correct one of the identical sub-expressions on both sides of operator "&&" sonarjs/no-identical-expressions␊
37-
32:16 warning Unexpected use of undefined no-undefined␊
38-
32:40 warning Unexpected use of undefined no-undefined␊
39-
32:53 error Expected literal to be on the right side of === yoda␊
40-
32:62 error 'params' is not defined no-undef␊
41-
33:3 warning This function expects 1 argument, but 2 were provided sonarjs/no-extra-arguments␊
42-
34:28 error Module path/to/legacyModule is deprecated. Use module x instead deprecate/import␊
43-
36:3 error Function deprecatedFunction is deprecated. Use function x from package y instead deprecate/function␊
44-
36:3 error 'deprecatedFunction' is not defined no-undef␊
45-
37:3 error Member expression $.each is deprecated. Use native forEach instead deprecate/member-expression␊
46-
37:3 error '$' is not defined no-undef␊
47-
38:3 error Unexpected 'debugger' statement no-debugger␊
31+
25:0 warning Missing JSDoc @returns type jsdoc/require-returns-type␊
32+
30:17 warning Avoid creating new promises promise/avoid-new␊
33+
32:1 warning Expected catch() or return promise/catch-or-return␊
34+
33:3 warning Each then() should return a value or throw promise/always-return␊
35+
34:5 warning Avoid wrapping return values in Promise.resolve promise/no-return-wrap␊
36+
34:29 error Missing semicolon semi␊
37+
36:5 error 'forgotToReturn' is not defined no-undef␊
38+
36:21 error Missing semicolon semi␊
39+
38:3 error Missing semicolon semi␊
40+
40:5 error 'variable' is assigned a value but never used no-unused-vars␊
41+
40:16 warning This conditional operation returns the same value whether the condition is "true" or "false" sonarjs/no-all-duplicated-branches␊
42+
40:17 error Unexpected constant condition no-constant-condition␊
43+
40:25 error Unnecessary use of boolean literals in conditional expression no-unneeded-ternary␊
44+
42:5 warning Correct one of the identical sub-expressions on both sides of operator "&&" sonarjs/no-identical-expressions␊
45+
42:16 warning Unexpected use of undefined no-undefined␊
46+
42:40 warning Unexpected use of undefined no-undefined␊
47+
42:53 error Expected literal to be on the right side of === yoda␊
48+
42:62 error 'params' is not defined no-undef␊
49+
43:3 warning This function expects 1 argument, but 2 were provided sonarjs/no-extra-arguments␊
50+
44:28 error Module path/to/legacyModule is deprecated. Use module x instead deprecate/import␊
51+
46:3 error Function deprecatedFunction is deprecated. Use function x from package y instead deprecate/function␊
52+
46:3 error 'deprecatedFunction' is not defined no-undef␊
53+
47:3 error Member expression $.each is deprecated. Use native forEach instead deprecate/member-expression␊
54+
47:3 error '$' is not defined no-undef␊
55+
48:3 error Unexpected 'debugger' statement no-debugger␊
4856
4957
example.json␊
5058
4:5 error Property keys must be doublequoted json/undefined␊
@@ -55,6 +63,6 @@ Generated by [AVA](https://ava.li).
5563
6:19 error Trailing comma json/trailingcomma␊
5664
8:2 error End of file expected json/undefined␊
5765
58-
40 problems (19 errors, 21 warnings)␊
59-
1 error and 0 warnings potentially fixable with the `--fix` option.␊
66+
48 problems (23 errors, 25 warnings)␊
67+
4 errors and 0 warnings potentially fixable with the `--fix` option.␊
6068
`
178 Bytes
Binary file not shown.

index.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
extends: [
3-
'eslint-config-standard',
4-
'plugin:promise/recommended'
3+
'eslint-config-standard'
4+
// 'plugin:promise/recommended' // Disabled, because Code Climate does not support promise.
55
// 'plugin:eslint-plugin-sonarjs/recommended' // Disabled globally, for now, because it is a much higher standard than Tree's existing code currently adheres to. Enable on a case-by-case basis, if you wish.
66
],
77
env: {
@@ -41,7 +41,7 @@ module.exports = {
4141
parser: 'babel-eslint',
4242
/**
4343
* @property plugins - Tree additional linter plugins.
44-
* @note - Code Climate does not support deprecate and sonarjs, and breaks if they are present. You will need to add these plugins individually in your .eslintrc.js file.
44+
* @note - Code Climate does not support bestpractices, deprecate, no-only-tests, no-skip-tests, sonarjs, and test-selectors, and breaks if they are present. You will need to add these plugins individually in your .eslintrc.js file.
4545
*/
4646
plugins: [
4747
// 'eslint-plugin-bestpractices',
@@ -51,6 +51,7 @@ module.exports = {
5151
'eslint-plugin-json'
5252
// 'eslint-plugin-no-only-tests',
5353
// 'eslint-plugin-no-skip-tests',
54+
// 'eslint-plugin-promise',
5455
// 'eslint-plugin-sonarjs',
5556
// 'eslint-plugin-test-selectors' // NOTE: Only runs against JSX
5657
],
@@ -102,6 +103,19 @@ module.exports = {
102103
'no-only-tests/no-only-tests': 'error',
103104
'no-skip-tests/no-skip-tests': 'warn',
104105

106+
'promise/always-return': 'warn',
107+
'promise/no-return-wrap': 'warn',
108+
'promise/param-names': 'warn',
109+
'promise/catch-or-return': 'warn',
110+
'promise/no-native': 'off',
111+
'promise/no-nesting': 'warn',
112+
'promise/no-promise-in-callback': 'warn',
113+
'promise/no-callback-in-promise': 'warn',
114+
'promise/avoid-new': 'warn',
115+
'promise/no-new-statics': 'warn',
116+
'promise/no-return-in-finally': 'warn',
117+
'promise/valid-params': 'warn',
118+
105119
'sonarjs/cognitive-complexity': 'warn',
106120
'sonarjs/max-switch-cases': 'warn',
107121
'sonarjs/no-all-duplicated-branches': 'warn',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-config-tree",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Shared Tree configuration that contains overrides and enhancements on top of the base frontier configuration.",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)