@santi020k/eslint-config-basic 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 (140) hide show
  1. package/.agent/rules/context.md +78 -0
  2. package/.agent/rules/guidelines.md +124 -0
  3. package/.editorconfig +13 -0
  4. package/.env.example +8 -0
  5. package/.github/CODEOWNERS +2 -0
  6. package/.github/DISCUSSION_TEMPLATE/rfcs.yml +21 -0
  7. package/.github/DISCUSSION_TEMPLATE/technical-discussions.yml +21 -0
  8. package/.github/FUNDING.yml +2 -0
  9. package/.github/ISSUE_TEMPLATE/README.md +13 -0
  10. package/.github/ISSUE_TEMPLATE/bug_report.yml +69 -0
  11. package/.github/ISSUE_TEMPLATE/config.yml +8 -0
  12. package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
  13. package/.github/ISSUE_TEMPLATE/question.yml +22 -0
  14. package/.github/SECURITY.md +12 -0
  15. package/.github/SPONSORSHIPS.md +27 -0
  16. package/.github/dependabot.yml +45 -0
  17. package/.github/labeler.yml +46 -0
  18. package/.github/pull_request_template.md +56 -0
  19. package/.github/workflows/assign-issues.yml +18 -0
  20. package/.github/workflows/audit.yml +22 -0
  21. package/.github/workflows/build.yml +29 -0
  22. package/.github/workflows/codeql.yml +40 -0
  23. package/.github/workflows/docs.yml +49 -0
  24. package/.github/workflows/labeler.yml +18 -0
  25. package/.github/workflows/publish.yml +24 -0
  26. package/.github/workflows/release.yml +35 -0
  27. package/.github/workflows/size-check.yml +23 -0
  28. package/.github/workflows/stale.yml +31 -0
  29. package/.nvmrc +1 -0
  30. package/.vscode/extensions.json +10 -0
  31. package/.vscode/settings.json +55 -0
  32. package/CHANGELOG.md +16 -0
  33. package/CONTRIBUTING.md +194 -0
  34. package/DEVELOPMENT.md +4 -0
  35. package/LICENSE +21 -0
  36. package/README.md +275 -0
  37. package/config/.husky/commit-msg +9 -0
  38. package/config/.husky/pre-commit +1 -0
  39. package/config/.husky/pre-push +1 -0
  40. package/config/.husky/prepare-commit-msg +1 -0
  41. package/cspell.config.yaml +2 -0
  42. package/eslint.config.js +21 -0
  43. package/llms.txt +72 -0
  44. package/package.json +61 -0
  45. package/packages/astro/README.md +13 -0
  46. package/packages/astro/package.json +45 -0
  47. package/packages/astro/src/ambient.d.ts +10 -0
  48. package/packages/astro/src/index.ts +18 -0
  49. package/packages/astro/src/rules.ts +29 -0
  50. package/packages/astro/tsconfig.json +9 -0
  51. package/packages/astro/tsup.config.ts +11 -0
  52. package/packages/basic/README.md +33 -0
  53. package/packages/basic/package.json +55 -0
  54. package/packages/basic/src/index.ts +110 -0
  55. package/packages/basic/tsconfig.json +9 -0
  56. package/packages/basic/tsup.config.ts +18 -0
  57. package/packages/core/README.md +14 -0
  58. package/packages/core/index.ts +14 -0
  59. package/packages/core/package.json +61 -0
  60. package/packages/core/src/ambient.d.ts +61 -0
  61. package/packages/core/src/index.ts +75 -0
  62. package/packages/core/src/rules.ts +157 -0
  63. package/packages/core/src/settings/gitignore.ts +10 -0
  64. package/packages/core/src/settings/index.ts +1 -0
  65. package/packages/core/src/types.ts +57 -0
  66. package/packages/core/src/utils/index.ts +28 -0
  67. package/packages/core/tsconfig.json +9 -0
  68. package/packages/core/tsup.config.ts +10 -0
  69. package/packages/expo/README.md +13 -0
  70. package/packages/expo/package.json +48 -0
  71. package/packages/expo/src/ambient.d.ts +3 -0
  72. package/packages/expo/src/index.ts +39 -0
  73. package/packages/expo/tsconfig.json +9 -0
  74. package/packages/expo/tsup.config.ts +11 -0
  75. package/packages/nest/package.json +45 -0
  76. package/packages/nest/src/ambient.d.ts +14 -0
  77. package/packages/nest/src/index.ts +20 -0
  78. package/packages/nest/src/rules.ts +15 -0
  79. package/packages/nest/tsconfig.json +9 -0
  80. package/packages/nest/tsup.config.ts +11 -0
  81. package/packages/next/README.md +13 -0
  82. package/packages/next/package.json +47 -0
  83. package/packages/next/src/index.ts +31 -0
  84. package/packages/next/src/rules.ts +16 -0
  85. package/packages/next/tsconfig.json +9 -0
  86. package/packages/next/tsup.config.ts +10 -0
  87. package/packages/optionals/README.md +18 -0
  88. package/packages/optionals/package.json +55 -0
  89. package/packages/optionals/src/ambient.d.ts +25 -0
  90. package/packages/optionals/src/cspell.ts +14 -0
  91. package/packages/optionals/src/i18next.ts +19 -0
  92. package/packages/optionals/src/index.ts +8 -0
  93. package/packages/optionals/src/markdown.ts +66 -0
  94. package/packages/optionals/src/mdx.ts +40 -0
  95. package/packages/optionals/src/stencil.ts +48 -0
  96. package/packages/optionals/src/tailwind.ts +11 -0
  97. package/packages/optionals/src/vitest.ts +61 -0
  98. package/packages/optionals/tsconfig.json +9 -0
  99. package/packages/optionals/tsup.config.ts +11 -0
  100. package/packages/playground/README.md +14 -0
  101. package/packages/playground/package.json +17 -0
  102. package/packages/playground/src/astro/eslint.config.js +4 -0
  103. package/packages/playground/src/js/eslint.config.js +4 -0
  104. package/packages/playground/src/js/index.test.js +63 -0
  105. package/packages/playground/src/mdx/eslint.config.js +4 -0
  106. package/packages/playground/src/mdx/index.mdx +115 -0
  107. package/packages/playground/src/react/eslint.config.js +4 -0
  108. package/packages/playground/src/react/index.test.jsx +130 -0
  109. package/packages/playground/src/ts/eslint.config.js +4 -0
  110. package/packages/playground/src/ts/index.test.ts +61 -0
  111. package/packages/playground/src/ts/tsconfig.json +3 -0
  112. package/packages/playground/tsconfig.json +9 -0
  113. package/packages/react/README.md +14 -0
  114. package/packages/react/index.ts +26 -0
  115. package/packages/react/package.json +49 -0
  116. package/packages/react/src/ambient.d.ts +23 -0
  117. package/packages/react/src/index.ts +52 -0
  118. package/packages/react/src/rules.ts +47 -0
  119. package/packages/react/tsconfig.json +9 -0
  120. package/packages/react/tsup.config.ts +10 -0
  121. package/packages/tests/README.md +17 -0
  122. package/packages/tests/package.json +21 -0
  123. package/packages/tests/src/__snapshots__/snapshots.test.ts.snap +654 -0
  124. package/packages/tests/src/composition.test.ts +171 -0
  125. package/packages/tests/src/configs.test.ts +118 -0
  126. package/packages/tests/src/rules.test.ts +60 -0
  127. package/packages/tests/src/snapshots.test.ts +126 -0
  128. package/packages/tests/tsconfig.json +10 -0
  129. package/packages/tests/vitest.config.ts +8 -0
  130. package/packages/typescript/README.md +14 -0
  131. package/packages/typescript/package.json +47 -0
  132. package/packages/typescript/src/index.ts +32 -0
  133. package/packages/typescript/src/rules.ts +36 -0
  134. package/packages/typescript/tsconfig.json +9 -0
  135. package/packages/typescript/tsup.config.ts +10 -0
  136. package/tsconfig.base.json +20 -0
  137. package/tsconfig.docs.json +18 -0
  138. package/turbo.json +19 -0
  139. package/typedoc.config.mjs +25 -0
  140. package/typedoc.markdown.mjs +26 -0
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@santi020k/eslint-config-basic",
3
+ "version": "0.0.0",
4
+ "description": "A comprehensive ESLint configuration package for JavaScript, TypeScript, and React projects.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup",
20
+ "dev": "tsup --watch",
21
+ "clean": "rm -rf dist"
22
+ },
23
+ "dependencies": {
24
+ "@santi020k/eslint-config-astro": "*",
25
+ "@santi020k/eslint-config-core": "*",
26
+ "@santi020k/eslint-config-expo": "*",
27
+ "@santi020k/eslint-config-nest": "*",
28
+ "@santi020k/eslint-config-next": "*",
29
+ "@santi020k/eslint-config-optionals": "*",
30
+ "@santi020k/eslint-config-react": "*",
31
+ "@santi020k/eslint-config-typescript": "*",
32
+ "@eslint/compat": "^2.0.2",
33
+ "@eslint/js": "^9.39.2",
34
+ "@typescript-eslint/eslint-plugin": "^8.54.0",
35
+ "@typescript-eslint/type-utils": "^8.54.0",
36
+ "cross-dirname": "^0.1.0",
37
+ "eslint": "^9.39.2",
38
+ "typescript-eslint": "^8.54.0"
39
+ },
40
+ "devDependencies": {
41
+ "tsup": "^8.5.1",
42
+ "typescript": "^5.9.3",
43
+ "@typescript-eslint/utils": "^8.54.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "author": "santi020k",
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/santi020k/eslint-config.git",
53
+ "directory": "packages/basic"
54
+ }
55
+ }
@@ -0,0 +1,110 @@
1
+ // Re-export types and utilities from core
2
+ export {
3
+ ConfigOption,
4
+ OptionalOption,
5
+ SettingOption,
6
+ ReactConfigs,
7
+ applyConfigIfOptionPresent,
8
+ hasReactConfig,
9
+ coreConfig,
10
+ jsConfig,
11
+ gitignore
12
+ } from '@santi020k/eslint-config-core'
13
+
14
+ export type {
15
+ EslintConfigOptions,
16
+ FlatConfigArray
17
+ } from '@santi020k/eslint-config-core'
18
+
19
+ // Re-export framework configs
20
+ export { typescriptConfig, tsConfig } from '@santi020k/eslint-config-typescript'
21
+
22
+ export { reactConfig } from '@santi020k/eslint-config-react'
23
+
24
+ export { nextConfig } from '@santi020k/eslint-config-next'
25
+
26
+ export { astroConfig } from '@santi020k/eslint-config-astro'
27
+
28
+ export { expoConfig } from '@santi020k/eslint-config-expo'
29
+
30
+ export { nestConfig } from '@santi020k/eslint-config-nest'
31
+
32
+ // Re-export optionals
33
+ export {
34
+ cspell,
35
+ i18next,
36
+ markdown,
37
+ mdx,
38
+ stencil,
39
+ tailwind,
40
+ vitest
41
+ } from '@santi020k/eslint-config-optionals'
42
+
43
+ // Import for composition
44
+ import { astroConfig } from '@santi020k/eslint-config-astro'
45
+ import type { EslintConfigOptions, FlatConfigArray } from '@santi020k/eslint-config-core'
46
+ import {
47
+ applyConfigIfOptionPresent,
48
+ ConfigOption,
49
+ coreConfig,
50
+ gitignore,
51
+ hasReactConfig,
52
+ OptionalOption,
53
+ SettingOption
54
+ } from '@santi020k/eslint-config-core'
55
+ import { expoConfig } from '@santi020k/eslint-config-expo'
56
+ import { nestConfig } from '@santi020k/eslint-config-nest'
57
+ import { nextConfig } from '@santi020k/eslint-config-next'
58
+ import {
59
+ cspell,
60
+ i18next,
61
+ markdown,
62
+ mdx,
63
+ stencil,
64
+ tailwind,
65
+ vitest
66
+ } from '@santi020k/eslint-config-optionals'
67
+ import { reactConfig } from '@santi020k/eslint-config-react'
68
+ import { typescriptConfig } from '@santi020k/eslint-config-typescript'
69
+
70
+ /**
71
+ * Generates the ESLint configuration array, applying configurations
72
+ * and optional settings based on the input configuration.
73
+ *
74
+ * @param {EslintConfigOptions} options - Configuration and optional settings
75
+ * @returns {FlatConfigArray} The final ESLint configuration array
76
+ */
77
+ export const eslintConfig = ({
78
+ config = [],
79
+ optionals = [],
80
+ settings = []
81
+ }: EslintConfigOptions = {}): FlatConfigArray => {
82
+ const hasReact = hasReactConfig(config)
83
+
84
+ return [
85
+ // Settings
86
+ ...(settings.includes(SettingOption.Gitignore) ? gitignore : []),
87
+
88
+ // Core JS config (always included)
89
+ ...coreConfig,
90
+
91
+ // React config (included if any React-based framework is used)
92
+ ...(hasReact ? reactConfig : []),
93
+
94
+ // Framework-specific configs
95
+ ...applyConfigIfOptionPresent(config, ConfigOption.Ts, typescriptConfig),
96
+ ...applyConfigIfOptionPresent(config, ConfigOption.Next, nextConfig),
97
+ ...applyConfigIfOptionPresent(config, ConfigOption.Astro, astroConfig),
98
+ ...applyConfigIfOptionPresent(config, ConfigOption.Expo, expoConfig),
99
+ ...applyConfigIfOptionPresent(config, ConfigOption.Nest, nestConfig),
100
+
101
+ // Optionals
102
+ ...(optionals.includes(OptionalOption.Cspell) ? cspell : []),
103
+ ...(optionals.includes(OptionalOption.Tailwind) ? tailwind : []),
104
+ ...(optionals.includes(OptionalOption.Vitest) ? vitest : []),
105
+ ...(optionals.includes(OptionalOption.I18next) ? i18next : []),
106
+ ...(optionals.includes(OptionalOption.Stencil) ? stencil : []),
107
+ ...(optionals.includes(OptionalOption.Mdx) ? mdx : []),
108
+ ...(optionals.includes(OptionalOption.Markdown) ? markdown : [])
109
+ ]
110
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*.ts"],
8
+ "exclude": ["node_modules", "dist"]
9
+ }
@@ -0,0 +1,18 @@
1
+ import type { Options } from 'tsup'
2
+
3
+ const env = process.env.NODE_ENV
4
+
5
+ export const tsup: Options = {
6
+ splitting: true,
7
+ clean: true, // clean up the dist folder
8
+ dts: true, // generate dts files
9
+ format: ['esm'], // generate esm files
10
+ minify: false,
11
+ // bundle: env === 'production',
12
+ skipNodeModulesBundle: true,
13
+ entryPoints: ['src/index.ts'],
14
+ watch: env === 'development',
15
+ target: 'es2020',
16
+ outDir: 'dist',
17
+ entry: ['src/**/*.ts'] // include all files under src
18
+ }
@@ -0,0 +1,14 @@
1
+ # @santi020k/eslint-config-core
2
+
3
+ Core ESLint configuration and utilities for the `@santi020k/eslint-config` monorepo.
4
+
5
+ ## Description
6
+
7
+ This package contains:
8
+ - Base JavaScript rules.
9
+ - Types and Enums (`ConfigOption`, `OptionalOption`, etc.).
10
+ - Utility functions for composing configurations.
11
+
12
+ ## Installation
13
+
14
+ This package is an internal dependency of `@santi020k/eslint-config` and is not intended to be installed directly.
@@ -0,0 +1,14 @@
1
+ import tseslint from 'typescript-eslint'
2
+
3
+ import js from '@eslint/js'
4
+
5
+ export default [
6
+ js.configs.recommended,
7
+ ...tseslint.configs.recommended,
8
+ {
9
+ rules: {
10
+ 'no-unused-vars': 'warn',
11
+ 'no-console': 'warn'
12
+ }
13
+ }
14
+ ]
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@santi020k/eslint-config-core",
3
+ "version": "0.0.0",
4
+ "description": "Core ESLint configuration with base JavaScript rules and shared utilities",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./utils": {
15
+ "import": "./dist/utils/index.js",
16
+ "types": "./dist/utils/index.d.ts"
17
+ },
18
+ "./types": {
19
+ "import": "./dist/types.js",
20
+ "types": "./dist/types.d.ts"
21
+ }
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "clean": "rm -rf dist"
30
+ },
31
+ "peerDependencies": {
32
+ "eslint": "^9.0.0"
33
+ },
34
+ "dependencies": {
35
+ "@eslint/js": "^9.39.2",
36
+ "@stylistic/eslint-plugin": "^5.7.1",
37
+ "eslint-config-standard": "^17.1.0",
38
+ "eslint-plugin-import": "^2.32.0",
39
+ "eslint-plugin-jsx-a11y": "^6.10.2",
40
+ "eslint-plugin-n": "^17.23.2",
41
+ "eslint-plugin-promise": "^7.2.1",
42
+ "eslint-plugin-simple-import-sort": "^12.1.1",
43
+ "eslint-plugin-unused-imports": "^4.3.0",
44
+ "globals": "^17.3.0"
45
+ },
46
+ "devDependencies": {
47
+ "@typescript-eslint/utils": "^8.54.0",
48
+ "tsup": "^8.5.1",
49
+ "typescript": "^5.9.3"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "license": "MIT",
55
+ "author": "santi020k",
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "git+https://github.com/santi020k/eslint-config.git",
59
+ "directory": "packages/core"
60
+ }
61
+ }
@@ -0,0 +1,61 @@
1
+ // Type declarations for ESLint plugins that don't ship their own types
2
+
3
+ declare module 'eslint-config-standard' {
4
+ import type { TSESLint } from '@typescript-eslint/utils'
5
+
6
+ const config: {
7
+ rules: TSESLint.Linter.RulesRecord
8
+ }
9
+
10
+ export default config
11
+ }
12
+
13
+ declare module 'eslint-plugin-import' {
14
+ import type { TSESLint } from '@typescript-eslint/utils'
15
+
16
+ const plugin: {
17
+ rules: Record<string, TSESLint.RuleModule<string, unknown[]>>
18
+ }
19
+
20
+ export default plugin
21
+ }
22
+
23
+ declare module 'eslint-plugin-jsx-a11y' {
24
+ import type { TSESLint } from '@typescript-eslint/utils'
25
+
26
+ const plugin: TSESLint.FlatConfig.Plugin
27
+
28
+ export default plugin
29
+ }
30
+
31
+ declare module 'eslint-plugin-n' {
32
+ import type { TSESLint } from '@typescript-eslint/utils'
33
+
34
+ const plugin: TSESLint.FlatConfig.Plugin
35
+
36
+ export default plugin
37
+ }
38
+
39
+ declare module 'eslint-plugin-promise' {
40
+ import type { TSESLint } from '@typescript-eslint/utils'
41
+
42
+ const plugin: TSESLint.FlatConfig.Plugin
43
+
44
+ export default plugin
45
+ }
46
+
47
+ declare module 'eslint-plugin-simple-import-sort' {
48
+ import type { TSESLint } from '@typescript-eslint/utils'
49
+
50
+ const plugin: TSESLint.FlatConfig.Plugin
51
+
52
+ export default plugin
53
+ }
54
+
55
+ declare module 'eslint-plugin-unused-imports' {
56
+ import type { TSESLint } from '@typescript-eslint/utils'
57
+
58
+ const plugin: TSESLint.FlatConfig.Plugin
59
+
60
+ export default plugin
61
+ }
@@ -0,0 +1,75 @@
1
+ // @ts-check
2
+ import configStandard from 'eslint-config-standard'
3
+ import pluginImport from 'eslint-plugin-import'
4
+ import pluginJsxA11y from 'eslint-plugin-jsx-a11y'
5
+ import pluginN from 'eslint-plugin-n'
6
+ import pluginPromise from 'eslint-plugin-promise'
7
+ import pluginSimpleImport from 'eslint-plugin-simple-import-sort'
8
+ import pluginUnusedImport from 'eslint-plugin-unused-imports'
9
+ import globals from 'globals'
10
+
11
+ import { rules } from './rules.js'
12
+
13
+ import eslint from '@eslint/js'
14
+ import pluginStylistic from '@stylistic/eslint-plugin'
15
+ import type { TSESLint } from '@typescript-eslint/utils'
16
+
17
+ // Re-export types and utilities
18
+ export * from './types.js'
19
+
20
+ export * from './utils/index.js'
21
+
22
+ const languageOptions: TSESLint.FlatConfig.LanguageOptions = {
23
+ ecmaVersion: 'latest',
24
+ sourceType: 'module',
25
+ globals: {
26
+ ...globals.browser,
27
+ ...globals.node
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Core JavaScript ESLint configuration
33
+ * This is included by default in all configurations
34
+ */
35
+ export const coreConfig: TSESLint.FlatConfig.ConfigArray = [
36
+ {
37
+ name: 'eslint-config/recommended',
38
+ ...eslint.configs.recommended
39
+ },
40
+ {
41
+ name: 'eslint-config/plugins',
42
+ plugins: {
43
+ n: pluginN,
44
+ promise: pluginPromise,
45
+ import: { rules: pluginImport.rules },
46
+ 'simple-import-sort': pluginSimpleImport,
47
+ 'jsx-a11y': pluginJsxA11y,
48
+ 'unused-imports': pluginUnusedImport
49
+ },
50
+ languageOptions,
51
+ rules: {
52
+ ...configStandard.rules,
53
+ 'import/first': 'off'
54
+ }
55
+ },
56
+ {
57
+ name: 'eslint-config/stylistic',
58
+ ...pluginStylistic.configs.recommended
59
+ },
60
+ {
61
+ name: 'eslint-config/custom-js',
62
+ languageOptions,
63
+ files: ['**/*.{js,jsx,mjs,cjs}'],
64
+ rules
65
+ }
66
+ ]
67
+
68
+ // Legacy export for backwards compatibility
69
+ export { coreConfig as jsConfig }
70
+
71
+ // Export rules and groups for use by other packages
72
+ export { rules, groups } from './rules.js'
73
+
74
+ // Export settings
75
+ export { gitignore } from './settings/index.js'
@@ -0,0 +1,157 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+
3
+ const groups = [
4
+ // Internal packages.
5
+ // Atomic Design and components
6
+ ['^(components|@/components|@components)(/.*|$)'],
7
+ ['^(ui|@/ui|@ui)(/.*|$)'],
8
+ ['^(atoms|@/atoms|@atoms)(/.*|$)'],
9
+ ['^(molecules|@/molecules|@molecules)(/.*|$)'],
10
+ ['^(organisms|@/organisms|@organisms)(/.*|$)'],
11
+ ['^(templates|@/templates|@templates)(/.*|$)'],
12
+ ['^(pages|@/pages|@pages)(/.*|$)'],
13
+ // Other posible folders
14
+ ['^(store|@/store|@store)(/.*|$)'],
15
+ ['^(api|@/api|@api)(/.*|$)'],
16
+ ['^(contexts|@/contexts|@contexts)(/.*|$)'],
17
+ ['^(hooks|@/hooks|@hooks)(/.*|$)'],
18
+ ['^(lib|@/lib|@lib)(/.*|$)'],
19
+ ['^(services|@/services|@services)(/.*|$)'],
20
+ ['^(models|@/models|@models)(/.*|$)'],
21
+ ['^(utils|@/utils|@utils)(/.*|$)'],
22
+ ['^(ws|@/ws|@ws)(/.*|$)'],
23
+ // npm packages
24
+ ['^\\w'],
25
+ // Side effect imports.
26
+ ['^\\u0000'],
27
+ // Other relative imports. Put same-folder imports and `.` last.
28
+ ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
29
+ // Parent imports. Put `..` last.
30
+ ['^\\.\\.(?!/?$)', '^\\.\\./?$'],
31
+ // Style imports.
32
+ ['^.+\\.?(css|scss)$']
33
+ ]
34
+
35
+ export const rules: TSESLint.Linter.RulesRecord = {
36
+ 'unused-imports/no-unused-imports': 'warn',
37
+ indent: 'off',
38
+ 'brace-style': 'off',
39
+ '@stylistic/brace-style': ['warn', '1tbs'],
40
+ '@stylistic/indent': ['warn', 2],
41
+ '@stylistic/quote-props': ['warn', 'as-needed'],
42
+ quotes: 'off',
43
+ '@stylistic/quotes': ['warn', 'single'],
44
+ '@stylistic/semi': ['warn', 'never'],
45
+ 'quote-props': 'off',
46
+ 'comma-dangle': 'off',
47
+ '@stylistic/comma-dangle': ['warn', 'never'],
48
+ '@stylistic/object-curly-spacing': ['warn', 'always'],
49
+ '@stylistic/padded-blocks': ['warn', 'never'],
50
+ '@stylistic/arrow-parens': ['warn', 'as-needed'],
51
+ '@stylistic/dot-location': ['warn', 'property'],
52
+ '@stylistic/function-call-argument-newline': ['warn', 'never'],
53
+ '@stylistic/object-property-newline': [
54
+ 'warn',
55
+ { allowAllPropertiesOnSameLine: true }
56
+ ],
57
+ '@stylistic/multiline-ternary': ['warn', 'always-multiline'],
58
+ '@stylistic/member-delimiter-style': ['error', {
59
+ multiline: {
60
+ delimiter: 'none',
61
+ requireLast: false
62
+ },
63
+ singleline: {
64
+ delimiter: 'comma',
65
+ requireLast: false
66
+ },
67
+ overrides: {
68
+ interface: {
69
+ multiline: {
70
+ delimiter: 'none',
71
+ requireLast: false
72
+ }
73
+ }
74
+ }
75
+ }],
76
+ '@stylistic/no-extra-parens': 'off',
77
+ '@stylistic/max-len': [
78
+ 'warn',
79
+ {
80
+ code: 120,
81
+ tabWidth: 2,
82
+ comments: 200,
83
+ ignoreStrings: true
84
+ }
85
+ ],
86
+ '@stylistic/max-statements-per-line': ['warn', { max: 1 }],
87
+ '@stylistic/array-element-newline': ['warn', 'consistent'],
88
+ '@stylistic/no-extra-semi': 'off',
89
+ '@stylistic/no-multi-spaces': 'off',
90
+ '@stylistic/padding-line-between-statements': [
91
+ 'warn',
92
+ { blankLine: 'always', prev: '*', next: '*' },
93
+ { blankLine: 'any', prev: 'import', next: 'import' },
94
+ {
95
+ blankLine: 'always',
96
+ prev: ['const', 'let', 'var'],
97
+ next: ['const', 'let', 'var']
98
+ },
99
+ {
100
+ blankLine: 'never',
101
+ prev: ['singleline-const', 'singleline-let', 'singleline-var'],
102
+ next: ['singleline-const', 'singleline-let', 'singleline-var']
103
+ },
104
+ { blankLine: 'always', prev: 'block-like', next: 'const' },
105
+ { blankLine: 'always', prev: 'const', next: 'block-like' }
106
+ ],
107
+ '@stylistic/function-paren-newline': ['warn', 'consistent'],
108
+ 'arrow-body-style': ['warn', 'as-needed'],
109
+ 'prefer-arrow-callback': ['warn', { allowNamedFunctions: true }],
110
+ 'func-style': ['warn', 'expression', { allowArrowFunctions: true }],
111
+ 'simple-import-sort/imports': [
112
+ 'warn',
113
+ {
114
+ groups
115
+ }
116
+ ],
117
+ 'jsx-a11y/alt-text': 'warn',
118
+ 'no-empty': 'warn',
119
+ 'no-nested-ternary': 'warn',
120
+ 'no-undef': 'warn',
121
+ 'unused-imports/no-unused-vars': [
122
+ 'warn',
123
+ {
124
+ vars: 'all',
125
+ varsIgnorePattern: '^_',
126
+ args: 'after-used',
127
+ argsIgnorePattern: '^_',
128
+ destructuredArrayIgnorePattern: '^_',
129
+ ignoreRestSiblings: true
130
+ }
131
+ ],
132
+ 'no-void': 'warn',
133
+ camelcase: 'warn',
134
+ 'array-callback-return': 'warn',
135
+ 'no-fallthrough': 'warn',
136
+ eqeqeq: 'warn',
137
+ 'no-constant-binary-expression': 'warn',
138
+ '@stylistic/lines-around-comment': ['error', { allowClassStart: true, beforeLineComment: false, allowBlockStart: true }],
139
+ 'import/no-duplicates': 'warn',
140
+ 'valid-typeof': 'warn',
141
+ 'no-constant-condition': 'warn',
142
+ 'no-use-before-define': 'warn',
143
+ '@stylistic/implicit-arrow-linebreak': 'warn',
144
+ 'import/export': 'warn',
145
+ 'no-useless-escape': 'warn',
146
+ 'no-useless-return': 'warn',
147
+ 'prefer-promise-reject-errors': 'warn',
148
+ 'no-useless-constructor': 'warn',
149
+ 'no-new': 'warn',
150
+ 'prefer-regex-literals': 'warn',
151
+ '@stylistic/multiline-comment-style': 'off',
152
+ 'space-before-function-paren': 'off',
153
+ 'operator-linebreak': 'off',
154
+ '@stylistic/operator-linebreak': ['error', 'after']
155
+ }
156
+
157
+ export { groups }
@@ -0,0 +1,10 @@
1
+ import { includeIgnoreFile } from '@eslint/compat'
2
+ import type { TSESLint } from '@typescript-eslint/utils'
3
+
4
+ /**
5
+ * Gitignore ESLint configuration
6
+ * Automatically ignores files from .gitignore
7
+ */
8
+ export const gitignore: TSESLint.FlatConfig.ConfigArray = [
9
+ includeIgnoreFile(`${process.cwd()}/.gitignore`) as TSESLint.FlatConfig.Config
10
+ ]
@@ -0,0 +1 @@
1
+ export { gitignore } from './gitignore.js'
@@ -0,0 +1,57 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+
3
+ /**
4
+ * Enum for configuration options in ESLint
5
+ */
6
+ export enum ConfigOption {
7
+ Ts = 'ts',
8
+ React = 'react',
9
+ Next = 'next',
10
+ Expo = 'expo',
11
+ Astro = 'astro',
12
+ Nest = 'nest'
13
+ }
14
+
15
+ /**
16
+ * Enum for optional features that can be included in ESLint
17
+ */
18
+ export enum OptionalOption {
19
+ Cspell = 'cspell',
20
+ Tailwind = 'tailwind',
21
+ Vitest = 'vitest',
22
+ I18next = 'i18next',
23
+ Mdx = 'mdx',
24
+ Markdown = 'markdown',
25
+ Stencil = 'stencil'
26
+ }
27
+
28
+ /**
29
+ * Enum for settings options in ESLint
30
+ */
31
+ export enum SettingOption {
32
+ Gitignore = 'gitignore'
33
+ }
34
+
35
+ /**
36
+ * Array of configurations that require React
37
+ */
38
+ export const ReactConfigs: ConfigOption[] = [
39
+ ConfigOption.React,
40
+ ConfigOption.Astro,
41
+ ConfigOption.Next,
42
+ ConfigOption.Expo
43
+ ]
44
+
45
+ /**
46
+ * ESLint configuration interface
47
+ */
48
+ export interface EslintConfigOptions {
49
+ config?: ConfigOption[]
50
+ optionals?: OptionalOption[]
51
+ settings?: SettingOption[]
52
+ }
53
+
54
+ /**
55
+ * Type alias for ESLint flat config array
56
+ */
57
+ export type FlatConfigArray = TSESLint.FlatConfig.ConfigArray
@@ -0,0 +1,28 @@
1
+ import type { FlatConfigArray } from '../types.js'
2
+ import { ConfigOption, ReactConfigs } from '../types.js'
3
+
4
+ /**
5
+ * Adds a specific configuration if the given option is present in the configs array.
6
+ *
7
+ * @param configs - An array of configuration options.
8
+ * @param option - The option to check for.
9
+ * @param configToAdd - The configuration to add if the option is present.
10
+ * @returns The configuration to add if the option is present, otherwise an empty array.
11
+ */
12
+ export const applyConfigIfOptionPresent = (
13
+ configs: ConfigOption[],
14
+ option: ConfigOption,
15
+ configToAdd: FlatConfigArray
16
+ ): FlatConfigArray => configs.includes(option) ? configToAdd : []
17
+
18
+ /**
19
+ * Checks if the provided configs array includes any React-specific configurations.
20
+ *
21
+ * @param configs - An optional array of configuration options.
22
+ * @returns True if any React configuration is found, false otherwise.
23
+ */
24
+ export const hasReactConfig = (configs?: ConfigOption[]): boolean => {
25
+ if (!configs) return false
26
+
27
+ return ReactConfigs.some(reactConfig => configs.includes(reactConfig))
28
+ }