@azat-io/eslint-config 2.0.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.
@@ -0,0 +1,189 @@
1
+ import { parser } from "typescript-eslint";
2
+ import vuePlugin from "eslint-plugin-vue";
3
+ import vueParser from "vue-eslint-parser";
4
+ let vue = (config) => {
5
+ if (!config.vue) {
6
+ return {};
7
+ }
8
+ let files = ["**/*.vue"];
9
+ let additionalParserOptions = {};
10
+ if (config.typescript) {
11
+ additionalParserOptions = {
12
+ ...additionalParserOptions,
13
+ parser,
14
+ projectService: true,
15
+ tsconfigRootDir: process.cwd()
16
+ };
17
+ }
18
+ return {
19
+ files,
20
+ languageOptions: {
21
+ parser: vueParser,
22
+ parserOptions: {
23
+ ecmaVersion: "latest",
24
+ extraFileExtensions: [".vue"],
25
+ sourceType: "module",
26
+ ...additionalParserOptions
27
+ }
28
+ },
29
+ plugins: {
30
+ vue: vuePlugin
31
+ },
32
+ rules: {
33
+ "vue/attribute-hyphenation": ["error", "always"],
34
+ "vue/block-order": [
35
+ "error",
36
+ {
37
+ order: ["script", "template", "style"]
38
+ }
39
+ ],
40
+ "vue/comment-directive": "error",
41
+ "vue/component-api-style": "error",
42
+ "vue/component-definition-name-casing": ["error", "kebab-case"],
43
+ "vue/component-name-in-template-casing": ["error", "kebab-case"],
44
+ "vue/component-options-name-casing": ["error", "kebab-case"],
45
+ "vue/custom-event-name-casing": ["error", "kebab-case"],
46
+ "vue/define-emits-declaration": "error",
47
+ "vue/define-props-declaration": "error",
48
+ "vue/enforce-style-attribute": [
49
+ "error",
50
+ {
51
+ allow: ["scoped", "plain"]
52
+ }
53
+ ],
54
+ "vue/html-button-has-type": "error",
55
+ "vue/html-end-tags": "error",
56
+ "vue/html-self-closing": "error",
57
+ "vue/jsx-uses-vars": "error",
58
+ "vue/no-async-in-computed-properties": "error",
59
+ "vue/no-child-content": "error",
60
+ "vue/no-computed-properties-in-data": "error",
61
+ "vue/no-deprecated-data-object-declaration": "error",
62
+ "vue/no-deprecated-delete-set": "error",
63
+ "vue/no-deprecated-destroyed-lifecycle": "error",
64
+ "vue/no-deprecated-dollar-listeners-api": "error",
65
+ "vue/no-deprecated-dollar-scopedslots-api": "error",
66
+ "vue/no-deprecated-events-api": "error",
67
+ "vue/no-deprecated-filter": "error",
68
+ "vue/no-deprecated-functional-template": "error",
69
+ "vue/no-deprecated-html-element-is": "error",
70
+ "vue/no-deprecated-inline-template": "error",
71
+ "vue/no-deprecated-model-definition": "error",
72
+ "vue/no-deprecated-props-default-this": "error",
73
+ "vue/no-deprecated-router-link-tag-prop": "error",
74
+ "vue/no-deprecated-scope-attribute": "error",
75
+ "vue/no-deprecated-slot-attribute": "error",
76
+ "vue/no-deprecated-slot-scope-attribute": "error",
77
+ "vue/no-deprecated-v-bind-sync": "error",
78
+ "vue/no-deprecated-v-is": "error",
79
+ "vue/no-deprecated-v-on-native-modifier": "error",
80
+ "vue/no-deprecated-v-on-number-modifiers": "error",
81
+ "vue/no-deprecated-vue-config-keycodes": "error",
82
+ "vue/no-dupe-keys": "error",
83
+ "vue/no-dupe-v-else-if": "error",
84
+ "vue/no-duplicate-attr-inheritance": "error",
85
+ "vue/no-duplicate-attributes": "error",
86
+ "vue/no-empty-component-block": "error",
87
+ "vue/no-export-in-script-setup": "error",
88
+ "vue/no-expose-after-await": "error",
89
+ "vue/no-lifecycle-after-await": "error",
90
+ "vue/no-lone-template": "error",
91
+ "vue/no-multiple-objects-in-class": "error",
92
+ "vue/no-multiple-slot-args": "error",
93
+ "vue/no-mutating-props": "error",
94
+ "vue/no-parsing-error": "error",
95
+ "vue/no-potential-component-option-typo": "error",
96
+ "vue/no-ref-as-operand": "error",
97
+ "vue/no-ref-object-reactivity-loss": "error",
98
+ "vue/no-required-prop-with-default": "error",
99
+ "vue/no-reserved-component-names": "error",
100
+ "vue/no-reserved-keys": "error",
101
+ "vue/no-reserved-props": "error",
102
+ "vue/no-setup-props-reactivity-loss": "error",
103
+ "vue/no-shared-component-data": "error",
104
+ "vue/no-side-effects-in-computed-properties": "error",
105
+ "vue/no-template-key": "error",
106
+ "vue/no-template-shadow": "error",
107
+ "vue/no-template-target-blank": "error",
108
+ "vue/no-textarea-mustache": "error",
109
+ "vue/no-this-in-before-route-enter": "error",
110
+ "vue/no-undef-components": "error",
111
+ "vue/no-undef-properties": "error",
112
+ "vue/no-unused-components": "error",
113
+ "vue/no-unused-emit-declarations": "error",
114
+ "vue/no-unused-vars": "error",
115
+ "vue/no-use-computed-property-like-method": "error",
116
+ "vue/no-use-v-else-with-v-for": "error",
117
+ "vue/no-use-v-if-with-v-for": "error",
118
+ "vue/no-useless-mustaches": "error",
119
+ "vue/no-useless-template-attributes": "error",
120
+ "vue/no-useless-v-bind": "error",
121
+ "vue/no-v-for-template-key-on-child": "error",
122
+ "vue/no-v-html": "error",
123
+ "vue/no-v-text-v-html-on-component": "error",
124
+ "vue/no-watch-after-await": "error",
125
+ "vue/prefer-define-options": "error",
126
+ "vue/prefer-import-from-vue": "error",
127
+ "vue/prefer-separate-static-class": "error",
128
+ "vue/prefer-true-attribute-shorthand": "error",
129
+ "vue/prop-name-casing": ["error", "camelCase"],
130
+ "vue/require-component-is": "error",
131
+ "vue/require-default-prop": "error",
132
+ "vue/require-emit-validator": "error",
133
+ "vue/require-explicit-emits": "error",
134
+ "vue/require-explicit-slots": "error",
135
+ "vue/require-macro-variable-name": [
136
+ "error",
137
+ {
138
+ defineEmits: "emit",
139
+ defineProps: "props",
140
+ defineSlots: "slots",
141
+ useAttrs: "attrs",
142
+ useSlots: "slots"
143
+ }
144
+ ],
145
+ "vue/require-name-property": "error",
146
+ "vue/require-prop-type-constructor": "error",
147
+ "vue/require-render-return": "error",
148
+ "vue/require-slots-as-functions": "error",
149
+ "vue/require-toggle-inside-transition": "error",
150
+ "vue/require-typed-ref": "error",
151
+ "vue/require-v-for-key": "error",
152
+ "vue/require-valid-default-prop": "error",
153
+ "vue/return-in-computed-property": "error",
154
+ "vue/return-in-emits-validator": "error",
155
+ "vue/this-in-template": "error",
156
+ "vue/use-v-on-exact": "error",
157
+ "vue/v-bind-style": "error",
158
+ "vue/v-on-event-hyphenation": "error",
159
+ "vue/v-on-style": "error",
160
+ "vue/v-slot-style": "error",
161
+ "vue/valid-attribute-name": "error",
162
+ "vue/valid-define-emits": "error",
163
+ "vue/valid-define-options": "error",
164
+ "vue/valid-define-props": "error",
165
+ "vue/valid-next-tick": "error",
166
+ "vue/valid-template-root": "error",
167
+ "vue/valid-v-bind": "error",
168
+ "vue/valid-v-cloak": "error",
169
+ "vue/valid-v-else": "error",
170
+ "vue/valid-v-else-if": "error",
171
+ "vue/valid-v-for": "error",
172
+ "vue/valid-v-html": "error",
173
+ "vue/valid-v-if": "error",
174
+ "vue/valid-v-is": "error",
175
+ "vue/valid-v-memo": "error",
176
+ "vue/valid-v-model": "error",
177
+ "vue/valid-v-on": "error",
178
+ "vue/valid-v-once": "error",
179
+ "vue/valid-v-pre": "error",
180
+ "vue/valid-v-show": "error",
181
+ "vue/valid-v-slot": "error",
182
+ "vue/valid-v-text": "error"
183
+ },
184
+ processor: vuePlugin.processors[".vue"]
185
+ };
186
+ };
187
+ export {
188
+ vue
189
+ };
package/license.md ADDED
@@ -0,0 +1,20 @@
1
+ # The MIT License (MIT)
2
+
3
+ Copyright 2023 Azat S. <to@azat.io>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@azat-io/eslint-config",
3
+ "version": "2.0.0",
4
+ "description": "ESLint shareable config",
5
+ "keywords": [
6
+ "eslint",
7
+ "eslint-config",
8
+ "config",
9
+ "code-styles",
10
+ "linter",
11
+ "javascript",
12
+ "typescript"
13
+ ],
14
+ "repository": "azat-io/eslint-config",
15
+ "license": "MIT",
16
+ "author": "Azat S. <to@azat.io>",
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.mjs",
22
+ "require": "./dist/index.cjs"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "files": [
27
+ "./dist"
28
+ ],
29
+ "dependencies": {
30
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
31
+ "@vitest/eslint-plugin": "^1.1.10",
32
+ "astro-eslint-parser": "^1.1.0",
33
+ "eslint-import-resolver-typescript": "^3.6.3",
34
+ "eslint-plugin-astro": "^1.3.1",
35
+ "eslint-plugin-import-x": "^4.4.2",
36
+ "eslint-plugin-jsdoc": "^50.5.0",
37
+ "eslint-plugin-jsx-a11y": "^6.10.2",
38
+ "eslint-plugin-n": "^17.13.2",
39
+ "eslint-plugin-package-json": "^0.15.6",
40
+ "eslint-plugin-perfectionist": "^3.9.1",
41
+ "eslint-plugin-prefer-arrow": "^1.2.3",
42
+ "eslint-plugin-prefer-let": "^4.0.0",
43
+ "eslint-plugin-promise": "^7.1.0",
44
+ "eslint-plugin-qwik": "^1.10.0",
45
+ "eslint-plugin-react": "^7.37.2",
46
+ "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
47
+ "eslint-plugin-react-hooks": "^5.0.0",
48
+ "eslint-plugin-react-perf": "^3.3.3",
49
+ "eslint-plugin-regexp": "^2.7.0",
50
+ "eslint-plugin-sonarjs": "^2.0.4",
51
+ "eslint-plugin-svelte": "^2.46.0",
52
+ "eslint-plugin-unicorn": "^56.0.0",
53
+ "eslint-plugin-vue": "^9.31.0",
54
+ "globals": "^15.12.0",
55
+ "jsonc-eslint-parser": "^2.4.0",
56
+ "svelte-eslint-parser": "^0.43.0",
57
+ "typescript-eslint": "^8.14.0",
58
+ "vue-eslint-parser": "^9.4.3"
59
+ },
60
+ "peerDependencies": {
61
+ "eslint": ">=9.14.0"
62
+ },
63
+ "publishConfig": {
64
+ "access": "public"
65
+ }
66
+ }
package/readme.md ADDED
@@ -0,0 +1,151 @@
1
+ # ESLint Config
2
+
3
+ <img
4
+ src="https://raw.githubusercontent.com/azat-io/eslint-config/main/assets/logo.png"
5
+ alt="ESLint Config Logo"
6
+ align="right"
7
+ height="160"
8
+ width="160"
9
+ />
10
+
11
+ [![Version](https://img.shields.io/npm/v/@azat-io/eslint-config.svg?color=4a32c3&labelColor=26272b)](https://npmjs.com/package/@azat-io/eslint-configt)
12
+ [![GitHub License](https://img.shields.io/badge/license-MIT-232428.svg?color=4a32c3&labelColor=26272b)](https://github.com/azat-io/eslint-config/blob/main/license.md)
13
+
14
+ A comprehensive and flexible ESLint configuration that supports a wide range of frameworks and environments. Easily integrate clean, consistent code standards across projects by enabling settings for specific tools and libraries.
15
+
16
+ This config covers multiple setups in a single, straightforward import, helping maintain consistency across different project types and frameworks.
17
+
18
+ ## Usage
19
+
20
+ 1. Install package:
21
+
22
+ ```sh
23
+ pnpm add --save-dev eslint @azat-io/eslint-config
24
+ ```
25
+
26
+ 2. Create ESLint configuration file `eslint.config.js`:
27
+
28
+ ```js
29
+ import eslintConfig from '@azat-io/eslint-config'
30
+
31
+ export default eslintConfig({
32
+ perfectionist: true,
33
+ typescript: true,
34
+ react: true,
35
+ node: true,
36
+ })
37
+ ```
38
+
39
+ 3. Add script for `package.json`:
40
+
41
+ ```json
42
+ {
43
+ "scripts": {
44
+ "test:js": "eslint \"**/*.{js,ts,jsx,tsx,json}\""
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Configuration
50
+
51
+ To configure the ESLint rules based on your project’s needs, import the config and pass an object with options for each framework or tool. By default, all options are disabled, so you can enable only what's relevant to your project.
52
+
53
+ ```js
54
+ import eslintConfig from '@azat-io/eslint-config'
55
+
56
+ export default eslintConfig({
57
+ perfectionist: true,
58
+ typescript: true,
59
+ svelte: true,
60
+ vitest: true,
61
+ astro: true,
62
+ react: true,
63
+ qwik: true,
64
+ node: true,
65
+ vue: true,
66
+ })
67
+ ```
68
+
69
+ ### perfectionist
70
+
71
+ Enables rules for sorting and organizing code structures for better readability and consistency.
72
+
73
+ ### typescript
74
+
75
+ Adds TypeScript-specific linting rules to ensure type safety and maintain TypeScript best practices.
76
+
77
+ ### svelte
78
+
79
+ Enables support for Svelte, including linting rules for Svelte components and files.
80
+
81
+ ### vitest
82
+
83
+ Adds support for Vitest, adjusting linting for testing files and practices within Vitest projects.
84
+
85
+ ### astro
86
+
87
+ Configures ESLint for Astro projects, with adjustments for Astro’s file structure and conventions.
88
+
89
+ ### react
90
+
91
+ Includes React-specific linting rules for JSX syntax, React hooks, and best practices within React environments.
92
+
93
+ ### qwik
94
+
95
+ Adds support for Qwik, adjusting linting for Qwik-specific syntax and conventions.
96
+
97
+ ### node
98
+
99
+ Adjusts linting for Node.js environments, addressing Node-specific globals, imports, and common practices.
100
+
101
+ ### vue
102
+
103
+ Adds Vue-specific linting rules, supporting Vue's syntax and best practices for Vue components.
104
+
105
+ ### extends
106
+
107
+ You can add your own configs. Example:
108
+
109
+ ```js
110
+ import eslintConfig from '@azat-io/eslint-config'
111
+
112
+ export default eslintConfig({
113
+ extends: [
114
+ {
115
+ 'no-undef': 'off',
116
+ },
117
+ ],
118
+ })
119
+ ```
120
+
121
+ ## Plugins
122
+
123
+ This config uses the following plugins:
124
+
125
+ - [@eslint/js](https://github.com/eslint/eslint)
126
+ - [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest)
127
+ - [eslint-plugin-astro](https://github.com/ota-meshi/eslint-plugin-astro)
128
+ - [eslint-plugin-import-x](https://github.com/un-ts/eslint-plugin-import-x)
129
+ - [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc)
130
+ - [eslint-plugin-jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y)
131
+ - [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
132
+ - [eslint-plugin-package-json](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json)
133
+ - [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist)
134
+ - [eslint-plugin-prefer-arrow](https://github.com/TristonJ/eslint-plugin-prefer-arrow)
135
+ - [eslint-plugin-prefer-let](https://github.com/thefrontside/javascript/tree/v3/packages/eslint-plugin-prefer-let)
136
+ - [eslint-plugin-promise](https://github.com/eslint-community/eslint-plugin-promise)
137
+ - [eslint-plugin-qwik](https://github.com/QwikDev/qwik/tree/main/packages/eslint-plugin-qwik)
138
+ - [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react)
139
+ - [eslint-plugin-react-compiler](https://github.com/facebook/react/tree/main/compiler/packages/eslint-plugin-react-compiler)
140
+ - [eslint-plugin-react-hooks](https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks)
141
+ - [eslint-plugin-react-perf](https://github.com/cvazac/eslint-plugin-react-perf)
142
+ - [eslint-plugin-regexp](https://github.com/ota-meshi/eslint-plugin-regexp)
143
+ - [eslint-plugin-sonarjs](https://github.com/SonarSource/SonarJS/tree/master/packages/jsts/src/rules)
144
+ - [eslint-plugin-svelte](https://github.com/sveltejs/eslint-plugin-svelte)
145
+ - [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn)
146
+ - [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue)
147
+ - [typescript-eslint](https://github.com/typescript-eslint/typescript-eslint)
148
+
149
+ ## License
150
+
151
+ MIT &copy; [Azat S.](https://azat.io)