eslint-config-uphold 0.2.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Uphold
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,22 +1,27 @@
1
1
  # eslint-config-uphold
2
2
 
3
- Uphold-flavored ESLint config.
3
+ Uphold-flavored [ESLint](https://eslint.org/) config.
4
+
5
+ The [rules defined here](https://github.com/uphold/eslint-config-uphold/blob/master/src/index.js)
6
+ extend the [eslint-recommended](https://github.com/eslint/eslint/blob/master/conf/eslint-recommended.js) preset,
7
+ as well as the [overrides](https://github.com/prettier/eslint-config-prettier/blob/master/index.js)
8
+ that allow the [Prettier](https://prettier.io) pretty-printer to reformat the code without conflicts.
4
9
 
5
10
  ## Installation
6
11
 
7
12
  ```sh
8
- $ npm install eslint eslint-config-uphold --save-dev
13
+ $ npm install eslint eslint-config-uphold prettier --save-dev
9
14
  ```
10
15
 
11
16
  ## Usage
12
17
 
13
- Create an `.eslintrc.yml` file with the following:
18
+ Create an `.eslintrc.yml` file with the following content:
14
19
 
15
20
  ```yaml
16
21
  extends: uphold
17
22
  ```
18
23
 
19
- Add the following `script` to your `package.json`:
24
+ Add a `lint` command to the `scripts` section of your `package.json`, like so:
20
25
 
21
26
  ```json
22
27
  {
@@ -31,3 +36,17 @@ and run the linter with:
31
36
  ```sh
32
37
  $ npm run lint
33
38
  ```
39
+
40
+ To automatically fix all lint issues, use the `--fix` option:
41
+
42
+ ```sh
43
+ $ npm run lint --fix
44
+ ```
45
+
46
+ ## Upgrading eslint
47
+
48
+ See the [eslint repo](https://github.com/eslint/eslint#semantic-versioning-policy) for eslint's guidelines on semantic versioning.
49
+
50
+ A [tilde range](https://docs.npmjs.com/cli/v6/using-npm/semver#tilde-ranges-123-12-1) is set for the eslint dependency to pick up any patch changes by default.
51
+
52
+ For any minor/major upgrades to `eslint` it is recommended to update both eslint and `eslint-config-uphold` and keep them in parallel. This is down to the fact that no guarantee is made that minor upgrades do not cause conflicts or issues with existing or new rules. The downside here is a package update is required for any security or other bug fixes. The benefit however is the included rules are always guaranteed to be stable.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-uphold",
3
- "version": "0.2.0",
3
+ "version": "2.1.0",
4
4
  "description": "Uphold-flavored ESLint config",
5
5
  "keywords": [
6
6
  "config",
@@ -19,31 +19,42 @@
19
19
  "type": "git",
20
20
  "url": "git+ssh://git@github.com/uphold/eslint-config-uphold.git"
21
21
  },
22
+ "files": [
23
+ "src"
24
+ ],
22
25
  "scripts": {
23
- "changelog": "github-changelog-generator --future-release=v$npm_config_future_release > CHANGELOG.md",
24
- "lint": "eslint --config src/index.js src/index.js test/index.js",
26
+ "changelog": "echo \"$(github-changelog-generator --owner uphold --repo eslint-config-uphold --future-release=$npm_package_version)\n$(tail -n +2 CHANGELOG.md)\" > CHANGELOG.md",
27
+ "lint": "eslint src test/index.js",
25
28
  "test": "mocha $npm_package_options_mocha",
26
29
  "version": "npm run changelog --future-release=$npm_package_version && git add -A CHANGELOG.md"
27
30
  },
28
31
  "dependencies": {
29
- "babel-eslint": "^7.1.1",
30
- "eslint-plugin-mocha": "^5.1.0",
31
- "eslint-plugin-sort-class-members": "^1.0.1",
32
+ "@babel/core": "^7.16.12",
33
+ "@babel/eslint-parser": "^7.16.5",
34
+ "eslint-config-prettier": "^7.2.0",
35
+ "eslint-plugin-mocha": "^5.3.0",
36
+ "eslint-plugin-prettier": "^3.3.1",
37
+ "eslint-plugin-rulesdir": "^0.1.0",
32
38
  "eslint-plugin-sort-imports-es6": "^0.0.3",
33
39
  "eslint-plugin-sql-template": "^2.0.0"
34
40
  },
35
41
  "devDependencies": {
36
- "@uphold/github-changelog-generator": "^0.7.0",
37
- "eslint": "^4.19.0",
38
- "mocha": "^3.1.1",
42
+ "@uphold/github-changelog-generator": "^3.0.0",
43
+ "eslint": "~8.7.0",
44
+ "mocha": "^9.2.0",
39
45
  "pre-commit": "^1.2.2",
46
+ "prettier": "^2.2.1",
40
47
  "should": "^9.0.2"
41
48
  },
49
+ "peerDependencies": {
50
+ "eslint": "~8.7.0",
51
+ "prettier": "^2.2.1"
52
+ },
42
53
  "pre-commit": [
43
54
  "lint"
44
55
  ],
45
56
  "engines": {
46
- "node": ">=6"
57
+ "node": ">=10.23.2"
47
58
  },
48
59
  "options": {
49
60
  "mocha": "-t 10000 --require should test"
package/src/index.js CHANGED
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Module dependencies.
3
+ */
4
+
5
+ const rulesDir = require('eslint-plugin-rulesdir');
6
+
7
+ /**
8
+ * Configure the rulesdir plugin.
9
+ */
10
+
11
+ rulesDir.RULES_DIR = `${__dirname}/rules`;
1
12
 
2
13
  /**
3
14
  * Export `uphold` shared configuration preset.
@@ -11,97 +22,56 @@ module.exports = {
11
22
  mocha: true,
12
23
  node: true
13
24
  },
14
- extends: ['eslint:recommended'],
15
- parser: 'babel-eslint',
16
- plugins: ['mocha', 'sort-class-members', 'sort-imports-es6', 'sql-template'],
25
+ extends: ['eslint:recommended', 'plugin:prettier/recommended'],
26
+ parser: '@babel/eslint-parser',
27
+ parserOptions: {
28
+ requireConfigFile: false
29
+ },
30
+ plugins: ['mocha', 'rulesdir', 'sort-imports-es6', 'sql-template'],
17
31
  root: true,
18
32
  rules: {
19
33
  'accessor-pairs': 'error',
20
- 'array-bracket-spacing': 'error',
21
- 'arrow-parens': ['error', 'as-needed'],
22
- 'arrow-spacing': 'error',
23
34
  'block-scoped-var': 'error',
24
- 'block-spacing': 'off',
25
- 'brace-style': ['error', '1tbs', {
26
- allowSingleLine: true
27
- }],
28
- camelcase: 'off',
29
- 'comma-dangle': 'error',
30
- 'comma-spacing': 'error',
31
- 'comma-style': 'error',
32
- complexity: 'off',
33
- 'computed-property-spacing': 'error',
34
- 'consistent-return': 'off',
35
35
  'consistent-this': ['error', 'self'],
36
36
  curly: 'error',
37
37
  'default-case': 'error',
38
- 'dot-location': ['error', 'property'],
39
38
  'dot-notation': 'error',
40
- 'eol-last': 'error',
41
39
  eqeqeq: ['error', 'smart'],
42
- 'func-names': 'off',
43
- 'func-style': ['error', 'declaration', {
44
- allowArrowFunctions: true
45
- }],
46
- 'generator-star-spacing': ['error', 'before'],
47
- 'id-length': ['error', {
48
- exceptions: ['_', 'e', 'i']
49
- }],
50
- 'id-match': ['error', '^_$|^[a-zA-Z][a-zA-Z0-9]*$|^[A-Z][_A-Z0-9]+[A-Z0-9]$', {
51
- onlyDeclarations: true,
52
- properties: true
53
- }],
54
- indent: ['error', 2, {
55
- SwitchCase: 1
56
- }],
57
- 'key-spacing': 'error',
58
- 'keyword-spacing': 'error',
59
- 'linebreak-style': 'error',
60
- 'lines-around-comment': 'off',
40
+ 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
41
+ 'id-length': ['error', { exceptions: ['_', 'e', 'i'] }],
42
+ 'id-match': [
43
+ 'error',
44
+ '^_$|^[$_a-zA-Z]*[_a-zA-Z0-9]*[a-zA-Z0-9]*$|^[A-Z][_A-Z0-9]+[A-Z0-9]$',
45
+ { onlyDeclarations: true, properties: true }
46
+ ],
61
47
  'max-depth': 'error',
62
- 'max-nested-callbacks': 'off',
63
48
  'max-params': ['error', 4],
64
49
  'mocha/no-exclusive-tests': 'error',
65
50
  'mocha/no-identical-title': 'error',
66
51
  'mocha/no-nested-tests': 'error',
67
52
  'mocha/no-sibling-hooks': 'error',
68
53
  'new-cap': 'error',
69
- 'new-parens': 'error',
70
- 'newline-after-var': 'error',
71
- 'newline-before-return': 'error',
72
54
  'no-alert': 'error',
73
55
  'no-array-constructor': 'error',
74
56
  'no-bitwise': 'error',
75
57
  'no-caller': 'error',
76
- 'no-catch-shadow': 'off',
77
58
  'no-cond-assign': ['error', 'always'],
78
- 'no-confusing-arrow': 'error',
79
59
  'no-div-regex': 'error',
80
60
  'no-duplicate-imports': 'error',
81
61
  'no-else-return': 'error',
82
- 'no-empty': 'error',
83
- 'no-empty-label': 'off',
84
62
  'no-eq-null': 'error',
85
63
  'no-eval': 'error',
86
64
  'no-extend-native': 'error',
87
65
  'no-extra-bind': 'error',
88
- 'no-extra-parens': 'error',
89
- 'no-floating-decimal': 'error',
90
66
  'no-implied-eval': 'error',
91
67
  'no-inline-comments': 'error',
92
68
  'no-iterator': 'error',
93
- 'no-label-var': 'off',
94
69
  'no-labels': 'error',
95
70
  'no-lone-blocks': 'error',
96
71
  'no-lonely-if': 'error',
97
72
  'no-loop-func': 'error',
98
73
  'no-mixed-requires': 'error',
99
- 'no-multi-spaces': 'error',
100
74
  'no-multi-str': 'error',
101
- 'no-multiple-empty-lines': ['error', {
102
- max: 1
103
- }],
104
- 'no-native-reassign': 'error',
105
75
  'no-nested-ternary': 'error',
106
76
  'no-new': 'error',
107
77
  'no-new-func': 'error',
@@ -118,16 +88,11 @@ module.exports = {
118
88
  'no-script-url': 'error',
119
89
  'no-self-compare': 'error',
120
90
  'no-sequences': 'error',
121
- 'no-shadow': 'off',
122
- 'no-shadow-restricted-names': 'error',
123
- 'no-spaced-func': 'error',
124
91
  'no-sync': 'error',
92
+ 'no-tabs': ['error', { allowIndentationTabs: true }],
125
93
  'no-throw-literal': 'error',
126
- 'no-trailing-spaces': 'error',
127
94
  'no-undef-init': 'error',
128
- 'no-undefined': 'off',
129
95
  'no-underscore-dangle': 'error',
130
- 'no-unexpected-multiline': 'error',
131
96
  'no-unneeded-ternary': 'error',
132
97
  'no-unused-expressions': 'error',
133
98
  'no-use-before-define': 'error',
@@ -135,60 +100,45 @@ module.exports = {
135
100
  'no-useless-concat': 'error',
136
101
  'no-var': 'error',
137
102
  'no-void': 'error',
138
- 'no-warning-comments': 'off',
139
- 'no-with': 'error',
140
- 'object-curly-spacing': ['error', 'always'],
141
103
  'object-shorthand': 'error',
142
- 'one-var': ['error', 'never'],
143
- 'one-var-declaration-per-line': ['error', 'always'],
144
104
  'operator-assignment': 'error',
145
- 'operator-linebreak': ['error', 'none'],
146
- 'padded-blocks': ['error', 'never'],
147
- 'prefer-arrow-callback': 'error',
105
+ 'padding-line-between-statements': [
106
+ 'error',
107
+ { blankLine: 'always', next: 'return', prev: '*' },
108
+ { blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
109
+ { blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] }
110
+ ],
148
111
  'prefer-const': 'error',
149
- 'prefer-destructuring': ['error', {
150
- AssignmentExpression: {
151
- array: false,
152
- object: false
112
+ 'prefer-destructuring': [
113
+ 'error',
114
+ {
115
+ AssignmentExpression: { array: false, object: false },
116
+ VariableDeclarator: { array: true, object: true }
153
117
  },
154
- VariableDeclarator: {
155
- array: true,
156
- object: true
118
+ {
119
+ enforceForRenamedProperties: false
157
120
  }
158
- }, {
159
- enforceForRenamedProperties: false
160
- }],
121
+ ],
161
122
  'prefer-spread': 'error',
162
123
  'prefer-template': 'error',
163
- 'quote-props': ['error', 'as-needed'],
164
- quotes: ['error', 'single', {
165
- allowTemplateLiterals: true
166
- }],
124
+ 'prettier/prettier': ['error', { arrowParens: 'avoid', printWidth: 120, singleQuote: true, trailingComma: 'none' }],
167
125
  radix: 'error',
126
+ 'require-atomic-updates': 'off',
168
127
  'require-await': 'error',
169
- 'require-yield': 'error',
170
- semi: 'error',
171
- 'semi-spacing': 'error',
172
- 'sort-imports-es6/sort-imports-es6': ['error', {
173
- ignoreCase: false,
174
- ignoreMemberSort: false,
175
- memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
176
- }],
177
- 'sort-keys': ['error', 'asc', {
178
- natural: true
179
- }],
180
- 'space-before-blocks': 'error',
181
- 'space-before-function-paren': ['error', { anonymous: 'never', named: 'never' }],
182
- 'space-in-parens': 'error',
183
- 'space-infix-ops': 'error',
184
- 'space-unary-ops': 'error',
128
+ 'rulesdir/explicit-sinon-use-fake-timers': 'error',
129
+ 'sort-imports-es6/sort-imports-es6': [
130
+ 'error',
131
+ {
132
+ ignoreCase: false,
133
+ ignoreMemberSort: false,
134
+ memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single']
135
+ }
136
+ ],
137
+ 'sort-keys': ['error', 'asc', { natural: true }],
185
138
  'spaced-comment': 'error',
186
139
  'sql-template/no-unsafe-query': 'error',
187
- strict: 'off',
188
- 'template-curly-spacing': 'error',
189
140
  'valid-jsdoc': 'error',
190
141
  'vars-on-top': 'error',
191
- 'wrap-iife': ['error', 'inside'],
192
142
  yoda: 'error'
193
143
  }
194
144
  };
@@ -0,0 +1,50 @@
1
+ 'use strict';
2
+
3
+ // ------------------------------------------------------------------------------
4
+ // Validates that `sinon.useFakeTimers()` is always called with an explicit `toFake` property.
5
+ // ------------------------------------------------------------------------------
6
+
7
+ module.exports = {
8
+ meta: {
9
+ messages: {
10
+ avoidName: 'Calls to `sinon.useFakeTimers()` must provide a `toFake` configuration'
11
+ }
12
+ },
13
+ // eslint-disable-next-line sort-keys
14
+ create(context) {
15
+ return {
16
+ CallExpression(node) {
17
+ if (!node.callee || !node.callee.object || !node.callee.property) {
18
+ return;
19
+ }
20
+
21
+ if (node.callee.object.name === 'sinon' && node.callee.property.name === 'useFakeTimers') {
22
+ if (!node.arguments.length) {
23
+ context.report({
24
+ message: 'Must pass an object with `toFake` configuration',
25
+ node
26
+ });
27
+ }
28
+
29
+ for (const argument of node.arguments) {
30
+ if (argument.type === 'ObjectExpression') {
31
+ if (!argument.properties.find(({ key: { name } }) => name === 'toFake')) {
32
+ context.report({
33
+ message: 'Object must contain `toFake` configuration',
34
+ node
35
+ });
36
+ }
37
+
38
+ continue;
39
+ }
40
+
41
+ context.report({
42
+ message: 'Not an object',
43
+ node
44
+ });
45
+ }
46
+ }
47
+ }
48
+ };
49
+ }
50
+ };
package/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: node_js
2
-
3
- cache: yarn
4
-
5
- node_js:
6
- - 6
7
- - 8
8
- - 10
9
-
10
- script:
11
- - yarn lint
12
- - yarn test
package/CHANGELOG.md DELETED
@@ -1,21 +0,0 @@
1
- # Changelog
2
-
3
- ## [v0.2.0](https://github.com/uphold/eslint-config-uphold/releases/tag/v0.2.0) (2018-07-16)
4
- - Add @uphold/github-changelog-generator [\#13](https://github.com/uphold/eslint-config-uphold/pull/13) ([Americas](https://github.com/Americas))
5
- - Replace drone with travis [\#10](https://github.com/uphold/eslint-config-uphold/pull/10) ([Americas](https://github.com/Americas))
6
- - Add pre-commit lint hook [\#12](https://github.com/uphold/eslint-config-uphold/pull/12) ([Americas](https://github.com/Americas))
7
- - Raise minimum node engine requirement to 6 [\#11](https://github.com/uphold/eslint-config-uphold/pull/11) ([Americas](https://github.com/Americas))
8
- - Fix linting errors [\#9](https://github.com/uphold/eslint-config-uphold/pull/9) ([Americas](https://github.com/Americas))
9
- - Add new mocha rules [\#8](https://github.com/uphold/eslint-config-uphold/pull/8) ([rplopes](https://github.com/rplopes))
10
- - Update eslint-plugin-mocha@^5.1.0 [\#7](https://github.com/uphold/eslint-config-uphold/pull/7) ([Americas](https://github.com/Americas))
11
-
12
- ## [v0.1.1](https://github.com/uphold/eslint-config-uphold/releases/tag/v0.1.1) (2018-03-20)
13
- - Allow computed properties in prefer destructuring [\#5](https://github.com/uphold/eslint-config-uphold/pull/5) ([nunofgs](https://github.com/nunofgs))
14
-
15
- ## [v0.1.0](https://github.com/uphold/eslint-config-uphold/releases/tag/v0.1.0) (2017-12-26)
16
- - Add `jasmine` and `jest` to eslint environments [\#4](https://github.com/uphold/eslint-config-uphold/pull/4) ([nunofgs](https://github.com/nunofgs))
17
-
18
- ## [v0.0.1](https://github.com/uphold/eslint-config-uphold/releases/tag/v0.0.1) (2017-09-07)
19
- - Add prefer-destructuring rule [\#2](https://github.com/uphold/eslint-config-uphold/pull/2) ([nunofgs](https://github.com/nunofgs))
20
- - Replace travis with drone [\#3](https://github.com/uphold/eslint-config-uphold/pull/3) ([franciscocardoso](https://github.com/franciscocardoso))
21
- - Update eslint@4.4.1 [\#1](https://github.com/uphold/eslint-config-uphold/pull/1) ([nunofgs](https://github.com/nunofgs))