@baicie/eslint-config 0.0.3

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/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # @baicie/eslint-config
2
+
3
+ Unified ESLint configuration package for the Baicie project ecosystem.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add -D @baicie/eslint-config
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Base Configuration
14
+
15
+ For general TypeScript projects:
16
+
17
+ ```js
18
+ // eslint.config.js
19
+ import config from '@baicie/eslint-config';
20
+
21
+ export default config;
22
+ ```
23
+
24
+ ### React Configuration
25
+
26
+ For React projects:
27
+
28
+ ```js
29
+ // eslint.config.js
30
+ import config from '@baicie/eslint-config/react';
31
+
32
+ export default config;
33
+ ```
34
+
35
+ ### Node.js Configuration
36
+
37
+ For backend Node.js projects:
38
+
39
+ ```js
40
+ // eslint.config.js
41
+ import config from '@baicie/eslint-config/node';
42
+
43
+ export default config;
44
+ ```
45
+
46
+ ### Strict Configuration
47
+
48
+ For projects requiring stricter code quality:
49
+
50
+ ```js
51
+ // eslint.config.js
52
+ import config from '@baicie/eslint-config/strict';
53
+
54
+ export default config;
55
+ ```
56
+
57
+ ### NestJS Configuration
58
+
59
+ For NestJS backend projects:
60
+
61
+ ```js
62
+ // eslint.config.js
63
+ import config from '@baicie/eslint-config/nestjs';
64
+
65
+ export default config;
66
+ ```
67
+
68
+ **Features**:
69
+ - Enforces NestJS naming conventions (Controller, Service, Module, etc.)
70
+ - Supports decorators and dependency injection patterns
71
+ - DTO and entity naming conventions
72
+
73
+ ### Vue.js Configuration
74
+
75
+ For Vue.js frontend projects (Vue 2 / Vue 3):
76
+
77
+ ```js
78
+ // eslint.config.js
79
+ import config from '@baicie/eslint-config/vue';
80
+
81
+ export default config;
82
+ ```
83
+
84
+ **Features**:
85
+ - Vue 3 Composition API support
86
+ - Vue Single File Component rules
87
+ - TypeScript support in Vue files
88
+ - Enforces `<script setup>` syntax
89
+
90
+ ## Configuration Options
91
+
92
+ ### TypeScript
93
+
94
+ The base configuration includes TypeScript support via `typescript-eslint`.
95
+
96
+ ### Import Sorting
97
+
98
+ Imports are automatically sorted and organized by groups.
99
+
100
+ ### Unused Imports
101
+
102
+ Unused imports are automatically removed on save.
103
+
104
+ ## License
105
+
106
+ MIT
package/base.js ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @baicie/eslint-config - Base ESLint Configuration
3
+ *
4
+ * This is the foundational ESLint configuration that all other configs extend from.
5
+ * Provides TypeScript support, import ordering, and common linting rules.
6
+ */
7
+ import js from '@eslint/js'
8
+ import tseslint from 'typescript-eslint'
9
+ import importPlugin from 'eslint-plugin-import-x'
10
+ import unusedImports from 'eslint-plugin-unused-imports'
11
+ import perfectionist from 'eslint-plugin-perfectionist'
12
+
13
+ /** @type {import('eslint').Linter.Config[]} */
14
+ export default [
15
+ js.configs.recommended,
16
+ ...tseslint.configs.recommended,
17
+ ...tseslint.configs.stylistic,
18
+
19
+ {
20
+ plugins: {
21
+ import: importPlugin,
22
+ 'unused-imports': unusedImports,
23
+ perfectionist: perfectionist,
24
+ },
25
+
26
+ // Disable project-based type checking by default
27
+ // Consumers should configure parserOptions.project in their own config
28
+ languageOptions: {
29
+ parserOptions: {
30
+ project: null,
31
+ tsconfigRootDir: null,
32
+ },
33
+ },
34
+
35
+ rules: {
36
+ // Delete unused imports
37
+ 'unused-imports/no-unused-imports': 'error',
38
+ 'unused-imports/no-unused-vars': [
39
+ 'error',
40
+ {
41
+ argsIgnorePattern: '^_',
42
+ varsIgnorePattern: '^_',
43
+ },
44
+ ],
45
+
46
+ // TypeScript rules
47
+ '@typescript-eslint/no-explicit-any': 'warn',
48
+ '@typescript-eslint/consistent-type-imports': [
49
+ 'error',
50
+ {
51
+ prefer: 'type-imports',
52
+ disallowTypeAnnotations: false,
53
+ },
54
+ ],
55
+
56
+ // Import ordering
57
+ 'import/order': [
58
+ 'warn',
59
+ {
60
+ groups: [
61
+ 'builtin',
62
+ 'external',
63
+ 'internal',
64
+ 'parent',
65
+ 'sibling',
66
+ 'index',
67
+ 'object',
68
+ 'type',
69
+ ],
70
+ 'newlines-between': 'always',
71
+ alphabetize: {
72
+ order: 'asc',
73
+ caseInsensitive: true,
74
+ },
75
+ },
76
+ ],
77
+
78
+ // Perfectionist for sorting
79
+ 'perfectionist/sort-objects': 'off',
80
+
81
+ // Disable conflicting rules
82
+ 'no-unused-vars': 'off',
83
+ },
84
+ },
85
+
86
+ // Ignore patterns
87
+ {
88
+ ignores: [
89
+ '**/dist/**',
90
+ '**/node_modules/**',
91
+ '**/.git/**',
92
+ '**/temp/**',
93
+ '**/__tests__/**',
94
+ '**/*.spec.ts',
95
+ '**/*.test.ts',
96
+ ],
97
+ },
98
+ ]
package/nestjs.js ADDED
@@ -0,0 +1,124 @@
1
+ /**
2
+ * @baicie/eslint-config - NestJS ESLint Configuration
3
+ *
4
+ * Extends the base configuration with NestJS-specific rules and plugins.
5
+ * Use this for NestJS backend projects.
6
+ */
7
+ import base from './base.js'
8
+ import pluginImport from 'eslint-plugin-import'
9
+
10
+ const micromatch = {
11
+ name: 'nestjs/micromatch',
12
+ files: ['**/*.module.ts', '**/*.controller.ts', '**/*.service.ts'],
13
+ rules: {
14
+ // NestJS naming conventions
15
+ '@typescript-eslint/class-naming-convention': [
16
+ 'error',
17
+ {
18
+ selector: 'class',
19
+ format: ['PascalCase'],
20
+ suffix: [
21
+ 'Controller',
22
+ 'Service',
23
+ 'Module',
24
+ 'Middleware',
25
+ 'Guard',
26
+ 'Pipe',
27
+ 'Interceptor',
28
+ 'Decorator',
29
+ 'ExceptionFilter',
30
+ ],
31
+ },
32
+ ],
33
+ },
34
+ }
35
+
36
+ const dtoRules = {
37
+ name: 'nestjs/dto',
38
+ files: ['**/*.dto.ts', '**/*.entity.ts', '**/*.interface.ts'],
39
+ rules: {
40
+ '@typescript-eslint/naming-convention': [
41
+ 'error',
42
+ {
43
+ selector: 'typeLike',
44
+ format: ['PascalCase'],
45
+ },
46
+ {
47
+ selector: 'property',
48
+ format: ['camelCase', 'snake_case'],
49
+ leadingUnderscore: 'allow',
50
+ },
51
+ ],
52
+ },
53
+ }
54
+
55
+ const decoratedClassRules = {
56
+ name: 'nestjs/decorated-classes',
57
+ files: ['**/*.controller.ts', '**/*.service.ts', '**/*.resolver.ts'],
58
+ rules: {
59
+ 'class-methods-use-this': 'off',
60
+ },
61
+ }
62
+
63
+ /** @type {import('eslint').Linter.Config[]} */
64
+ export default [
65
+ ...base,
66
+
67
+ // NestJS-specific rules
68
+ {
69
+ plugins: {
70
+ import: pluginImport,
71
+ },
72
+ },
73
+
74
+ micromatch,
75
+ dtoRules,
76
+ decoratedClassRules,
77
+
78
+ {
79
+ rules: {
80
+ // Allow dependency injection patterns
81
+ 'no-underscore-dangle': [
82
+ 'error',
83
+ {
84
+ allow: ['__', '_id'],
85
+ },
86
+ ],
87
+
88
+ // Allow parameter decorators
89
+ 'no-unused-vars': [
90
+ 'error',
91
+ {
92
+ argsIgnorePattern: '^_',
93
+ varsIgnorePattern: '^_',
94
+ caughtErrorsIgnorePattern: '^_',
95
+ },
96
+ ],
97
+
98
+ // NestJS controller/service naming
99
+ '@typescript-eslint/naming-convention': [
100
+ 'error',
101
+ {
102
+ selector: 'class',
103
+ format: ['PascalCase'],
104
+ },
105
+ {
106
+ selector: 'interface',
107
+ format: ['PascalCase'],
108
+ custom: {
109
+ regex: '^I[A-Z]',
110
+ match: false,
111
+ },
112
+ },
113
+ {
114
+ selector: 'typeAlias',
115
+ format: ['PascalCase'],
116
+ },
117
+ {
118
+ selector: 'enumMember',
119
+ format: ['PascalCase'],
120
+ },
121
+ ],
122
+ },
123
+ },
124
+ ]
package/node.js ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @baicie/eslint-config - Node.js ESLint Configuration
3
+ *
4
+ * Extends the base configuration with Node.js-specific rules.
5
+ * Use this for backend Node.js projects and CLI tools.
6
+ */
7
+ import base from './base.js'
8
+
9
+ /** @type {import('eslint').Linter.Config[]} */
10
+ export default [
11
+ ...base,
12
+
13
+ {
14
+ languageOptions: {
15
+ globals: {
16
+ // Node.js globals
17
+ node: true,
18
+ // CommonJS globals (for mixed projects)
19
+ module: 'readonly',
20
+ require: 'readonly',
21
+ exports: 'readonly',
22
+ },
23
+ },
24
+
25
+ rules: {
26
+ // Node.js specific rules
27
+ 'no-console': 'off',
28
+ 'no-process-exit': 'off',
29
+ },
30
+ },
31
+ ]
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@baicie/eslint-config",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": "./base.js",
7
+ "./react": "./react.js",
8
+ "./node": "./node.js",
9
+ "./strict": "./strict.js",
10
+ "./nestjs": "./nestjs.js",
11
+ "./vue": "./vue.js"
12
+ },
13
+ "peerDependencies": {
14
+ "eslint": "^9.0.0",
15
+ "typescript-eslint": "^8.0.0"
16
+ },
17
+ "devDependencies": {
18
+ "@eslint/js": "^9.0.0",
19
+ "eslint-plugin-import-x": "^4.0.0",
20
+ "eslint-plugin-perfectionist": "^4.0.0",
21
+ "eslint-plugin-react": "^7.0.0",
22
+ "eslint-plugin-react-hooks": "^5.0.0",
23
+ "eslint-plugin-unused-imports": "^4.0.0",
24
+ "eslint-plugin-vue": "^10.0.0",
25
+ "vue-eslint-parser": "^10.0.0",
26
+ "typescript-eslint": "^8.0.0"
27
+ },
28
+ "keywords": [
29
+ "eslint",
30
+ "config",
31
+ "lint",
32
+ "nestjs",
33
+ "vue"
34
+ ],
35
+ "license": "MIT",
36
+ "publishConfig": {
37
+ "access": "public",
38
+ "registry": "https://registry.npmjs.org/"
39
+ }
40
+ }
package/react.js ADDED
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @baicie/eslint-config - React ESLint Configuration
3
+ *
4
+ * Extends the base configuration with React-specific rules and plugins.
5
+ * Use this for React and React Native projects.
6
+ */
7
+ import base from './base.js'
8
+ import react from 'eslint-plugin-react'
9
+ import hooks from 'eslint-plugin-react-hooks'
10
+
11
+ /** @type {import('eslint').Linter.Config[]} */
12
+ export default [
13
+ ...base,
14
+
15
+ {
16
+ plugins: {
17
+ react,
18
+ 'react-hooks': hooks,
19
+ },
20
+
21
+ settings: {
22
+ react: {
23
+ version: 'detect',
24
+ },
25
+ },
26
+
27
+ rules: {
28
+ // React rules
29
+ 'react/prop-types': 'off',
30
+ 'react/display-name': 'off',
31
+ 'react/jsx-uses-react': 'off',
32
+ 'react/react-in-jsx-scope': 'off',
33
+
34
+ // React Hooks rules
35
+ 'react-hooks/rules-of-hooks': 'error',
36
+ 'react-hooks/exhaustive-deps': 'warn',
37
+ },
38
+ },
39
+ ]
package/strict.js ADDED
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @baicie/eslint-config - Strict ESLint Configuration
3
+ *
4
+ * Extends the base configuration with stricter rules for projects
5
+ * that require more rigorous code quality standards.
6
+ */
7
+ import base from './base.js'
8
+
9
+ /** @type {import('eslint').Linter.Config[]} */
10
+ export default [
11
+ ...base,
12
+
13
+ {
14
+ rules: {
15
+ // Stricter TypeScript rules
16
+ '@typescript-eslint/no-explicit-any': 'error',
17
+ '@typescript-eslint/no-non-null-assertion': 'warn',
18
+ '@typescript-eslint/explicit-function-return-type': 'off',
19
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
20
+ '@typescript-eslint/no-explicit-any': 'error',
21
+ '@typescript-eslint/no-unnecessary-type-assertion': 'error',
22
+
23
+ // Stricter import rules
24
+ 'import/no-cycle': 'error',
25
+ 'import/no-duplicates': 'error',
26
+ 'import/no-unresolved': 'error',
27
+
28
+ // Stricter unused vars rules
29
+ 'no-unused-vars': [
30
+ 'error',
31
+ {
32
+ argsIgnorePattern: '^_',
33
+ varsIgnorePattern: '^_',
34
+ caughtErrorsIgnorePattern: '^_',
35
+ },
36
+ ],
37
+
38
+ // Prefer const
39
+ 'prefer-const': 'error',
40
+
41
+ // No debugger
42
+ 'no-debugger': 'error',
43
+ },
44
+ },
45
+ ]
package/vue.js ADDED
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @baicie/eslint-config - Vue.js ESLint Configuration
3
+ *
4
+ * Extends the base configuration with Vue.js and Vue 3 Composition API rules.
5
+ * Use this for Vue.js frontend projects (Vue 2 or Vue 3).
6
+ */
7
+ import base from './base.js'
8
+ import vuePlugin from 'eslint-plugin-vue'
9
+ import vueParser from 'vue-eslint-parser'
10
+
11
+ const VueRecommended = {
12
+ name: 'vue/recommended',
13
+ files: ['**/*.vue'],
14
+ ...vuePlugin.configs['vue3-recommended'],
15
+ }
16
+
17
+ const vueRules = {
18
+ name: 'vue/rules',
19
+ files: ['**/*.vue'],
20
+ rules: {
21
+ // Vue specific rules
22
+ 'vue/multi-word-component-names': 'off',
23
+ 'vue/no-v-html': 'warn',
24
+ 'vue/require-default-prop': 'off',
25
+ 'vue/require-explicit-emits': 'error',
26
+ 'vue/v-on-event-hyphenation': ['error', 'always', { autofix: true }],
27
+ 'vue/define-emits-declaration': ['error', 'type-based'],
28
+ 'vue/define-macros-emulation': [
29
+ 'error',
30
+ ['defineProps', 'defineSlots', 'defineEmits', 'defineExpose'],
31
+ ],
32
+ 'vue/no-unused-vars': 'error',
33
+
34
+ // Vue 3 Composition API
35
+ 'vue/component-api-style': ['error', ['script setup']],
36
+ 'vue/component-tags-order': [
37
+ 'error',
38
+ { order: ['script', 'template', 'style'] },
39
+ ],
40
+ 'vue/block-order': ['error', { order: ['script', 'template', 'style'] }],
41
+ 'vue/define-props-declaration': ['error', 'type-based'],
42
+ 'vue/no-useless-v-bind': 'error',
43
+ 'vue/no-v-text': 'error',
44
+ 'vue/padding-line-between-blocks': 'error',
45
+ 'vue/prefer-separate-static-class': 'error',
46
+ 'vue/prefer-true-attribute-shorthand': 'error',
47
+
48
+ // JSX in Vue (if using)
49
+ 'vue/jsx-uses-vars': 'error',
50
+ },
51
+ }
52
+
53
+ const tsxRules = {
54
+ name: 'vue/tsx',
55
+ files: ['**/*.tsx'],
56
+ rules: {
57
+ // Relaxed rules for TSX files
58
+ 'react/prop-types': 'off',
59
+ },
60
+ }
61
+
62
+ /** @type {import('eslint').Linter.Config[]} */
63
+ export default [
64
+ ...base,
65
+
66
+ {
67
+ name: 'vue/parser',
68
+ files: ['**/*.vue'],
69
+ languageOptions: {
70
+ parser: vueParser,
71
+ parserOptions: {
72
+ ecmaFeatures: {
73
+ jsx: true,
74
+ },
75
+ extraFileExtensions: ['.vue'],
76
+ },
77
+ },
78
+ },
79
+
80
+ VueRecommended,
81
+ vueRules,
82
+ tsxRules,
83
+ ]