@timobechtel/style 1.14.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.
@@ -1,39 +0,0 @@
1
- // @ts-check
2
- const { defineConfig } = require('eslint-define-config');
3
-
4
- module.exports = defineConfig({
5
- rules: {
6
- // Disallow non-import statements appearing before import statements.
7
- 'import/first': 'error',
8
- // Require a newline after the last import/require.
9
- 'import/newline-after-import': 'warn',
10
- // Disallow a module from importing itself.
11
- 'import/no-self-import': 'error',
12
- // Ensures that there are no useless path segments.
13
- 'import/no-useless-path-segments': ['error'],
14
- // Enforce a module import order convention.
15
- 'import/order': [
16
- 'warn',
17
- {
18
- groups: [
19
- 'builtin', // Node.js built-in modules
20
- 'external', // Packages
21
- 'internal', // Aliased modules
22
- 'parent', // Relative parent
23
- 'sibling', // Relative sibling
24
- 'index', // Relative index
25
- ],
26
- },
27
- ],
28
- // allow default exports
29
- 'import/no-default-export': 'off',
30
- /**
31
- * These are enabled by `import/recommended`, but are better handled by
32
- * TypeScript and @typescript-eslint.
33
- */
34
- 'import/default': 'off',
35
- 'import/export': 'off',
36
- 'import/namespace': 'off',
37
- 'import/no-unresolved': 'off',
38
- },
39
- });
@@ -1,90 +0,0 @@
1
- // @ts-check
2
- const { defineConfig } = require('eslint-define-config');
3
-
4
- module.exports = defineConfig({
5
- rules: {
6
- // We should prefer TypeScript over prop-types.
7
- 'react/prop-types': 'off',
8
- // Disable requiring React to be imported, as this is no longer required.
9
- 'react/react-in-jsx-scope': 'off',
10
- /**
11
- * Require an explicit type when using button elements. Prevents common mistakes where `type="button"` is omitted on `<button>` elements.
12
- */
13
- 'react/button-has-type': 'error',
14
- /**
15
- * Require consistent function type for function components.
16
- */
17
- 'react/function-component-definition': 'warn',
18
- /**
19
- * Require destructuring and symmetric naming of `useState` hook value and setter variables.
20
- */
21
- 'react/hook-use-state': 'warn',
22
- /**
23
- * Require consistent boolean attributes notation in JSX.
24
- */
25
- 'react/jsx-boolean-value': 'warn',
26
- /**
27
- * Disallow unnecessary curly braces in JSX props and children.
28
- */
29
- 'react/jsx-curly-brace-presence': [
30
- 'warn',
31
- {
32
- props: 'never',
33
- children: 'ignore',
34
- propElementValues: 'always',
35
- },
36
- ],
37
- /**
38
- * Require using shorthand form for React fragments, unless required.
39
- */
40
- 'react/jsx-fragments': 'warn',
41
- /**
42
- * Prevent problematic leaked values from being rendered.
43
- */
44
- 'react/jsx-no-leaked-render': 'error',
45
- /**
46
- * Prevents usage of unsafe `target='_blank'`.
47
- *
48
- * This rule is a part of `react/recommended`, but modified to
49
- * enable allowReferrer.
50
- */
51
- 'react/jsx-no-target-blank': [
52
- 'error',
53
- {
54
- allowReferrer: true,
55
- },
56
- ],
57
- /**
58
- * Disallow empty React fragments.
59
- */
60
- 'react/jsx-no-useless-fragment': ['warn', { allowExpressions: true }],
61
- /**
62
- * Require the use of PascalCase for user-defined JSX components.
63
- */
64
- 'react/jsx-pascal-case': 'warn',
65
- /**
66
- * Require props to be sorted alphabetically.
67
- */
68
- 'react/jsx-sort-props': [
69
- 'warn',
70
- {
71
- // list callbacks after all other props
72
- callbacksLast: true,
73
- },
74
- ],
75
- /**
76
- * Disallow creating unstable components inside components.
77
- */
78
- 'react/no-unstable-nested-components': 'error',
79
- /**
80
- * Disallow closing tags for components without children.
81
- */
82
- 'react/self-closing-comp': 'warn',
83
- /**
84
- * Enforce exhaustive dependencies in `useEffect` and `useCallback` hooks.
85
- */
86
- 'react-hooks/exhaustive-deps': 'error',
87
- // prefer destructuring props
88
- 'react/destructuring-assignment': ['warn', 'always'],
89
- },
90
- });
@@ -1,108 +0,0 @@
1
- const { defineConfig } = require('eslint-define-config');
2
- const noUnusedVarsConfig = require('./base.cjs').rules['no-unused-vars'];
3
-
4
- // @ts-check
5
- module.exports = defineConfig({
6
- rules: {
7
- // Require consistent usage of type exports.
8
- '@typescript-eslint/consistent-type-exports': [
9
- 'error',
10
- { fixMixedExportsWithInlineTypeSpecifier: true },
11
- ],
12
- // Require consistent usage of type imports.
13
- '@typescript-eslint/consistent-type-imports': [
14
- 'error',
15
- {
16
- prefer: 'type-imports',
17
- fixStyle: 'inline-type-imports',
18
- },
19
- ],
20
- /**
21
- * Require using function property types in method signatures.
22
- * These have enhanced typechecking, whereas method signatures do not.
23
- */
24
- '@typescript-eslint/method-signature-style': 'error',
25
- /**
26
- * Require consistent naming conventions.
27
- * Improves IntelliSense suggestions and avoids name collisions.
28
- */
29
- '@typescript-eslint/naming-convention': [
30
- 'error',
31
- // Anything type-like should be written in PascalCase.
32
- {
33
- format: ['PascalCase'],
34
- selector: ['typeLike', 'enumMember'],
35
- },
36
- // Interfaces cannot be prefixed with `I`, or have restricted names.
37
- {
38
- custom: {
39
- match: false,
40
- regex: '^I[A-Z]|^(Interface|Props|State)$',
41
- },
42
- format: ['PascalCase'],
43
- selector: 'interface',
44
- },
45
- ],
46
- // Disallow members of unions and intersections that do nothing or override type information.
47
- '@typescript-eslint/no-redundant-type-constituents': 'error',
48
- // Require using `RegExp.exec()` over `String.match()` for consistency.
49
- '@typescript-eslint/prefer-regexp-exec': 'warn',
50
- //
51
- '@typescript-eslint/require-array-sort-compare': [
52
- 'error',
53
- { ignoreStringArrays: true },
54
- ],
55
- /**
56
- * Require exhaustive checks when using union types in switch statements.
57
- * This ensures cases are considered when items are later added to a union.
58
- */
59
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
60
- // Require default parameters to be last.
61
- 'default-param-last': 'off',
62
- '@typescript-eslint/default-param-last': 'error',
63
- // Disallow creation of functions within loops.
64
- 'no-loop-func': 'off',
65
- '@typescript-eslint/no-loop-func': 'error',
66
- // Disallow unused variables.
67
- 'no-unused-vars': 'off',
68
- '@typescript-eslint/no-unused-vars': noUnusedVarsConfig,
69
-
70
- /**
71
- * These are enabled by `import/recommended`, but are better handled by
72
- * TypeScript and @typescript-eslint.
73
- */
74
- 'import/default': 'off',
75
- 'import/export': 'off',
76
- 'import/namespace': 'off',
77
- 'import/no-unresolved': 'off',
78
-
79
- // This is disabled as I feel that checking empty strings is a valid use
80
- // of `||` over `??`.
81
- '@typescript-eslint/prefer-nullish-coalescing': 'off',
82
-
83
- // Disallow Promises in places not designed to handle them.
84
- '@typescript-eslint/no-misused-promises': [
85
- 'error',
86
- {
87
- // Disabled as I feel that passing a async callback to a function expecting
88
- // a void callback is a valid use case.
89
- // e.g. fn.on('event', async () => {})
90
- // Strictly requiring to return 'undefined' does not have a functional benefit,
91
- // but makes the code more verbose.
92
- checksVoidReturn: false,
93
- },
94
- ],
95
- // While I'd prefer using types over interfaces, there are a lot of cases
96
- // where interfaces are needed, e.g. merging declarations and this rule is too strict.
97
- '@typescript-eslint/consistent-type-definitions': 'off',
98
- // while using property signatures provides better typechecking,
99
- // method signatures provide better hinting in the editor.
100
- // (different color for methods vs properties)
101
- '@typescript-eslint/method-signature-style': 'off',
102
- // There are cases where using the index signature is more descriptive
103
- // as the index can be named
104
- '@typescript-eslint/consistent-indexed-object-style': 'off',
105
- // Enforce using a top-level type qualifier for imports when only types are imported using the inline type qualifier
106
- '@typescript-eslint/no-import-type-side-effects': 'error',
107
- },
108
- });
@@ -1,129 +0,0 @@
1
- // @ts-check
2
- const { defineConfig } = require('eslint-define-config');
3
-
4
- module.exports = defineConfig({
5
- plugins: ['unicorn'],
6
- rules: {
7
- // Use destructured variables over properties.
8
- 'unicorn/consistent-destructuring': 'warn',
9
- // Move function definitions to the highest possible scope.
10
- 'unicorn/consistent-function-scoping': [
11
- 'warn',
12
- {
13
- checkArrowFunctions: false,
14
- },
15
- ],
16
- // Enforce passing a message value when creating a built-in error.
17
- 'unicorn/error-message': 'error',
18
- // Require escape sequences to use uppercase values.
19
- 'unicorn/escape-case': 'warn',
20
- // Disallow empty files.
21
- 'unicorn/no-empty-file': 'error',
22
- // Do not use a for loop that can be replaced with a for-of loop.
23
- 'unicorn/no-for-loop': 'warn',
24
- // Require Array.isArray() instead of instanceof Array.
25
- 'unicorn/no-instanceof-array': 'error',
26
- // Prevent calling EventTarget#removeEventListener() with the result of an expression.
27
- 'unicorn/no-invalid-remove-event-listener': 'error',
28
- // Disallow the use of objects as default parameters.
29
- 'unicorn/no-object-as-default-parameter': 'error',
30
- // Disallow then property.
31
- 'unicorn/no-thenable': 'error',
32
- // Disallow awaiting non-promise values.
33
- 'unicorn/no-unnecessary-await': 'error',
34
- // Disallow unreadable IIFEs.
35
- 'unicorn/no-unreadable-iife': 'warn',
36
- // Disallow useless fallback when spreading in object literals.
37
- 'unicorn/no-useless-fallback-in-spread': 'warn',
38
- // Disallow useless array length check.
39
- 'unicorn/no-useless-length-check': 'warn',
40
- // Disallow returning/yielding Promise.resolve/reject() in async functions or promise callbacks
41
- 'unicorn/no-useless-promise-resolve-reject': 'error',
42
- // Disallow unnecessary spread.
43
- 'unicorn/no-useless-spread': 'error',
44
- // Disallow number literals with zero fractions or dangling dots.
45
- 'unicorn/no-zero-fractions': 'warn',
46
- // Enforce the style of numeric separators by correctly grouping digits.
47
- 'unicorn/numeric-separators-style': 'error',
48
- // Prefer .addEventListener() and .removeEventListener() over on-functions.
49
- 'unicorn/prefer-add-event-listener': 'error',
50
- // Prefer .find(…) and .findLast(…) over the first or last element from .filter(…).
51
- 'unicorn/prefer-array-find': 'error',
52
- // Prefer Array#flat() over legacy techniques to flatten arrays.
53
- 'unicorn/prefer-array-flat': 'error',
54
- // Prefer .flatMap(…) over .map(…).flat().
55
- 'unicorn/prefer-array-flat-map': 'error',
56
- // Prefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item.
57
- 'unicorn/prefer-array-index-of': 'error',
58
- // Prefer .some(…) over .filter(…).length check and .{find,findLast}(…).
59
- 'unicorn/prefer-array-some': 'error',
60
- // Prefer .at() method for index access and String#charAt().
61
- 'unicorn/prefer-at': 'error',
62
- // Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…).
63
- 'unicorn/prefer-blob-reading-methods': 'error',
64
- // Prefer Date.now() to get the number of milliseconds since the Unix Epoch.
65
- 'unicorn/prefer-date-now': 'error',
66
- // Prefer default parameters over reassignment.
67
- 'unicorn/prefer-default-parameters': 'warn',
68
- // Prefer Node#append() over Node#appendChild().
69
- 'unicorn/prefer-dom-node-append': 'error',
70
- // Prefer using .dataset on DOM elements over calling attribute methods.
71
- 'unicorn/prefer-dom-node-dataset': 'error',
72
- // Prefer childNode.remove() over parentNode.removeChild(childNode).
73
- 'unicorn/prefer-dom-node-remove': 'error',
74
- // Prefer EventTarget over EventEmitter.
75
- 'unicorn/prefer-event-target': 'warn',
76
- // Prefer export…from when re-exporting.
77
- 'unicorn/prefer-export-from': [
78
- 'warn',
79
- {
80
- ignoreUsedVariables: true,
81
- },
82
- ],
83
- // Prefer .includes() over .indexOf() and Array#some() when checking for existence or non-existence.
84
- 'unicorn/prefer-includes': 'error',
85
- // Prefer KeyboardEvent#key over KeyboardEvent#keyCode.
86
- 'unicorn/prefer-keyboard-event-key': 'error',
87
- // Prefer using a logical operator over a ternary.
88
- 'unicorn/prefer-logical-operator-over-ternary': 'error',
89
- // Enforce the use of Math.trunc instead of bitwise operators.
90
- 'unicorn/prefer-math-trunc': 'error',
91
- // Prefer .before() over .insertBefore(), .replaceWith() over .replaceChild(), prefer one of .before(), .after(), .append() or .prepend() over insertAdjacentText() and insertAdjacentElement().
92
- 'unicorn/prefer-modern-dom-apis': 'error',
93
- // Prefer modern Math APIs over legacy patterns.
94
- 'unicorn/prefer-modern-math-apis': 'error',
95
- // Prefer negative index over .length - index when possible.
96
- 'unicorn/prefer-negative-index': 'error',
97
- // Require using the `node:` protocol when importing Node.js built-in modules.
98
- 'unicorn/prefer-node-protocol': 'error',
99
- // Prefer Number static properties over global ones.
100
- 'unicorn/prefer-number-properties': ['error', { checkInfinity: false }],
101
- // Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object.
102
- 'unicorn/prefer-object-from-entries': 'error',
103
- // Prefer Reflect.apply() over Function#apply().
104
- 'unicorn/prefer-reflect-apply': 'error',
105
- // using RegExp.test() is faster than string.match()
106
- // note: you should not use the global flag /g with RegExp.test() though!
107
- 'unicorn/prefer-regexp-test': 'error',
108
- // Prefer Set#has() over Array#includes() when checking for existence or non-existence.
109
- 'unicorn/prefer-set-has': 'error',
110
- // Prefer using Set#size instead of Array#length.
111
- 'unicorn/prefer-set-size': 'error',
112
- // Prefer the spread operator over Array.from().
113
- 'unicorn/prefer-spread': 'error',
114
- // Prefer String#replaceAll() over regex searches with the global flag.
115
- 'unicorn/prefer-string-replace-all': 'error',
116
- // Prefer String#slice() over String#substr() and String#substring().
117
- 'unicorn/prefer-string-slice': 'error',
118
- // Prefer String#startsWith() & String#endsWith() over RegExp#test().
119
- 'unicorn/prefer-string-starts-ends-with': 'error',
120
- // Prefer ternary expressions over simple if-else statements.
121
- 'unicorn/prefer-ternary': ['warn', 'only-single-line'],
122
- // Prefer top-level await over top-level promises and async function calls.
123
- 'unicorn/prefer-top-level-await': 'error',
124
- // Enforce using the separator argument with Array#join().
125
- 'unicorn/require-array-join-separator': 'error',
126
- // Enforce consistent brace style for case clauses.
127
- 'unicorn/switch-case-braces': 'error',
128
- },
129
- });