@jsimck/eslint-config 1.0.1 → 1.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/rules/react.js +156 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsimck/eslint-config",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Very opinionated eslint config I use on my projects, includes: prettier, TS, jest, sonarqube and plugin-unicorn. It uses new eslint flat config.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -9,7 +9,7 @@
9
9
  "eslint": "^8.35.0"
10
10
  },
11
11
  "scripts": {
12
- "release": "changeset version && changeset publish",
12
+ "release": "changeset publish",
13
13
  "changeset": "changeset add",
14
14
  "lint": "eslint './**/*.{js,ts,jsx,tsx,cjs,mjs}'"
15
15
  },
package/rules/react.js CHANGED
@@ -6,5 +6,161 @@ export default [
6
6
  files: ['**/*.jsx', '**/*.tsx'],
7
7
  ...reactRecommended,
8
8
  ...reactJsxRuntime,
9
+ rules: {
10
+ 'react/boolean-prop-naming': [
11
+ 'error',
12
+ {
13
+ message:
14
+ 'Invalid boolean prop name, use one of (is|has|show|hide) prefixes.',
15
+ propTypeNames: ['bool', 'mutuallyExclusiveTrueProps'],
16
+ rule: '^(is|has|show|hide)[A-Z]([A-Za-z0-9]?)+',
17
+ },
18
+ ],
19
+ 'react/default-props-match-prop-types': [
20
+ 'error',
21
+ { allowRequiredDefaults: true },
22
+ ],
23
+ 'react/display-name': ['off'],
24
+ 'react/function-component-definition': [
25
+ 'error',
26
+ {
27
+ namedComponents: 'function-declaration',
28
+ unnamedComponents: 'arrow-function',
29
+ },
30
+ ],
31
+ 'react/hook-use-state': ['warn', { allowDestructuredState: true }],
32
+ 'react/no-access-state-in-setstate': 'error',
33
+ 'react/no-adjacent-inline-elements': 'error',
34
+ 'react/no-array-index-key': 'warn',
35
+ 'react/no-arrow-function-lifecycle': 'error',
36
+ 'react/no-did-update-set-state': 'error',
37
+ 'react/no-find-dom-node': 'error',
38
+ 'react/no-multi-comp': 'error',
39
+ 'react/no-namespace': 'error',
40
+ 'react/no-redundant-should-component-update': 'error',
41
+ 'react/no-invalid-html-attribute': 'error',
42
+ 'react/no-this-in-sfc': 'error',
43
+ 'react/no-typos': 'error',
44
+ 'react/no-unsafe': 'error',
45
+ 'react/no-unstable-nested-components': 'error',
46
+ 'react/no-unused-class-component-methods': 'warn',
47
+ 'react/no-unused-prop-types': [
48
+ 'error',
49
+ {
50
+ customValidators: [],
51
+ skipShapeProps: true,
52
+ },
53
+ ],
54
+ 'react/no-unused-state': 'error',
55
+ 'react/no-will-update-set-state': 'error',
56
+ 'react/prefer-es6-class': ['error', 'always'],
57
+ 'react/prefer-stateless-function': 'error',
58
+ 'react/prop-types': [
59
+ 'warn',
60
+ {
61
+ customValidators: [],
62
+ ignore: [],
63
+ skipUndeclared: false,
64
+ },
65
+ ],
66
+ 'react/require-render-return': 'error',
67
+ 'react/no-unknown-property': 'warn',
68
+ 'react/self-closing-comp': 'error',
69
+ 'react/state-in-constructor': ['error', 'always'],
70
+ 'react/static-property-placement': [
71
+ 'error',
72
+ 'property assignment',
73
+ {
74
+ childContextTypes: 'static getter',
75
+ contextType: 'static getter',
76
+ contextTypes: 'static getter',
77
+ defaultProps: 'static getter',
78
+ displayName: 'static getter',
79
+ propTypes: 'static getter',
80
+ },
81
+ ],
82
+ 'react/style-prop-object': 'error',
83
+ 'react/void-dom-elements-no-children': 'error',
84
+
85
+ // jsx specifics
86
+ 'react/jsx-boolean-value': [
87
+ 'error',
88
+ 'never',
89
+ {
90
+ always: [],
91
+ },
92
+ ],
93
+ 'react/jsx-child-element-spacing': 'error',
94
+ 'react/jsx-closing-bracket-location': ['error', 'tag-aligned'],
95
+ 'react/jsx-closing-tag-location': 'error',
96
+ 'react/jsx-curly-brace-presence': [
97
+ 'error',
98
+ {
99
+ children: 'never',
100
+ props: 'never',
101
+ },
102
+ ],
103
+ 'react/jsx-curly-newline': [
104
+ 'error',
105
+ {
106
+ multiline: 'consistent',
107
+ singleline: 'consistent',
108
+ },
109
+ ],
110
+ 'react/jsx-filename-extension': [
111
+ 'error',
112
+ {
113
+ extensions: ['.jsx', '.tsx'],
114
+ },
115
+ ],
116
+ 'react/jsx-first-prop-new-line': ['error', 'multiline-multiprop'],
117
+ 'react/jsx-fragments': ['error', 'syntax'],
118
+ 'react/jsx-handler-names': [
119
+ 'warn',
120
+ {
121
+ eventHandlerPrefix: 'handle',
122
+ eventHandlerPropPrefix: 'on',
123
+ checkLocalVariables: true,
124
+ checkInlineFunction: true,
125
+ },
126
+ ],
127
+ 'react/jsx-max-props-per-line': [
128
+ 'error',
129
+ {
130
+ maximum: 1,
131
+ when: 'multiline',
132
+ },
133
+ ],
134
+ 'react/jsx-newline': ['error', { prevent: true }],
135
+ 'react/jsx-no-constructed-context-values': 'error',
136
+ 'react/jsx-no-script-url': 'error',
137
+ 'react/jsx-no-useless-fragment': 'error',
138
+ 'react/jsx-one-expression-per-line': [
139
+ 'error',
140
+ {
141
+ allow: 'single-child',
142
+ },
143
+ ],
144
+ 'react/jsx-pascal-case': [
145
+ 'error',
146
+ {
147
+ allowAllCaps: true,
148
+ ignore: [],
149
+ },
150
+ ],
151
+ 'react/jsx-props-no-multi-spaces': 'error',
152
+ 'react/jsx-wrap-multilines': [
153
+ 'error',
154
+ {
155
+ arrow: 'parens-new-line',
156
+ assignment: 'parens-new-line',
157
+ condition: 'parens-new-line',
158
+ declaration: 'parens-new-line',
159
+ logical: 'parens-new-line',
160
+ prop: 'parens-new-line',
161
+ return: 'parens-new-line',
162
+ },
163
+ ],
164
+ },
9
165
  },
10
166
  ];