@kozka/eslint-config 1.0.0-rc.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # @kozka/eslint-config
2
+
3
+ ESLint configuration for JS/TS/React projects.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install --save-dev @kozka/eslint-config
9
+ ```
10
+
11
+ You'll also need to install ESLint if you haven't already:
12
+
13
+ ```bash
14
+ npm install --save-dev eslint
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ### Full config (recommended)
20
+
21
+ ```js
22
+ // eslint.config.mjs
23
+ import kozkaConfig from '@kozka/eslint-config';
24
+
25
+ export default kozkaConfig;
26
+ ```
27
+
28
+ ### CommonJS (legacy)
29
+
30
+ ```js
31
+ // eslint.config.cjs
32
+ const kozkaConfig = require('@kozka/eslint-config');
33
+
34
+ module.exports = kozkaConfig;
35
+ ```
36
+
37
+ ### Selective imports
38
+
39
+ ```js
40
+ // eslint.config.mjs
41
+ import jsConfig from '@kozka/eslint-config/js';
42
+ import tsConfig from '@kozka/eslint-config/ts';
43
+ import reactConfig from '@kozka/eslint-config/react';
44
+ import prettierConfig from '@kozka/eslint-config/prettier';
45
+
46
+ export default [
47
+ ...jsConfig,
48
+ ...tsConfig,
49
+ ...reactConfig,
50
+ ...prettierConfig,
51
+ ];
52
+ ```
53
+
54
+ ### Combine with other configs
55
+
56
+ ```js
57
+ // eslint.config.mjs
58
+ import kozkaConfig from '@kozka/eslint-config';
59
+ import nextConfig from 'eslint-config-next';
60
+
61
+ export default [
62
+ ...kozkaConfig,
63
+ ...nextConfig,
64
+ ];
65
+ ```
66
+
67
+ ## Configs
68
+
69
+ | Export | Description |
70
+ |--------|-------------|
71
+ | `default` | Full config (js + ts + react + prettier) |
72
+ | `./js` | Base JS rules (ESLint recommended + import) |
73
+ | `./ts` | TypeScript rules |
74
+ | `./react` | React + Hooks + Accessibility rules |
75
+ | `./prettier` | Prettier compatibility rules |
76
+
77
+ ## Requirements
78
+
79
+ - Node.js >= 18.0.0
80
+ - ESLint >= 9.0.0
81
+
82
+ ## Extending configuration
83
+
84
+ You can override or extend rules in your own config:
85
+
86
+ ```js
87
+ // eslint.config.mjs
88
+ import kozkaConfig from '@kozka/eslint-config';
89
+
90
+ export default [
91
+ ...kozkaConfig,
92
+ {
93
+ rules: {
94
+ 'no-console': 'warn',
95
+ },
96
+ },
97
+ ];
98
+ ```
package/index.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { createRequire } = require('module');
2
+ const require = createRequire(import.meta.url);
3
+
4
+ const index = require('./index.mjs');
5
+ module.exports = index;
package/index.mjs ADDED
@@ -0,0 +1,9 @@
1
+ import reactConfig from './react.mjs';
2
+ import prettierConfig from './prettier.mjs';
3
+
4
+ const index = {
5
+ name: 'kozka',
6
+ };
7
+
8
+ export { reactConfig, prettierConfig };
9
+ export default [index, ...reactConfig, prettierConfig];
package/js.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { createRequire } = require('module');
2
+ const require = createRequire(import.meta.url);
3
+
4
+ const js = require('./js.mjs');
5
+ module.exports = js;
package/js.mjs ADDED
@@ -0,0 +1,81 @@
1
+ import js from '@eslint/js';
2
+ import importPlugin from 'eslint-plugin-import';
3
+
4
+ const jsConfig = {
5
+ name: 'kozka/js',
6
+ ...js.configs.recommended,
7
+ plugins: {
8
+ import: importPlugin,
9
+ },
10
+ rules: {
11
+ 'import/order': ['error', {
12
+ groups: [
13
+ 'builtin',
14
+ 'external',
15
+ 'internal',
16
+ 'parent',
17
+ 'sibling',
18
+ 'index',
19
+ ],
20
+ 'newlines-between': 'always',
21
+ alphabetize: {
22
+ order: 'asc',
23
+ caseInsensitive: true,
24
+ },
25
+ }],
26
+ 'import/no-unresolved': 'error',
27
+ 'import/named': 'error',
28
+ 'import/default': 'error',
29
+ 'import/export': 'error',
30
+ 'import/namespace': 'error',
31
+ 'import/no-restricted-paths': 'off',
32
+ 'import/no-absolute-path': 'error',
33
+ 'import/no-dynamic-require': 'warn',
34
+ 'import/no-internal-modules': 'off',
35
+ 'import/unambiguous': 'off',
36
+ 'import/no-commonjs': 'off',
37
+ 'import/no-nodejs-modules': 'off',
38
+ 'import/first': 'error',
39
+ 'import/imports-first': 'off',
40
+ 'import/no-duplicates': 'error',
41
+ 'import/no-named-export': 'off',
42
+ 'import/no-anonymous-default-export': 'off',
43
+ 'import/exports-last': 'off',
44
+ 'import/group-exports': 'off',
45
+ 'import/no-default-export': 'off',
46
+ 'import/no-named-as-default': 'error',
47
+ 'import/no-named-as-default-member': 'warn',
48
+ 'import/no-deprecated': 'off',
49
+ 'import/no-extraneous-dependencies': ['error', {
50
+ devDependencies: [
51
+ '**/*.test.{js,ts,jsx,tsx}',
52
+ '**/*.spec.{js,ts,jsx,tsx}',
53
+ '**/test/**',
54
+ '**/tests/**',
55
+ '**/__tests__/**',
56
+ '**/setupTests.ts',
57
+ '**/vite.config.{js,ts}',
58
+ '**/vitest.config.{js,ts}',
59
+ '**/jest.config.{js,ts}',
60
+ ],
61
+ optionalDependencies: false,
62
+ }],
63
+ 'import/no-mutable-exports': 'error',
64
+ 'import/no-unused-modules': 'off',
65
+ 'import/no-useless-path-segments': 'error',
66
+ 'import/dynamic-import-chunkname': 'off',
67
+ 'import/no-relative-parent-imports': 'off',
68
+ 'import/no-unused-modules': 'off',
69
+ 'import/no-import-module-exports': 'error',
70
+ 'import/no-relative-packages': 'warn',
71
+ 'import/extensions': ['error', 'ignorePackages', {
72
+ js: 'never',
73
+ jsx: 'never',
74
+ ts: 'never',
75
+ tsx: 'never',
76
+ }],
77
+ 'import/prefer-default-export': 'off',
78
+ },
79
+ };
80
+
81
+ export default jsConfig;
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@kozka/eslint-config",
3
+ "version": "1.0.0-rc.1",
4
+ "description": "ESLint configuration for JS/TS/React projects",
5
+ "type": "module",
6
+ "files": [
7
+ "*.mjs",
8
+ "*.cjs",
9
+ "README.md",
10
+ "LICENSE",
11
+ "package.json"
12
+ ],
13
+ "main": "./index.cjs",
14
+ "exports": {
15
+ ".": {
16
+ "import": "./index.mjs",
17
+ "require": "./index.cjs"
18
+ },
19
+ "./js": {
20
+ "import": "./js.mjs",
21
+ "require": "./js.cjs"
22
+ },
23
+ "./ts": {
24
+ "import": "./ts.mjs",
25
+ "require": "./ts.cjs"
26
+ },
27
+ "./react": {
28
+ "import": "./react.mjs",
29
+ "require": "./react.cjs"
30
+ },
31
+ "./prettier": {
32
+ "import": "./prettier.mjs",
33
+ "require": "./prettier.cjs"
34
+ }
35
+ },
36
+ "peerDependencies": {
37
+ "eslint": "^9.0.0"
38
+ },
39
+ "dependencies": {
40
+ "@eslint/js": "^9.0.0",
41
+ "eslint-config-prettier": "^9.0.0",
42
+ "eslint-plugin-import": "^2.0.0",
43
+ "eslint-plugin-jsx-a11y": "^6.0.0",
44
+ "eslint-plugin-react": "^7.0.0",
45
+ "eslint-plugin-react-hooks": "^5.0.0",
46
+ "@typescript-eslint/parser": "^8.0.0",
47
+ "@typescript-eslint/eslint-plugin": "^8.0.0"
48
+ },
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ },
52
+ "keywords": [
53
+ "eslint",
54
+ "eslint-config",
55
+ "javascript",
56
+ "typescript",
57
+ "react"
58
+ ],
59
+ "license": "MIT",
60
+ "devDependencies": {},
61
+ "scripts": {
62
+ "test": "echo \"Error: no test specified\" && exit 1"
63
+ },
64
+ "repository": {
65
+ "type": "git",
66
+ "url": "ssh://git@git.home.kozka.cc:2222/beefy/eslint-config.git"
67
+ },
68
+ "author": "Sergey Kozka"
69
+ }
package/prettier.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { createRequire } = require('module');
2
+ const require = createRequire(import.meta.url);
3
+
4
+ const prettier = require('./prettier.mjs');
5
+ module.exports = prettier;
package/prettier.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import prettierConfig from 'eslint-config-prettier';
2
+
3
+ const prettier = {
4
+ name: 'kozka/prettier',
5
+ rules: {
6
+ ...prettierConfig.rules,
7
+ },
8
+ };
9
+
10
+ export default prettier;
package/react.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { createRequire } = require('module');
2
+ const require = createRequire(import.meta.url);
3
+
4
+ const react = require('./react.mjs');
5
+ module.exports = react;
package/react.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import reactPlugin from 'eslint-plugin-react';
2
+ import reactHooksPlugin from 'eslint-plugin-react-hooks';
3
+ import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
4
+ import tsConfig from './ts.mjs';
5
+
6
+ const reactConfig = {
7
+ name: 'kozka/react',
8
+ plugins: {
9
+ react: reactPlugin,
10
+ 'react-hooks': reactHooksPlugin,
11
+ 'jsx-a11y': jsxA11yPlugin,
12
+ },
13
+ rules: {
14
+ ...reactPlugin.configs.recommended.rules,
15
+ ...reactHooksPlugin.configs.recommended.rules,
16
+ ...jsxA11yPlugin.configs.recommended.rules,
17
+ 'react/react-in-jsx-scope': 'off',
18
+ 'react/prop-types': 'off',
19
+ 'react/require-default-props': 'off',
20
+ 'react/jsx-filename-extension': 'off',
21
+ 'react/jsx-uses-react': 'off',
22
+ 'react/display-name': 'off',
23
+ 'react-hooks/rules-of-hooks': 'error',
24
+ 'react-hooks/exhaustive-deps': 'warn',
25
+ 'jsx-a11y/click-events-have-key-events': 'off',
26
+ 'jsx-a11y/no-static-element-interactions': 'off',
27
+ 'jsx-a11y/anchor-is-valid': 'off',
28
+ 'jsx-a11y/no-noninteractive-element-interactions': 'off',
29
+ 'jsx-a11y/no-noninteractive-tabindex': 'off',
30
+ 'jsx-a11y/no-autofocus': 'off',
31
+ },
32
+ settings: {
33
+ react: {
34
+ version: 'detect',
35
+ },
36
+ },
37
+ };
38
+
39
+ export default [...tsConfig, reactConfig];
package/ts.cjs ADDED
@@ -0,0 +1,5 @@
1
+ const { createRequire } = require('module');
2
+ const require = createRequire(import.meta.url);
3
+
4
+ const ts = require('./ts.mjs');
5
+ module.exports = ts;
package/ts.mjs ADDED
@@ -0,0 +1,52 @@
1
+ import tseslint from '@typescript-eslint/eslint-plugin';
2
+ import tsParser from '@typescript-eslint/parser';
3
+ import jsConfig from './js.mjs';
4
+
5
+ const tsConfig = {
6
+ name: 'kozka/ts',
7
+ files: ['**/*.ts', '**/*.tsx'],
8
+ languageOptions: {
9
+ parser: tsParser,
10
+ parserOptions: {
11
+ ecmaVersion: 'latest',
12
+ sourceType: 'module',
13
+ },
14
+ },
15
+ plugins: {
16
+ '@typescript-eslint': tseslint,
17
+ },
18
+ rules: {
19
+ ...tseslint.configs.recommended.rules,
20
+ '@typescript-eslint/no-unused-vars': ['error', {
21
+ argsIgnorePattern: '^_',
22
+ varsIgnorePattern: '^_',
23
+ }],
24
+ '@typescript-eslint/no-explicit-any': 'warn',
25
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
26
+ '@typescript-eslint/no-empty-object-type': 'off',
27
+ '@typescript-eslint/consistent-type-imports': ['error', {
28
+ prefer: 'type-imports',
29
+ }],
30
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
31
+ '@typescript-eslint/consistent-indexed-object-style': 'error',
32
+ '@typescript-eslint/array-type': ['error', {
33
+ default: 'array-simple',
34
+ }],
35
+ '@typescript-eslint/ban-ts-comment': 'off',
36
+ '@typescript-eslint/ban-types': 'off',
37
+ '@typescript-eslint/no-confusing-void-expression': 'off',
38
+ '@typescript-eslint/no-floating-promises': 'error',
39
+ '@typescript-eslint/no-misused-promises': ['error', {
40
+ checksVoidReturn: false,
41
+ }],
42
+ '@typescript-eslint/no-unnecessary-condition': 'off',
43
+ '@typescript-eslint/prefer-optional-chain': 'error',
44
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
45
+ '@typescript-eslint/no-invalid-void-type': 'off',
46
+ '@typescript-eslint/naming-convention': 'off',
47
+ 'no-dupe-class-members': 'off',
48
+ 'no-redeclare': 'off',
49
+ },
50
+ };
51
+
52
+ export default [jsConfig, tsConfig];