@librestock/eslint-config 0.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 (4) hide show
  1. package/base.js +168 -0
  2. package/index.js +4 -0
  3. package/nestjs.js +30 -0
  4. package/package.json +37 -0
package/base.js ADDED
@@ -0,0 +1,168 @@
1
+ import js from '@eslint/js'
2
+ import prettierConfig from 'eslint-config-prettier'
3
+ import pluginImport from 'eslint-plugin-import'
4
+ import pluginPromise from 'eslint-plugin-promise'
5
+ import pluginUnicorn from 'eslint-plugin-unicorn'
6
+ import globals from 'globals'
7
+ import tseslint from 'typescript-eslint'
8
+
9
+ /**
10
+ * Base ESLint configuration for LibreStock monorepo.
11
+ * Modules should import this and extend with their own rules.
12
+ *
13
+ * Usage:
14
+ * import baseConfig from '@librestock/eslint-config'
15
+ * export default tseslint.config(...baseConfig, { ...moduleSpecificRules })
16
+ */
17
+ export default tseslint.config(
18
+ js.configs.recommended,
19
+ ...tseslint.configs.recommendedTypeChecked,
20
+ ...tseslint.configs.stylisticTypeChecked,
21
+
22
+ // Global language options (modules can override)
23
+ {
24
+ languageOptions: {
25
+ ecmaVersion: 2024,
26
+ sourceType: 'module',
27
+ globals: {
28
+ ...globals.node,
29
+ ...globals.es2021,
30
+ },
31
+ parserOptions: {
32
+ project: true,
33
+ },
34
+ },
35
+ },
36
+
37
+ // Import plugin configuration
38
+ {
39
+ plugins: {
40
+ import: pluginImport,
41
+ },
42
+ rules: {
43
+ 'import/order': 'error',
44
+ 'import/no-duplicates': 'error',
45
+ 'import/no-cycle': 'error',
46
+ 'import/no-self-import': 'error',
47
+ 'import/first': 'error',
48
+ 'import/newline-after-import': 'error',
49
+ 'import/no-mutable-exports': 'error',
50
+ },
51
+ },
52
+
53
+ // Code quality plugins
54
+ {
55
+ plugins: {
56
+ unicorn: pluginUnicorn,
57
+ promise: pluginPromise,
58
+ },
59
+ rules: {
60
+ // Unicorn rules
61
+ 'unicorn/better-regex': 'error',
62
+ 'unicorn/catch-error-name': 'error',
63
+ 'unicorn/no-abusive-eslint-disable': 'error',
64
+ 'unicorn/prefer-node-protocol': 'error',
65
+ 'unicorn/prefer-number-properties': 'error',
66
+ 'unicorn/prefer-optional-catch-binding': 'error',
67
+ 'unicorn/prevent-abbreviations': 'off',
68
+ 'unicorn/no-null': 'off',
69
+
70
+ // Promise rules
71
+ 'promise/always-return': 'error',
72
+ 'promise/catch-or-return': 'error',
73
+ 'promise/no-return-wrap': 'error',
74
+ 'promise/param-names': 'error',
75
+ 'promise/no-nesting': 'warn',
76
+ },
77
+ },
78
+
79
+ // TypeScript rules
80
+ {
81
+ rules: {
82
+ '@typescript-eslint/no-unused-vars': [
83
+ 'error',
84
+ {
85
+ args: 'all',
86
+ argsIgnorePattern: '^_',
87
+ caughtErrors: 'all',
88
+ caughtErrorsIgnorePattern: '^_',
89
+ destructuredArrayIgnorePattern: '^_',
90
+ varsIgnorePattern: '^_',
91
+ ignoreRestSiblings: true,
92
+ },
93
+ ],
94
+ '@typescript-eslint/consistent-type-imports': [
95
+ 'error',
96
+ {
97
+ prefer: 'type-imports',
98
+ fixStyle: 'inline-type-imports',
99
+ disallowTypeAnnotations: false,
100
+ },
101
+ ],
102
+ '@typescript-eslint/no-floating-promises': 'error',
103
+ '@typescript-eslint/await-thenable': 'error',
104
+ '@typescript-eslint/require-await': 'error',
105
+ '@typescript-eslint/no-misused-promises': [
106
+ 'error',
107
+ {
108
+ checksVoidReturn: {
109
+ attributes: false,
110
+ },
111
+ },
112
+ ],
113
+ // Disable overly strict unsafe rules - impractical with third-party libraries
114
+ '@typescript-eslint/no-unsafe-assignment': 'off',
115
+ '@typescript-eslint/no-unsafe-member-access': 'off',
116
+ '@typescript-eslint/no-unsafe-call': 'off',
117
+ '@typescript-eslint/no-unsafe-return': 'off',
118
+ '@typescript-eslint/no-unsafe-argument': 'off',
119
+ },
120
+ },
121
+
122
+ // General JavaScript rules
123
+ {
124
+ rules: {
125
+ 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
126
+ 'no-debugger': 'error',
127
+ 'no-var': 'error',
128
+ 'prefer-const': 'error',
129
+ 'prefer-arrow-callback': 'error',
130
+ 'prefer-template': 'error',
131
+ 'object-shorthand': 'error',
132
+ 'prefer-destructuring': ['error', { object: true, array: false }],
133
+ 'prefer-object-spread': 'error',
134
+ 'prefer-rest-params': 'error',
135
+ 'prefer-spread': 'error',
136
+ curly: ['error', 'all'],
137
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
138
+ 'no-else-return': ['error', { allowElseIf: false }],
139
+ 'no-useless-return': 'error',
140
+ 'no-useless-rename': 'error',
141
+ 'no-throw-literal': 'error',
142
+ },
143
+ },
144
+
145
+ // Config/script file overrides
146
+ {
147
+ files: ['**/*.config.{js,ts,mjs,mts}', '**/scripts/**/*'],
148
+ rules: {
149
+ 'no-console': 'off',
150
+ },
151
+ },
152
+
153
+ // Prettier should be last
154
+ prettierConfig,
155
+
156
+ // Common ignore patterns
157
+ {
158
+ ignores: [
159
+ '**/node_modules/**',
160
+ 'dist/**',
161
+ 'build/**',
162
+ 'coverage/**',
163
+ '**/.turbo/**',
164
+ '**/.cache/**',
165
+ '*.min.js',
166
+ ],
167
+ },
168
+ )
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Re-export base config as default
2
+ export { default } from './base.js'
3
+ export { default as base } from './base.js'
4
+ export { default as nestjs } from './nestjs.js'
package/nestjs.js ADDED
@@ -0,0 +1,30 @@
1
+ import baseConfig from './base.js'
2
+ import tseslint from 'typescript-eslint'
3
+
4
+ export default tseslint.config(
5
+ ...baseConfig,
6
+
7
+ // NestJS specific rules
8
+ {
9
+ rules: {
10
+ '@typescript-eslint/interface-name-prefix': 'off',
11
+ '@typescript-eslint/explicit-function-return-type': 'off',
12
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
13
+ '@typescript-eslint/no-explicit-any': 'warn',
14
+ },
15
+ },
16
+
17
+ // Test files
18
+ {
19
+ files: ['**/*.spec.ts', '**/*.e2e-spec.ts'],
20
+ rules: {
21
+ '@typescript-eslint/no-explicit-any': 'off',
22
+ 'no-console': 'off',
23
+ },
24
+ },
25
+
26
+ // Ignore patterns
27
+ {
28
+ ignores: ['dist/**', 'node_modules/**'],
29
+ },
30
+ )
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@librestock/eslint-config",
3
+ "version": "0.1.0",
4
+ "description": "Shared ESLint configurations for LibreStock Inventory monorepo",
5
+ "license": "AGPL-3.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/librestock/packages.git",
9
+ "directory": "eslint-config"
10
+ },
11
+ "type": "module",
12
+ "main": "./index.js",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./base": "./base.js",
16
+ "./nestjs": "./nestjs.js"
17
+ },
18
+ "files": [
19
+ "*.js"
20
+ ],
21
+ "peerDependencies": {
22
+ "eslint": ">=8.0.0",
23
+ "prettier": ">=3.0.0",
24
+ "typescript": ">=5.0.0"
25
+ },
26
+ "dependencies": {
27
+ "@eslint/js": "^9.39.2",
28
+ "@typescript-eslint/eslint-plugin": "^8.50.1",
29
+ "@typescript-eslint/parser": "^8.50.1",
30
+ "eslint-config-prettier": "^10.1.8",
31
+ "eslint-plugin-import": "^2.32.0",
32
+ "eslint-plugin-promise": "^7.2.1",
33
+ "eslint-plugin-unicorn": "^62.0.0",
34
+ "globals": "^16.5.0",
35
+ "typescript-eslint": "^8.50.1"
36
+ }
37
+ }