@zetavg/eslint-config 0.0.7 → 0.0.8-pre.10

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 CHANGED
@@ -5,10 +5,11 @@ Shared ESLint configuration.
5
5
  ## Install
6
6
 
7
7
  ```bash
8
+ # npm
9
+ npm install --save-dev @zetavg/eslint-config eslint prettier
10
+ # pnpm
8
11
  pnpm add --save-dev @zetavg/eslint-config eslint prettier
9
- ```
10
-
11
- ```bash
12
+ # yarn
12
13
  yarn add --dev @zetavg/eslint-config eslint prettier
13
14
  ```
14
15
 
@@ -3,15 +3,20 @@ import { defineConfig } from 'eslint/config';
3
3
 
4
4
  import * as configs from '../configs/index.js';
5
5
 
6
+ /**
7
+ * Base ESLint configuration that should apply to all JavaScript and TypeScript
8
+ * files.
9
+ */
6
10
  export default defineConfig([
7
11
  {
8
12
  extends: [
9
13
  js.configs.recommended,
10
14
  configs.prettier,
11
- configs.general,
15
+ configs.style,
12
16
  configs.noUnusedVars,
13
17
  configs.imports,
14
18
  configs.importsSort,
19
+ configs.consoleAndDebugger,
15
20
  configs.todoComments,
16
21
  ],
17
22
  },
@@ -1 +1 @@
1
- export { default as default } from './default.js';
1
+ export { default as base } from './base.js';
@@ -1,6 +1,9 @@
1
1
  import { defineConfig } from 'eslint/config';
2
2
  import globals from 'globals';
3
3
 
4
+ /**
5
+ * CommonJS-specific ESLint configuration. Should only apply to CommonJS files.
6
+ */
4
7
  export default defineConfig([
5
8
  {
6
9
  languageOptions: {
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ /**
4
+ * Warns on `console.log` and `debugger` statements to prevent them from
5
+ * slipping into production code.
6
+ *
7
+ * Use `console.info`, `console.warn`, or `console.error` for intentional logging;
8
+ * reserve `console.log` for temporary debugging only.
9
+ */
10
+ export default defineConfig([
11
+ {
12
+ rules: {
13
+ 'no-console': ['warn', { allow: ['info', 'warn', 'error'] }],
14
+ 'no-debugger': 'warn',
15
+ },
16
+ },
17
+ ]);
@@ -3,11 +3,6 @@ import globals from 'globals';
3
3
 
4
4
  export default defineConfig([
5
5
  {
6
- rules: {
7
- curly: ['warn', 'multi-line', 'consistent'],
8
- 'no-console': ['warn', { allow: ['info', 'warn', 'error'] }],
9
- 'no-debugger': 'warn',
10
- },
11
6
  languageOptions: {
12
7
  globals: {
13
8
  ...globals['shared-node-browser'],
@@ -1,6 +1,11 @@
1
1
  import { defineConfig } from 'eslint/config';
2
2
  import simpleImportSort from 'eslint-plugin-simple-import-sort';
3
3
 
4
+ /**
5
+ * Enforces a consistent import ordering convention using automatic sorting,
6
+ * eliminating the need to debate or manually maintain import order.
7
+ * Violations are reported as warnings and can be auto-fixed.
8
+ */
4
9
  export default defineConfig([
5
10
  {
6
11
  plugins: {
@@ -22,9 +27,7 @@ export default defineConfig([
22
27
  // Packages. `react` related packages come first.
23
28
  ['^react$', '^react/', '^react-dom', '^react', '^@?\\w'],
24
29
  // Internal packages.
25
- [
26
- '^(@|@zetavg|components|utils|config|vendored-lib)(/.*|$)',
27
- ],
30
+ ['^(@|@zetavg|components|utils|config|vendored-lib)(/.*|$)'],
28
31
  // Side effect imports.
29
32
  ['^\\u0000'],
30
33
  // Parent imports. Put `..` last.
@@ -23,5 +23,13 @@ export default defineConfig([
23
23
  'import/enforce-node-protocol-usage': 'warn',
24
24
  'import/no-unresolved': 'off', // This sometimes cannot resolve paths correctly, providing false alerts.
25
25
  },
26
+ settings: {
27
+ 'import/ignore': [
28
+ // `eslint-plugin-import` inspects imported packages to validate exports.
29
+ // React Native's entry file uses Flow-only syntax, so we skip import
30
+ // analysis for that package.
31
+ 'node_modules/react-native/',
32
+ ],
33
+ },
26
34
  },
27
35
  ]);
package/configs/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as commonjs } from './commonjs.js';
2
- export { default as general } from './general.js';
2
+ export { default as consoleAndDebugger } from './console-and-debugger.js';
3
+ export { default as defaultGlobals } from './default-globals.js';
3
4
  export { default as imports } from './imports.js';
4
5
  export { default as importsSort } from './imports-sort.js';
5
6
  export { default as json } from './json.js';
@@ -7,4 +8,7 @@ export { default as markdown } from './markdown.js';
7
8
  export { default as noUnusedVars } from './no-unused.js';
8
9
  export { default as prettier } from './prettier.js';
9
10
  export { default as react } from './react.js';
11
+ export { default as style } from './style.js';
10
12
  export { default as todoComments } from './todo-comments.js';
13
+ export { default as typescript } from './typescript.js';
14
+ export { default as vitest } from './vitest.js';
package/configs/json.js CHANGED
@@ -8,11 +8,15 @@ export default defineConfig([
8
8
  },
9
9
  },
10
10
  {
11
- files: ['**/*.json'],
12
- ignores: [
13
- '**/tsconfig.json', // tsconfig files may contain comments, which ESLint can't parse
14
- ],
15
- language: 'json/json',
11
+ files: ['**/*.json', '**/*.jsonc'],
12
+ language: 'json/jsonc',
13
+ rules: {
14
+ 'json/no-duplicate-keys': 'error',
15
+ },
16
+ },
17
+ {
18
+ files: ['**/*.json5'],
19
+ language: 'json/json5',
16
20
  rules: {
17
21
  'json/no-duplicate-keys': 'error',
18
22
  },
package/configs/react.js CHANGED
@@ -1,16 +1,26 @@
1
1
  import { defineConfig } from 'eslint/config';
2
2
  import react from 'eslint-plugin-react';
3
3
  import reactHooks from 'eslint-plugin-react-hooks';
4
- import reactRefresh from 'eslint-plugin-react-refresh';
4
+ import reactRefreshPlugin from 'eslint-plugin-react-refresh';
5
5
  import globals from 'globals';
6
6
 
7
7
  export default defineConfig([
8
8
  react.configs.flat.recommended,
9
- reactHooks.configs['recommended-latest'],
10
- reactRefresh.configs.recommended,
9
+ reactHooks.configs.flat['recommended-latest'] ||
10
+ reactHooks.configs['recommended-latest'],
11
+ reactRefreshPlugin.configs.recommended,
11
12
  {
12
13
  languageOptions: {
13
14
  globals: globals.browser,
14
15
  },
16
+ settings: {
17
+ react: {
18
+ // eslint-plugin-react uses the legacy `context.getFilename()` API for version auto-detection, which was removed in ESLint v10.
19
+ // To work around this, we can only specify the React version explicitly. We should update this when eslint-plugin-react releases a new version that supports the new API.
20
+ // See: https://github.com/vercel/next.js/issues/89764#issuecomment-3928272828
21
+ // version: 'detect',
22
+ version: '19',
23
+ },
24
+ },
15
25
  },
16
26
  ]);
@@ -0,0 +1,12 @@
1
+ import { defineConfig } from 'eslint/config';
2
+
3
+ /**
4
+ * Enforces consistent code style and formatting rules to improve readability.
5
+ */
6
+ export default defineConfig([
7
+ {
8
+ rules: {
9
+ curly: ['warn', 'multi-line', 'consistent'],
10
+ },
11
+ },
12
+ ]);
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import tseslint from 'typescript-eslint';
3
+
4
+ /**
5
+ * Default ESLint configuration for TypeScript.
6
+ */
7
+ export default defineConfig([
8
+ tseslint.configs.recommended,
9
+ {
10
+ rules: {
11
+ // Turned off in favor of the `no-unused/no-unused-vars` rule in `no-unused.js`.
12
+ '@typescript-eslint/no-unused-vars': 'off',
13
+ },
14
+ },
15
+ ]);
@@ -0,0 +1,4 @@
1
+ import vitest from '@vitest/eslint-plugin';
2
+ import { defineConfig } from 'eslint/config';
3
+
4
+ export default defineConfig([vitest.configs.recommended]);
@@ -1 +1 @@
1
- export { default } from "./default.js";
1
+ export { default as base } from "./base.js";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@eslint/config-helpers").Config[];
2
+ export default _default;
@@ -1,5 +1,6 @@
1
1
  export { default as commonjs } from "./commonjs.js";
2
- export { default as general } from "./general.js";
2
+ export { default as consoleAndDebugger } from "./console-and-debugger.js";
3
+ export { default as defaultGlobals } from "./default-globals.js";
3
4
  export { default as imports } from "./imports.js";
4
5
  export { default as importsSort } from "./imports-sort.js";
5
6
  export { default as json } from "./json.js";
@@ -7,4 +8,7 @@ export { default as markdown } from "./markdown.js";
7
8
  export { default as noUnusedVars } from "./no-unused.js";
8
9
  export { default as prettier } from "./prettier.js";
9
10
  export { default as react } from "./react.js";
11
+ export { default as style } from "./style.js";
10
12
  export { default as todoComments } from "./todo-comments.js";
13
+ export { default as typescript } from "./typescript.js";
14
+ export { default as vitest } from "./vitest.js";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@eslint/config-helpers").Config[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@eslint/config-helpers").Config[];
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@eslint/config-helpers").Config[];
2
+ export default _default;
@@ -0,0 +1,3 @@
1
+ export default globals;
2
+ export * from "globals";
3
+ import globals from 'globals';
@@ -0,0 +1,3 @@
1
+ export default tsEslint;
2
+ export * from "typescript-eslint";
3
+ import tsEslint from 'typescript-eslint';
@@ -0,0 +1,2 @@
1
+ export default vitest;
2
+ import vitest from '@vitest/eslint-plugin';
@@ -0,0 +1,4 @@
1
+ import globals from 'globals';
2
+ export default globals;
3
+
4
+ export * from 'globals';
@@ -0,0 +1,4 @@
1
+ import tsEslint from 'typescript-eslint';
2
+ export default tsEslint;
3
+
4
+ export * from 'typescript-eslint';
@@ -0,0 +1,2 @@
1
+ import vitest from '@vitest/eslint-plugin';
2
+ export default vitest;
package/package.json CHANGED
@@ -2,7 +2,25 @@
2
2
  "name": "@zetavg/eslint-config",
3
3
  "type": "module",
4
4
  "main": "index.js",
5
- "types": "dist/index.d.ts",
5
+ "types": "dist/types/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "default": "./index.js",
9
+ "types": "./dist/types/index.d.ts"
10
+ },
11
+ "./globals": {
12
+ "default": "./exports/globals.js",
13
+ "types": "./dist/types/exports/globals.d.ts"
14
+ },
15
+ "./typescript-eslint": {
16
+ "default": "./exports/typescript-eslint.js",
17
+ "types": "./dist/types/exports/typescript-eslint.d.ts"
18
+ },
19
+ "./vitest": {
20
+ "default": "./exports/vitest.js",
21
+ "types": "./dist/types/exports/vitest.d.ts"
22
+ }
23
+ },
6
24
  "repository": {
7
25
  "type": "git",
8
26
  "url": "https://github.com/zetavg/es-configs",
@@ -21,7 +39,7 @@
21
39
  "peerDependencies": {
22
40
  "eslint": "^9 || ^10",
23
41
  "prettier": "^3",
24
- "typescript": ">=5.8"
42
+ "typescript": ">=5"
25
43
  },
26
44
  "peerDependenciesMeta": {
27
45
  "typescript": {
@@ -46,11 +64,11 @@
46
64
  "typescript-eslint": "^8"
47
65
  },
48
66
  "devDependencies": {
49
- "@zetavg/prettier-config": "^0.0.7",
50
- "@zetavg/tsconfig": "^0.0.7",
67
+ "@zetavg/prettier-config": "^0.0.8-pre.10",
68
+ "@zetavg/tsconfig": "^0.0.8-pre.10",
51
69
  "eslint": "^9",
52
70
  "prettier": "^3",
53
71
  "typescript": "~5.8"
54
72
  },
55
- "version": "0.0.7"
73
+ "version": "0.0.8-pre.10"
56
74
  }
@@ -1,26 +1,29 @@
1
- import vitest from '@vitest/eslint-plugin';
2
1
  import { defineConfig } from 'eslint/config';
3
- import tseslint from 'typescript-eslint';
4
2
 
5
3
  import * as configSets from '../config-sets/index.js';
6
4
  import * as configs from '../configs/index.js';
7
5
 
8
6
  export default defineConfig([
9
7
  { ignores: ['dist', 'node_modules'] },
10
- tseslint.configs.recommended,
11
- vitest.configs.recommended,
8
+ configs.vitest,
12
9
  configs.json,
13
10
  configs.markdown,
11
+ configs.defaultGlobals,
14
12
  {
15
13
  name: 'Configs Applied to All JS/TS Files',
16
14
  files: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
17
- extends: [configSets.default],
15
+ extends: [configSets.base],
18
16
  },
19
17
  {
20
18
  name: 'Configs for React Files',
21
19
  files: ['**/*.[j,t]sx'],
22
20
  extends: [configs.react],
23
21
  },
22
+ {
23
+ name: 'Configs for TypeScript Files',
24
+ files: ['**/*.{ts,cts,mts,tsx}'],
25
+ extends: [configs.typescript],
26
+ },
24
27
  {
25
28
  name: 'Configs for CommonJS Files',
26
29
  files: ['**/*.cjs'],