@w5s/eslint-config 1.0.0-alpha.1

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/rules/react.js ADDED
@@ -0,0 +1,176 @@
1
+ const { off, warn, error } = require('./_rule');
2
+
3
+ module.exports = {
4
+ plugins: ['react'],
5
+ rules: {
6
+ 'react/boolean-prop-naming': off,
7
+ 'react/button-has-type': error,
8
+ 'react/default-props-match-prop-types': off,
9
+ 'react/destructuring-assignment': off,
10
+ 'react/display-name': off,
11
+ 'react/forbid-component-props': off,
12
+ 'react/forbid-dom-props': off,
13
+ 'react/forbid-elements': off,
14
+ 'react/forbid-foreign-prop-types': off,
15
+ 'react/forbid-prop-types': off,
16
+ 'react/jsx-boolean-value': [error, 'never'],
17
+ 'react/jsx-child-element-spacing': off,
18
+ 'react/jsx-closing-bracket-location': off,
19
+ 'react/jsx-closing-tag-location': off,
20
+ 'react/jsx-curly-brace-presence': off,
21
+ 'react/jsx-curly-newline': error,
22
+ 'react/jsx-curly-spacing': [
23
+ error,
24
+ 'never',
25
+ {
26
+ allowMultiline: true,
27
+ },
28
+ ],
29
+ 'react/jsx-equals-spacing': [error, 'never'],
30
+ 'react/jsx-first-prop-new-line': [error, 'multiline-multiprop'],
31
+ 'react/jsx-fragments': [error, 'syntax'],
32
+ 'react/jsx-handler-names': [
33
+ error,
34
+ {
35
+ checkInlineFunction: false,
36
+ checkLocalVariables: false,
37
+ eventHandlerPrefix: 'handle',
38
+ eventHandlerPropPrefix: 'on',
39
+ },
40
+ ],
41
+ 'react/jsx-indent': [error, 2],
42
+ 'react/jsx-indent-props': [error, 2],
43
+ 'react/jsx-key': error,
44
+ 'react/jsx-max-props-per-line': [
45
+ error,
46
+ {
47
+ maximum: 3,
48
+ when: 'multiline',
49
+ },
50
+ ],
51
+ 'react/jsx-no-bind': [
52
+ 'error',
53
+ {
54
+ allowArrowFunctions: true,
55
+ allowBind: false,
56
+ ignoreRefs: true,
57
+ },
58
+ ],
59
+ 'react/jsx-no-comment-textnodes': error,
60
+ 'react/jsx-no-duplicate-props': error,
61
+ 'react/jsx-no-literals': off,
62
+ 'react/jsx-no-target-blank': error,
63
+ 'react/jsx-no-undef': error,
64
+ 'react/jsx-one-expression-per-line': off,
65
+ 'react/jsx-pascal-case': error,
66
+ 'react/jsx-props-no-multi-spaces': error,
67
+ 'react/jsx-props-no-spreading': off,
68
+ 'react/jsx-sort-default-props': error,
69
+ 'react/jsx-sort-props': [
70
+ 'error',
71
+ {
72
+ callbacksLast: false,
73
+ ignoreCase: true,
74
+ noSortAlphabetically: false,
75
+ reservedFirst: true,
76
+ shorthandFirst: false,
77
+ shorthandLast: false,
78
+ },
79
+ ],
80
+ 'react/jsx-tag-spacing': [
81
+ error,
82
+ {
83
+ afterOpening: 'never',
84
+ beforeSelfClosing: 'always',
85
+ closingSlash: 'never',
86
+ },
87
+ ],
88
+ 'react/jsx-uses-react': warn,
89
+ 'react/jsx-uses-vars': warn,
90
+ 'react/jsx-wrap-multilines': off,
91
+ 'react/no-access-state-in-setstate': error,
92
+ 'react/no-array-index-key': error,
93
+ 'react/no-children-prop': error,
94
+ 'react/no-danger': error,
95
+ 'react/no-danger-with-children': error,
96
+ 'react/no-deprecated': error,
97
+ 'react/no-did-mount-set-state': error,
98
+ 'react/no-did-update-set-state': error,
99
+ 'react/no-direct-mutation-state': error,
100
+ 'react/no-find-dom-node': error,
101
+ 'react/no-is-mounted': error,
102
+ 'react/no-multi-comp': off,
103
+ 'react/no-redundant-should-component-update': error,
104
+ 'react/no-set-state': off,
105
+ 'react/no-string-refs': error,
106
+ 'react/no-this-in-sfc': error,
107
+ 'react/no-typos': error,
108
+ 'react/no-unescaped-entities': error,
109
+ 'react/no-unknown-property': error,
110
+ 'react/no-unsafe': error,
111
+ 'react/no-unused-prop-types': error,
112
+ 'react/no-unused-state': error,
113
+ 'react/no-will-update-set-state': error,
114
+ 'react/prefer-es6-class': error,
115
+ 'react/prefer-read-only-props': warn,
116
+ 'react/prefer-stateless-function': off,
117
+ 'react/prop-types': off,
118
+ 'react/react-in-jsx-scope': error,
119
+ 'react/require-default-props': off,
120
+ 'react/require-render-return': error,
121
+ 'react/self-closing-comp': error,
122
+ 'react/sort-comp': [
123
+ 'error',
124
+ {
125
+ groups: {
126
+ lifecycle: [
127
+ 'displayName',
128
+ 'propTypes',
129
+ 'contextTypes',
130
+ 'childContextTypes',
131
+ 'mixins',
132
+ 'statics',
133
+ 'defaultProps',
134
+ 'constructor',
135
+ 'getDefaultProps',
136
+ 'getInitialState',
137
+ 'state',
138
+ 'getChildContext',
139
+ 'getDerivedStateFromProps',
140
+ 'componentWillMount',
141
+ 'UNSAFE_componentWillMount',
142
+ 'componentDidMount',
143
+ 'componentWillReceiveProps',
144
+ 'UNSAFE_componentWillReceiveProps',
145
+ 'shouldComponentUpdate',
146
+ 'componentWillUpdate',
147
+ 'UNSAFE_componentWillUpdate',
148
+ 'getSnapshotBeforeUpdate',
149
+ 'componentDidUpdate',
150
+ 'componentWillUnmount',
151
+ 'componentDidCatch',
152
+ ],
153
+ rendering: ['/^render.+$/', 'render'],
154
+ },
155
+ order: [
156
+ 'static-variables',
157
+ 'static-methods',
158
+ 'instance-variables',
159
+ 'lifecycle',
160
+ '/^on.+$/',
161
+ 'getters',
162
+ 'setters',
163
+ '/^(get|set)(?!(InitialState$|DefaultProps$|ChildContext$)).+$/',
164
+ 'instance-methods',
165
+ 'everything-else',
166
+ 'rendering',
167
+ ],
168
+ },
169
+ ],
170
+ 'react/sort-prop-types': error,
171
+ 'react/state-in-constructor': [error, 'never'],
172
+ 'react/static-property-placement': error,
173
+ 'react/style-prop-object': error,
174
+ 'react/void-dom-elements-no-children': error,
175
+ },
176
+ };
@@ -0,0 +1,132 @@
1
+ const { fixme, off, warn, error } = require('./_rule');
2
+ const { rules: baseRules } = require('./base');
3
+
4
+ const duplicateTSC = off; // = "off because tsc already checks that"
5
+
6
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
7
+ const ruleDisabled = {
8
+ camelcase: off,
9
+ 'constructor-super': off,
10
+ 'dot-notation': off,
11
+ 'getter-return': off,
12
+ 'import/default': duplicateTSC,
13
+ 'import/export': fixme(error), // https://github.com/benmosher/eslint-plugin-import/issues/1964
14
+ 'import/named': duplicateTSC,
15
+ 'import/namespace': duplicateTSC,
16
+ 'import/no-named-as-default-member': duplicateTSC,
17
+ 'import/no-unresolved': duplicateTSC,
18
+ 'no-array-constructor': off,
19
+ 'no-const-assign': off,
20
+ 'no-dupe-args': off,
21
+ 'no-dupe-class-members': off,
22
+ 'no-dupe-keys': off,
23
+ 'no-empty-function': off,
24
+ 'no-func-assign': off,
25
+ 'no-import-assign': off,
26
+ 'no-inner-declarations': fixme(error), // https://github.com/typescript-eslint/typescript-eslint/issues/239
27
+ 'no-new-symbol': off,
28
+ 'no-obj-calls': off,
29
+ 'no-redeclare': off,
30
+ 'no-setter-return': off,
31
+ 'no-shadow': off, // https://github.com/typescript-eslint/typescript-eslint/issues/2483
32
+ 'no-this-before-super': off,
33
+ 'no-undef': off,
34
+ 'no-unreachable': off,
35
+ 'no-unsafe-negation': off,
36
+ 'no-unused-vars': off,
37
+ 'no-use-before-define': off,
38
+ 'no-useless-constructor': off,
39
+ 'no-var': error,
40
+ 'prefer-const': error,
41
+ 'prefer-rest-params': error,
42
+ 'prefer-spread': error,
43
+ 'valid-typeof': off,
44
+ };
45
+
46
+ module.exports = {
47
+ extends: ['plugin:@typescript-eslint/recommended-requiring-type-checking'],
48
+ plugins: ['@typescript-eslint', 'import'],
49
+ rules: Object.assign(
50
+ {
51
+ '@typescript-eslint/adjacent-overload-signatures': error,
52
+ '@typescript-eslint/ban-ts-comment': [
53
+ warn,
54
+ {
55
+ minimumDescriptionLength: 3,
56
+ 'ts-check': false,
57
+ 'ts-expect-error': 'allow-with-description',
58
+ 'ts-ignore': 'allow-with-description',
59
+ 'ts-nocheck': true,
60
+ },
61
+ ],
62
+ '@typescript-eslint/ban-types': error,
63
+ '@typescript-eslint/consistent-type-assertions': [
64
+ error,
65
+ { assertionStyle: 'as', objectLiteralTypeAssertions: 'never' },
66
+ ],
67
+ '@typescript-eslint/dot-notation': baseRules['dot-notation'],
68
+ '@typescript-eslint/explicit-function-return-type': off,
69
+ '@typescript-eslint/explicit-module-boundary-types': off,
70
+ '@typescript-eslint/member-delimiter-style': error,
71
+ '@typescript-eslint/naming-convention': [
72
+ error,
73
+ {
74
+ format: ['PascalCase', 'camelCase'],
75
+ leadingUnderscore: 'allow',
76
+ selector: 'default',
77
+ trailingUnderscore: 'allow',
78
+ },
79
+ {
80
+ format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
81
+ leadingUnderscore: 'allow',
82
+ selector: 'variable',
83
+ trailingUnderscore: 'allow',
84
+ },
85
+ {
86
+ format: ['PascalCase', 'camelCase', 'UPPER_CASE'],
87
+ leadingUnderscore: 'allowSingleOrDouble',
88
+ selector: 'memberLike',
89
+ trailingUnderscore: 'allowDouble',
90
+ },
91
+ {
92
+ format: ['PascalCase'],
93
+ selector: 'typeLike',
94
+ },
95
+ ],
96
+ '@typescript-eslint/no-array-constructor': error,
97
+ '@typescript-eslint/no-base-to-string': error,
98
+ '@typescript-eslint/no-empty-function': baseRules['no-empty-function'],
99
+ '@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
100
+ '@typescript-eslint/no-explicit-any': off, // if any is explicit then it's wanted
101
+ '@typescript-eslint/no-implicit-any-catch': error,
102
+ '@typescript-eslint/no-inferrable-types': error,
103
+ '@typescript-eslint/no-misused-new': error,
104
+ '@typescript-eslint/no-namespace': off, // We don't agree with community, namespaces are great and not deprecated
105
+ '@typescript-eslint/no-non-null-assertion': error,
106
+ '@typescript-eslint/no-redeclare': fixme(error /* baseRules['no-redeclare'] */), // Error level so it is strongly discouraged
107
+ '@typescript-eslint/no-require-imports': error,
108
+ '@typescript-eslint/no-shadow': baseRules['no-shadow'], // Does not allow to declare type and const with same name
109
+ '@typescript-eslint/no-this-alias': error,
110
+ '@typescript-eslint/no-unnecessary-condition': error,
111
+ '@typescript-eslint/no-unsafe-argument': error,
112
+ '@typescript-eslint/no-unused-vars': baseRules['no-unused-vars'],
113
+ '@typescript-eslint/no-use-before-define': baseRules['no-use-before-define'],
114
+ '@typescript-eslint/no-useless-constructor': baseRules['no-useless-constructor'],
115
+ '@typescript-eslint/no-var-requires': error,
116
+ '@typescript-eslint/prefer-namespace-keyword': error,
117
+ '@typescript-eslint/prefer-reduce-type-parameter': error,
118
+ '@typescript-eslint/strict-boolean-expressions': [
119
+ error,
120
+ {
121
+ allowNullableObject: false,
122
+ allowNumber: false,
123
+ allowString: false,
124
+ },
125
+ ],
126
+ '@typescript-eslint/switch-exhaustiveness-check': error,
127
+ '@typescript-eslint/triple-slash-reference': error,
128
+ '@typescript-eslint/type-annotation-spacing': error,
129
+ },
130
+ ruleDisabled
131
+ ),
132
+ };
@@ -0,0 +1,58 @@
1
+ const { off, warn, error } = require('./_rule');
2
+
3
+ const unsafeRules = {
4
+ 'unicorn/consistent-destructuring': off,
5
+ 'unicorn/no-array-for-each': off, // This rule could change browser compatibility
6
+ 'unicorn/no-object-as-default-parameter': off,
7
+ 'unicorn/prefer-default-parameters': off,
8
+ 'unicorn/prevent-abbreviations': off, // This rule is so dangerous : it potentially break code while fixing in many cases !!
9
+ };
10
+
11
+ module.exports = {
12
+ extends: ['plugin:unicorn/recommended'],
13
+ plugins: ['unicorn'],
14
+ rules: Object.assign(
15
+ {
16
+ 'unicode-bom': [error, 'never'],
17
+ 'unicorn/better-regex': error,
18
+ 'unicorn/catch-error-name': [error, { name: error }],
19
+ 'unicorn/custom-error-definition': error,
20
+ 'unicorn/error-message': error,
21
+ 'unicorn/explicit-length-check': [error, { 'non-zero': 'greater-than' }],
22
+ 'unicorn/filename-case': off,
23
+ 'unicorn/import-index': off, // Not playing well with ES Module
24
+ 'unicorn/new-for-builtins': off, // error, @see https://github.com/sindresorhus/eslint-plugin-unicorn/issues/122
25
+ 'unicorn/no-abusive-eslint-disable': error,
26
+ 'unicorn/no-array-instanceof': error,
27
+ 'unicorn/no-console-spaces': off,
28
+ 'unicorn/no-fn-reference-in-iterator': off, // error ?
29
+ 'unicorn/no-for-loop': error,
30
+ 'unicorn/no-hex-escape': error,
31
+ 'unicorn/no-new-buffer': error,
32
+ 'unicorn/no-null': off, // https://github.com/sindresorhus/eslint-plugin-unicorn/issues/612
33
+ 'unicorn/no-process-exit': off,
34
+ 'unicorn/no-unreadable-array-destructuring': off,
35
+ 'unicorn/no-unsafe-regex': error,
36
+ 'unicorn/no-unused-properties': warn,
37
+ 'unicorn/no-useless-undefined': off,
38
+ 'unicorn/no-zero-fractions': error,
39
+ 'unicorn/number-literal-case': error,
40
+ 'unicorn/prefer-add-event-listener': off,
41
+ 'unicorn/prefer-event-key': error,
42
+ 'unicorn/prefer-exponentiation-operator': error,
43
+ 'unicorn/prefer-flat-map': error,
44
+ 'unicorn/prefer-includes': error,
45
+ 'unicorn/prefer-node-append': error,
46
+ 'unicorn/prefer-node-remove': error,
47
+ 'unicorn/prefer-number-properties': error,
48
+ 'unicorn/prefer-query-selector': error,
49
+ 'unicorn/prefer-set-has': off,
50
+ 'unicorn/prefer-spread': off,
51
+ 'unicorn/prefer-starts-ends-with': error,
52
+ 'unicorn/prefer-text-content': error,
53
+ 'unicorn/prefer-type-error': error,
54
+ 'unicorn/throw-new-error': error,
55
+ },
56
+ unsafeRules
57
+ ),
58
+ };
package/ts.js ADDED
@@ -0,0 +1,17 @@
1
+ // http://eslint.org/docs/user-guide/configuring
2
+ module.exports = {
3
+ extends: [
4
+ require.resolve('./rules/base'),
5
+ require.resolve('./rules/jsdoc'),
6
+ require.resolve('./rules/import'),
7
+ require.resolve('./rules/unicorn'),
8
+ 'plugin:import/typescript',
9
+ require.resolve('./rules/typescript'),
10
+ 'prettier',
11
+ require.resolve('./rules/prettier'),
12
+ ],
13
+ parser: '@typescript-eslint/parser',
14
+ parserOptions: {
15
+ sourceType: 'module',
16
+ },
17
+ };