@averay/codeformat 0.1.6 → 0.1.8

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/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ /* eslint sort-keys: "error" -- Organise rules */
2
+
1
3
  import typescriptPlugin from '@typescript-eslint/eslint-plugin';
2
4
  import typescriptParser from '@typescript-eslint/parser';
3
5
  import prettierConfig from 'eslint-config-prettier';
@@ -24,6 +26,11 @@ export function makeEslintConfig(options = {}) {
24
26
  // JavaScript & TypeScript
25
27
  {
26
28
  files: [`**/*.{${[...extensions.js, ...extensions.ts].join(',')}}`],
29
+ languageOptions: {
30
+ parserOptions: {
31
+ ...importPlugin.configs.recommended.parserOptions,
32
+ },
33
+ },
27
34
  plugins: {
28
35
  'eslint-comments': eslintCommentsPlugin,
29
36
  import: importPlugin,
@@ -32,17 +39,12 @@ export function makeEslintConfig(options = {}) {
32
39
  sonarjs: sonarjsPlugin,
33
40
  unicorn: unicornPlugin,
34
41
  },
35
- languageOptions: {
36
- parserOptions: {
37
- ...importPlugin.configs.recommended.parserOptions,
38
- },
39
- },
42
+ rules: convertWarnsToErrors(rulesetShared),
40
43
  settings: {
41
44
  'import/parsers': {
42
45
  espree: extensions.js.map((extension) => `.${extension}`),
43
46
  },
44
47
  },
45
- rules: convertWarnsToErrors(rulesetShared),
46
48
  },
47
49
 
48
50
  // TypeScript
@@ -55,13 +57,13 @@ export function makeEslintConfig(options = {}) {
55
57
  plugins: {
56
58
  '@typescript-eslint': typescriptPlugin,
57
59
  },
60
+ rules: convertWarnsToErrors(rulesetTypescript),
58
61
  settings: {
59
62
  ...importPlugin.configs.typescript.settings,
60
63
  'import/parsers': {
61
64
  '@typescript-eslint/parser': extensions.ts.map((extension) => `.${extension}`),
62
65
  },
63
66
  },
64
- rules: convertWarnsToErrors(rulesetTypescript),
65
67
  },
66
68
 
67
69
  prettierConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@averay/codeformat",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "author": "Adam Averay (https://adamaveray.com.au/)",
5
5
  "homepage": "https://github.com/adamaveray/codeformat",
6
6
  "repository": {
@@ -29,7 +29,7 @@ export default {
29
29
  'global-require': 'error',
30
30
  'grouped-accessor-pairs': ['error', 'getBeforeSet'],
31
31
  'guard-for-in': 'error',
32
- 'id-denylist': ['error', 'e', 'err', 'evt', 'cb'],
32
+ 'id-denylist': ['error', 'cb', 'e', 'enc', 'err', 'evt'],
33
33
  'lines-between-class-members': 'error',
34
34
  'logical-assignment-operators': ['error', 'always'],
35
35
  'max-classes-per-file': ['error', 1],
@@ -165,7 +165,14 @@ export default {
165
165
  'no-unused-expressions': 'error',
166
166
  'no-unused-labels': 'error',
167
167
  'no-unused-private-class-members': 'error',
168
- 'no-unused-vars': 'error',
168
+ 'no-unused-vars': [
169
+ 'error',
170
+ {
171
+ argsIgnorePattern: '^_\\w*$',
172
+ caughtErrorsIgnorePattern: '^_\\w*$',
173
+ varsIgnorePattern: '^(_\\d*|React)$',
174
+ },
175
+ ],
169
176
  'no-use-before-define': 'error',
170
177
  'no-useless-backreference': 'error',
171
178
  'no-useless-call': 'error',
@@ -12,6 +12,31 @@ export default {
12
12
  ...typescriptPlugin.configs['recommended-requiring-type-checking'].rules,
13
13
  ...typescriptPlugin.configs.strict.rules,
14
14
 
15
+ // eslint-disable-next-line unicorn/no-useless-spread -- Keeps the unprefixed core rules together
16
+ ...{
17
+ 'default-param-last': 'off',
18
+ 'dot-notation': 'off',
19
+ 'lines-between-class-members': 'off',
20
+ 'no-array-constructor': 'off',
21
+ 'no-dupe-class-members': 'off',
22
+ 'no-empty-function': 'off',
23
+ 'no-implied-eval': 'off',
24
+ 'no-invalid-this': 'off',
25
+ 'no-loop-func': 'off',
26
+ 'no-loss-of-precision': 'off',
27
+ 'no-magic-numbers': 'off',
28
+ 'no-redeclare': 'off',
29
+ 'no-restricted-imports': 'off',
30
+ 'no-return-await': 'off',
31
+ 'no-shadow': 'off',
32
+ 'no-throw-literal': 'off',
33
+ 'no-unused-expressions': 'off',
34
+ 'no-unused-vars': 'off',
35
+ 'no-use-before-define': 'off',
36
+ 'no-useless-constructor': 'off',
37
+ 'padding-line-between-statements': 'off',
38
+ },
39
+
15
40
  '@typescript-eslint/adjacent-overload-signatures': 'error',
16
41
  '@typescript-eslint/array-type': 'error',
17
42
  '@typescript-eslint/await-thenable': 'error',
@@ -112,6 +137,17 @@ export default {
112
137
  '@typescript-eslint/no-invalid-void-type': 'error',
113
138
  '@typescript-eslint/no-loop-func': 'error',
114
139
  '@typescript-eslint/no-loss-of-precision': 'error',
140
+ '@typescript-eslint/no-magic-numbers': [
141
+ 'error',
142
+ {
143
+ detectObjects: true,
144
+ enforceConst: true,
145
+ ignore: [-1, 0, 1],
146
+ ignoreArrayIndexes: true,
147
+ ignoreClassFieldInitialValues: true,
148
+ ignoreDefaultValues: true,
149
+ },
150
+ ],
115
151
  '@typescript-eslint/no-meaningless-void-operator': 'error',
116
152
  '@typescript-eslint/no-misused-new': 'error',
117
153
  '@typescript-eslint/no-misused-promises': 'error',
@@ -122,7 +158,7 @@ export default {
122
158
  '@typescript-eslint/no-redeclare': 'error',
123
159
  '@typescript-eslint/no-require-imports': 'error',
124
160
  '@typescript-eslint/no-restricted-imports': 'error',
125
- '@typescript-eslint/no-shadow': 'error',
161
+ '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
126
162
  '@typescript-eslint/no-this-alias': 'error',
127
163
  '@typescript-eslint/no-throw-literal': 'error',
128
164
  '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
@@ -175,7 +211,10 @@ export default {
175
211
  '@typescript-eslint/restrict-plus-operands': 'error',
176
212
  '@typescript-eslint/restrict-template-expressions': 'error',
177
213
  '@typescript-eslint/return-await': 'error',
178
- '@typescript-eslint/strict-boolean-expressions': ['error', { allowNullableString: true }],
214
+ '@typescript-eslint/strict-boolean-expressions': [
215
+ 'error',
216
+ { allowNullableObject: false, allowNullableString: false, allowNumber: false, allowString: false },
217
+ ],
179
218
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
180
219
  '@typescript-eslint/triple-slash-reference': 'error',
181
220
  '@typescript-eslint/unbound-method': 'off', // Does not support @autobind nor recognise binding in constructors