@petbee/eslint-config 3.0.2 → 3.0.4

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/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // This is the legacy config for ESLint < 9.0
2
2
  module.exports = {
3
3
  parserOptions: {
4
- project: 'tsconfig.json',
5
4
  sourceType: 'module',
6
5
  // ensure tsconfigRootDir is the project root for v8:
7
6
  tsconfigRootDir: process.cwd(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "691cd678231d15a665a7bb1751cac4c2fa3789b1"
84
+ "gitHead": "13a8a59332c6aa1b447f5d830041e7ed00d3e7a2"
85
85
  }
package/rules/nestjs.js CHANGED
@@ -1,12 +1,9 @@
1
- const { hasPackage, getFlat } = require('../lib/utils')
1
+ const { hasPackage } = require('../lib/utils')
2
2
  const nestjsLint = require('@darraghor/eslint-plugin-nestjs-typed')
3
- const tsConfig = require('./typescript.js') // <-- our patched TS config
3
+ const { tsParserOptions } = require('./shared-config.js')
4
4
 
5
5
  const hasNestJs = hasPackage('@nestjs/core')
6
6
 
7
- // Grab TS-ESLint flat override
8
- const tsFlat = getFlat(tsConfig)
9
-
10
7
  const nestjsRules = {
11
8
  '@typescript-eslint/interface-name-prefix': 'off',
12
9
  '@typescript-eslint/explicit-function-return-type': 'off',
@@ -25,19 +22,19 @@ const nestjsRules = {
25
22
  }
26
23
 
27
24
  // If NestJS is present, take its flatRecommended array and
28
- // graft in parserOptions from tsFlat[0]:
25
+ // graft in parserOptions from shared config:
29
26
  const nestFlat = hasNestJs
30
27
  ? [
31
28
  ...nestjsLint.default.configs.flatRecommended.map((cfg) => ({
32
29
  ...cfg,
33
30
  languageOptions: {
34
- ...tsFlat[0].languageOptions,
35
- ...cfg.languageOptions,
36
- // merge parserOptions so `project` stays intact
31
+ parser: require('@typescript-eslint/parser'),
37
32
  parserOptions: {
38
- ...tsFlat[0].languageOptions.parserOptions,
33
+ ...tsParserOptions,
34
+ // merge with any NestJS-specific parserOptions
39
35
  ...cfg.languageOptions?.parserOptions,
40
36
  },
37
+ ...cfg.languageOptions,
41
38
  },
42
39
  })),
43
40
  {
package/rules/nextjs.js CHANGED
@@ -2,6 +2,8 @@ module.exports = {
2
2
  plugins: ['@next/eslint-plugin-next'],
3
3
  extends: ['plugin:@next/next/recommended'],
4
4
  rules: {
5
+ // Allow non-camelCase naming in Next.js projects (e.g., route segments, pages, metadata)
6
+ '@typescript-eslint/naming-convention': 'off',
5
7
  // Next.js specific rules can be added here
6
8
  // For example, enforce no HTML <img> element usage
7
9
  '@next/next/no-img-element': 'error',
package/rules/react.js CHANGED
@@ -2,6 +2,8 @@ module.exports = {
2
2
  plugins: ['react'],
3
3
  extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
4
4
  rules: {
5
+ // Allow non-camelCase naming in React projects (e.g., components, hooks, CSS modules)
6
+ '@typescript-eslint/naming-convention': 'off',
5
7
  // Enforce consistent usage of function component definition
6
8
  // https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/function-component-definition.md
7
9
  'react/function-component-definition': [
@@ -0,0 +1,36 @@
1
+ // Shared configuration to avoid circular dependencies
2
+ const { hasPackage } = require('../lib/utils')
3
+
4
+ const hasTypescript = hasPackage('typescript')
5
+
6
+ // Common TypeScript parser configuration
7
+ const tsParserOptions = {
8
+ ecmaVersion: 2022,
9
+ sourceType: 'module',
10
+ projectService: true,
11
+ tsconfigRootDir: process.cwd(),
12
+ projectFolderIgnoreList: [/node_modules/i],
13
+ allowAutomaticSingleRunInference: true,
14
+ }
15
+
16
+ // Common TypeScript rules
17
+ const tsCommonRules = {
18
+ 'no-useless-catch': 'warn',
19
+ 'no-magic-numbers': ['warn', { ignore: [0, 1], ignoreArrayIndexes: true }],
20
+ 'max-classes-per-file': ['warn', 1],
21
+ 'prefer-arrow-callback': ['warn', { allowNamedFunctions: false, allowUnboundThis: true }],
22
+ 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
23
+ 'import/no-relative-parent-imports': 'warn',
24
+ 'no-restricted-imports': [
25
+ 'error',
26
+ {
27
+ patterns: ['../../*'],
28
+ },
29
+ ],
30
+ }
31
+
32
+ module.exports = {
33
+ hasTypescript,
34
+ tsParserOptions,
35
+ tsCommonRules,
36
+ }
@@ -1,5 +1,6 @@
1
1
  const { hasPackage } = require('../lib/utils')
2
- const hasTypescript = hasPackage('typescript')
2
+ const { hasTypescript, tsParserOptions, tsCommonRules } = require('./shared-config.js')
3
+
3
4
  const hasNestJs = hasPackage('@nestjs/core')
4
5
  const hasReact = hasPackage('react')
5
6
  const hasNext = hasPackage('next') || hasPackage('nextjs')
@@ -7,7 +8,9 @@ const hasNext = hasPackage('next') || hasPackage('nextjs')
7
8
  // Load framework-specific rules
8
9
  const reactRules = hasReact ? require('./react.js').rules : {}
9
10
  const nextjsRules = hasNext ? require('./nextjs.js').rules : {}
10
- const nestjsRules = hasNestJs ? require('./nestjs.js').rules : {}
11
+ // Note: Don't require nestjs.js here to avoid circular dependency.
12
+ // NestJS handles its own flat config completely.
13
+ const nestjsRules = {}
11
14
 
12
15
  const tsConfigOptions = [
13
16
  {
@@ -15,31 +18,9 @@ const tsConfigOptions = [
15
18
  extends: ['plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/recommended'],
16
19
  plugins: ['@typescript-eslint'],
17
20
  parser: '@typescript-eslint/parser',
18
- parserOptions: {
19
- ecmaVersion: 2022,
20
- sourceType: 'module',
21
- projectService: true,
22
- defaultProject: 'tsconfig.json',
23
- tsconfigRootDir: process.cwd(),
24
- projectFolderIgnoreList: [/node_modules/i],
25
- // We need this configuration to avoid performance issues in monorepos
26
- // https://github.com/typescript-eslint/typescript-eslint/issues/1192#issuecomment-862414778
27
- allowAutomaticSingleRunInference: true,
28
- },
21
+ parserOptions: tsParserOptions,
29
22
  rules: {
30
- // General improvements
31
- 'no-useless-catch': 'warn',
32
- 'no-magic-numbers': ['warn', { ignore: [0, 1], ignoreArrayIndexes: true }],
33
- 'max-classes-per-file': ['warn', 1],
34
- 'prefer-arrow-callback': ['warn', { allowNamedFunctions: false, allowUnboundThis: true }],
35
- 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }],
36
- 'import/no-relative-parent-imports': 'warn',
37
- 'no-restricted-imports': [
38
- 'error',
39
- {
40
- patterns: ['../../*'],
41
- },
42
- ],
23
+ ...tsCommonRules,
43
24
  ...reactRules,
44
25
  ...nextjsRules,
45
26
  ...nestjsRules,
@@ -63,7 +44,7 @@ const flatConfig = hasTypescript
63
44
  languageOptions: {
64
45
  parser: require('@typescript-eslint/parser'),
65
46
  parserOptions: {
66
- ...tsConfigOptions[0].parserOptions,
47
+ ...tsParserOptions,
67
48
  tsconfigRootDir: process.cwd(),
68
49
  },
69
50
  },