@ivanmaxlogiudice/eslint-config 0.1.10 → 1.0.0-beta.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.
@@ -0,0 +1,155 @@
1
+ import tsParser from '@typescript-eslint/parser'
2
+ import tsPlugin from '@typescript-eslint/eslint-plugin'
3
+ import { GLOB_TS, GLOB_TSX } from './shared.js'
4
+
5
+ export { tsParser, tsPlugin }
6
+
7
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
8
+ export const typescript = [
9
+ {
10
+ files: [GLOB_TS, GLOB_TSX],
11
+ languageOptions: {
12
+ parser: tsParser,
13
+ parserOptions: {
14
+ sourceType: 'module',
15
+ },
16
+ },
17
+ plugins: {
18
+ '@typescript-eslint': tsPlugin,
19
+ },
20
+ rules: {
21
+ ...tsPlugin.configs['eslint-recommended'].overrides[0].rules,
22
+ ...tsPlugin.configs['recommended'].rules,
23
+
24
+ '@typescript-eslint/ban-ts-comment': ['error', {
25
+ 'ts-ignore': 'allow-with-description',
26
+ }],
27
+ '@typescript-eslint/consistent-type-imports': ['error', {
28
+ disallowTypeAnnotations: false,
29
+ fixStyle: 'inline-type-imports',
30
+ }],
31
+ '@typescript-eslint/prefer-as-const': 'warn',
32
+ '@typescript-eslint/member-delimiter-style': ['error', {
33
+ multiline: { delimiter: 'none' },
34
+ }],
35
+ '@typescript-eslint/type-annotation-spacing': 'error',
36
+ '@typescript-eslint/no-require-imports': 'error',
37
+ '@typescript-eslint/no-redeclare': 'error',
38
+ '@typescript-eslint/no-dupe-class-members': 'error',
39
+
40
+ // Override JS
41
+ 'indent': 'off',
42
+ '@typescript-eslint/indent': ['error', 4, {
43
+ SwitchCase: 1,
44
+ outerIIFEBody: 1,
45
+ VariableDeclarator: 1,
46
+ }],
47
+
48
+ 'no-invalid-this': 'off',
49
+ '@typescript-eslint/no-invalid-this': 'error',
50
+
51
+ 'no-use-before-define': 'off',
52
+ '@typescript-eslint/no-use-before-define': ['error', {
53
+ classes: false,
54
+ functions: false,
55
+ variables: true,
56
+ }],
57
+
58
+ 'brace-style': 'off',
59
+ '@typescript-eslint/brace-style': ['error', 'stroustrup', {
60
+ allowSingleLine: true,
61
+ }],
62
+
63
+ 'comma-dangle': 'off',
64
+ '@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
65
+
66
+ 'object-curly-spacing': 'off',
67
+ '@typescript-eslint/object-curly-spacing': ['error', 'always'],
68
+
69
+ 'semi': 'off',
70
+ '@typescript-eslint/semi': ['error', 'never'],
71
+
72
+ 'quotes': 'off',
73
+ '@typescript-eslint/quotes': ['error', 'single', {
74
+ avoidEscape: true,
75
+ }],
76
+
77
+ 'space-before-blocks': 'off',
78
+ '@typescript-eslint/space-before-blocks': ['error', 'always'],
79
+
80
+ 'space-before-function-paren': 'off',
81
+ '@typescript-eslint/space-before-function-paren': ['error', {
82
+ anonymous: 'always',
83
+ asyncArrow: 'always',
84
+ named: 'never',
85
+ }],
86
+
87
+ 'space-infix-ops': 'off',
88
+ '@typescript-eslint/space-infix-ops': 'error',
89
+
90
+ 'keyword-spacing': 'off',
91
+ '@typescript-eslint/keyword-spacing': ['error', {
92
+ before: true,
93
+ after: true,
94
+ }],
95
+
96
+ 'comma-spacing': 'off',
97
+ '@typescript-eslint/comma-spacing': ['error', {
98
+ before: false,
99
+ after: true,
100
+ }],
101
+
102
+ 'no-extra-parens': 'off',
103
+ '@typescript-eslint/no-extra-parens': ['error', 'functions'],
104
+
105
+ 'no-loss-of-precision': 'off',
106
+ '@typescript-eslint/no-loss-of-precision': 'error',
107
+
108
+ 'lines-between-class-members': 'off',
109
+ '@typescript-eslint/lines-between-class-members': ['error', 'always', {
110
+ exceptAfterSingleLine: true,
111
+ }],
112
+
113
+ // antfu
114
+ 'antfu/generic-spacing': 'error',
115
+ 'antfu/no-cjs-exports': 'error',
116
+ 'antfu/no-ts-export-equal': 'error',
117
+
118
+ // off
119
+ 'import/named': 'off',
120
+
121
+ '@typescript-eslint/no-unused-vars': 'off', // handled by unused-imports/no-unused-imports
122
+ '@typescript-eslint/ban-types': 'off',
123
+ '@typescript-eslint/no-explicit-any': 'off',
124
+ '@typescript-eslint/no-non-null-assertion': 'off',
125
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
126
+ '@typescript-eslint/consistent-indexed-object-style': 'off',
127
+ '@typescript-eslint/naming-convention': 'off',
128
+ '@typescript-eslint/explicit-function-return-type': 'off',
129
+ '@typescript-eslint/explicit-member-accessibility': 'off',
130
+ '@typescript-eslint/no-parameter-properties': 'off',
131
+ '@typescript-eslint/ban-ts-ignore': 'off',
132
+ '@typescript-eslint/no-empty-function': 'off',
133
+ '@typescript-eslint/triple-slash-reference': 'off',
134
+ },
135
+ },
136
+ {
137
+ files: ['**/*.d.ts'],
138
+ rules: {
139
+ 'import/no-duplicates': 'off',
140
+ },
141
+ },
142
+ {
143
+ files: ['**/*.{test,spec}.ts?(x)'],
144
+ rules: {
145
+ 'no-unused-expressions': 'off',
146
+ },
147
+ },
148
+ {
149
+ files: ['**/*.js', '**/*.cjs'],
150
+ rules: {
151
+ '@typescript-eslint/no-var-requires': 'off',
152
+ '@typescript-eslint/no-require-imports': 'off',
153
+ },
154
+ },
155
+ ]
package/src/vue.js ADDED
@@ -0,0 +1,197 @@
1
+ import { getPackageInfoSync } from 'local-pkg'
2
+ import vueParser from 'vue-eslint-parser'
3
+ import vuePlugin from 'eslint-plugin-vue'
4
+ import tsPlugin from '@typescript-eslint/eslint-plugin'
5
+
6
+ import { typescript } from './typescript.js'
7
+ import { GLOB_VUE } from './shared.js'
8
+
9
+ export { vueParser, vuePlugin }
10
+
11
+ export function getVueVersion() {
12
+ const pkg = getPackageInfoSync('vue', { paths: [process.cwd()] })
13
+
14
+ if (pkg && typeof pkg.version === 'string' && !Number.isNaN(+pkg.version[0]))
15
+ return +pkg.version[0]
16
+
17
+ return 3
18
+ }
19
+ const isVue3 = getVueVersion() === 3
20
+
21
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
22
+ export const reactivityTransform = [
23
+ {
24
+ languageOptions: {
25
+ globals: {
26
+ $: 'readonly',
27
+ $$: 'readonly',
28
+ $ref: 'readonly',
29
+ $computed: 'readonly',
30
+ $shallowRef: 'readonly',
31
+ $toRef: 'readonly',
32
+ $customRef: 'readonly',
33
+ },
34
+ },
35
+ plugins: {
36
+ vue: vuePlugin,
37
+ },
38
+ rules: {
39
+ 'vue/no-setup-props-destructure': 'off',
40
+ },
41
+ },
42
+ ]
43
+
44
+ /** @type {import('eslint-define-config').Rules} */
45
+ const vueCustomRules = {
46
+ 'vue/max-attributes-per-line': 'off',
47
+ 'vue/no-v-html': 'off',
48
+ 'vue/multi-word-component-names': 'off',
49
+ // 'vue/require-prop-types': 'off',
50
+ // 'vue/require-default-prop': 'off',
51
+ // 'vue/no-dupe-keys': 'off',
52
+
53
+ 'vue/array-bracket-newline': ['error', {
54
+ minItems: 3,
55
+ multiline: true,
56
+ }],
57
+ 'vue/array-bracket-spacing': ['error', 'never'],
58
+ 'vue/arrow-spacing': ['error', {
59
+ after: true,
60
+ before: true,
61
+ }],
62
+ 'vue/block-spacing': ['error', 'always'],
63
+ 'vue/block-tag-newline': ['error', {
64
+ multiline: 'always',
65
+ singleline: 'always',
66
+ }],
67
+ 'vue/brace-style': ['error', 'stroustrup', {
68
+ allowSingleLine: true,
69
+ }],
70
+ 'vue/comma-dangle': ['error', 'always-multiline'],
71
+ 'vue/comma-spacing': ['error', {
72
+ after: true,
73
+ before: false,
74
+ }],
75
+ 'vue/comma-style': ['error', 'last'],
76
+ 'vue/component-name-in-template-casing': ['error', 'PascalCase'],
77
+ 'vue/component-options-name-casing': ['error', 'PascalCase'],
78
+ 'vue/component-tags-order': ['error', {
79
+ order: ['template', 'script', 'style'],
80
+ }],
81
+ 'vue/custom-event-name-casing': ['error', 'camelCase'],
82
+ 'vue/define-macros-order': ['error', {
83
+ order: ['defineOptions', 'defineProps', 'defineEmits', 'defineSlots'],
84
+ }],
85
+ 'vue/dot-location': ['error', 'property'],
86
+ 'vue/dot-notation': ['error', {
87
+ allowKeywords: true,
88
+ }],
89
+ 'vue/eqeqeq': ['error', 'smart'],
90
+ 'vue/html-comment-content-spacing': ['error', 'always', {
91
+ exceptions: ['-'],
92
+ }],
93
+ 'vue/html-indent': ['error', 4],
94
+ // 'vue/html-self-closing': ['error', {
95
+ // html: {
96
+ // component: 'always',
97
+ // normal: 'always',
98
+ // void: 'always',
99
+ // },
100
+ // math: 'always',
101
+ // svg: 'always',
102
+ // }],
103
+ 'vue/key-spacing': ['error', {
104
+ afterColon: true,
105
+ beforeColon: false,
106
+ }],
107
+ 'vue/keyword-spacing': ['error', {
108
+ after: true,
109
+ before: true,
110
+ }],
111
+ 'vue/no-constant-condition': 'warn',
112
+ 'vue/no-empty-pattern': 'error',
113
+ 'vue/no-extra-parens': ['error', 'functions'],
114
+ 'vue/no-irregular-whitespace': 'error',
115
+ 'vue/no-loss-of-precision': 'error',
116
+ 'vue/no-restricted-syntax': ['error', 'DebuggerStatement', 'LabeledStatement', 'WithStatement'],
117
+ 'vue/no-restricted-v-bind': ['error', '/^v-/'],
118
+ 'vue/no-sparse-arrays': 'error',
119
+ 'vue/no-unused-refs': 'error',
120
+ 'vue/no-useless-v-bind': 'error',
121
+ 'vue/object-curly-newline': ['error', {
122
+ consistent: true,
123
+ multiline: true,
124
+ }],
125
+ 'vue/object-curly-spacing': ['error', 'always'],
126
+ 'vue/object-property-newline': ['error', {
127
+ allowMultiplePropertiesPerLine: true,
128
+ }],
129
+ 'vue/object-shorthand': ['error', 'always', {
130
+ avoidQuotes: true,
131
+ ignoreConstructors: false,
132
+ }],
133
+ 'vue/operator-linebreak': ['error', 'before'],
134
+ 'vue/padding-line-between-blocks': ['error', 'always'],
135
+ 'vue/prefer-separate-static-class': 'error',
136
+ 'vue/prefer-template': 'error',
137
+ 'vue/quote-props': ['error', 'consistent-as-needed'],
138
+ 'vue/space-in-parens': ['error', 'never'],
139
+ 'vue/space-infix-ops': 'error',
140
+ 'vue/space-unary-ops': ['error', {
141
+ nonwords: false,
142
+ words: true,
143
+ }],
144
+ 'vue/template-curly-spacing': 'error',
145
+ }
146
+
147
+ /** @type {import('eslint-define-config').Rules} */
148
+ const vue3Rules = {
149
+ ...vuePlugin.configs['base'].rules,
150
+ ...vuePlugin.configs['vue3-essential'].rules,
151
+ ...vuePlugin.configs['vue3-strongly-recommended'].rules,
152
+ ...vuePlugin.configs['vue3-recommended'].rules,
153
+ }
154
+
155
+ /** @type {import('eslint-define-config').Rules} */
156
+ const vue2Rules = {
157
+ ...vuePlugin.configs['base'].rules,
158
+ ...vuePlugin.configs['essential'].rules,
159
+ ...vuePlugin.configs['strongly-recommended'].rules,
160
+ ...vuePlugin.configs['recommended'].rules,
161
+ }
162
+
163
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
164
+ export const vue = [
165
+ {
166
+ files: [GLOB_VUE],
167
+ plugins: {
168
+ 'vue': vuePlugin,
169
+ '@typescript-eslint': tsPlugin,
170
+ },
171
+ languageOptions: {
172
+ parser: vueParser,
173
+ parserOptions: {
174
+ parser: '@typescript-eslint/parser',
175
+ sourceType: 'module',
176
+ extraFileExtensions: ['.vue'],
177
+ ecmaFeatures: {
178
+ jsx: true,
179
+ },
180
+ },
181
+ },
182
+ processor: vuePlugin.processors['.vue'],
183
+ rules: {
184
+ ...typescript[0].rules,
185
+ },
186
+ },
187
+ {
188
+ plugins: {
189
+ vue: vuePlugin,
190
+ },
191
+ rules: {
192
+ ...(isVue3 ? vue3Rules : vue2Rules),
193
+ ...vueCustomRules,
194
+ },
195
+ },
196
+ ...reactivityTransform,
197
+ ]
package/src/yml.js ADDED
@@ -0,0 +1,26 @@
1
+ import ymlPlugin, { configs } from 'eslint-plugin-yml'
2
+ import ymlParser from 'yaml-eslint-parser'
3
+ import { GLOB_YAML } from './shared.js'
4
+
5
+ /** @type {import('eslint-define-config').FlatESLintConfigItem[]} */
6
+ export const yml = [
7
+ {
8
+ files: [GLOB_YAML],
9
+ plugins: {
10
+ yml: ymlPlugin,
11
+ },
12
+ languageOptions: {
13
+ parser: ymlParser,
14
+ },
15
+ rules: {
16
+ ...configs.standard.rules,
17
+
18
+ 'yml/no-empty-document': 'off',
19
+ 'yml/no-empty-mapping-value': 'off',
20
+ 'yml/quotes': ['error', {
21
+ avoidEscape: false,
22
+ prefer: 'single',
23
+ }],
24
+ },
25
+ },
26
+ ]