@zetavg/eslint-config 0.0.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/README.md +18 -0
- package/config-sets/default.js +18 -0
- package/config-sets/index.js +1 -0
- package/configs/commonjs.js +16 -0
- package/configs/general.js +18 -0
- package/configs/imports-sort.js +42 -0
- package/configs/imports.js +27 -0
- package/configs/index.js +9 -0
- package/configs/json.js +20 -0
- package/configs/no-unused.js +26 -0
- package/configs/prettier.js +16 -0
- package/configs/react.js +16 -0
- package/configs/todo-comments.js +25 -0
- package/eslint.config.mjs +5 -0
- package/index.js +15 -0
- package/package.json +51 -0
- package/presets/default.js +30 -0
- package/presets/index.js +1 -0
- package/prettier.config.mjs +10 -0
- package/tsconfig.json +10 -0
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# ESLint Config
|
|
2
|
+
|
|
3
|
+
Shared ESLint configurations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @zetavg/eslint-config --dev
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Then, add the following to your `eslint.config.js` (or `eslint.config.mjs`):
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { defineConfig } from 'eslint/config';
|
|
15
|
+
import config from '@zetavg/eslint-config';
|
|
16
|
+
|
|
17
|
+
export default defineConfig([config]);
|
|
18
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
|
|
4
|
+
import * as configs from '../configs/index.js';
|
|
5
|
+
|
|
6
|
+
export default defineConfig([
|
|
7
|
+
{
|
|
8
|
+
extends: [
|
|
9
|
+
js.configs.recommended,
|
|
10
|
+
configs.prettier,
|
|
11
|
+
configs.general,
|
|
12
|
+
configs.noUnusedVars,
|
|
13
|
+
configs.imports,
|
|
14
|
+
configs.importsSort,
|
|
15
|
+
configs.todoComments,
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as default } from './default.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
languageOptions: {
|
|
7
|
+
sourceType: 'commonjs',
|
|
8
|
+
globals: {
|
|
9
|
+
...globals['commonjs'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
'@typescript-eslint/no-require-imports': 'off',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
rules: {
|
|
7
|
+
curly: ['warn', 'multi-line', 'consistent'],
|
|
8
|
+
'no-console': ['warn', { allow: ['info', 'warn', 'error'] }],
|
|
9
|
+
'no-debugger': 'warn',
|
|
10
|
+
},
|
|
11
|
+
languageOptions: {
|
|
12
|
+
globals: {
|
|
13
|
+
...globals['shared-node-browser'],
|
|
14
|
+
process: 'readonly',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import simpleImportSort from 'eslint-plugin-simple-import-sort';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
plugins: {
|
|
7
|
+
'simple-import-sort': simpleImportSort,
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
'simple-import-sort/imports': [
|
|
11
|
+
'warn',
|
|
12
|
+
{
|
|
13
|
+
groups: [
|
|
14
|
+
// Node.js builtins. You could also generate this regex if you use a `.js` config.
|
|
15
|
+
// For example: `^(${require("module").builtinModules.join("|")})(/|$)`
|
|
16
|
+
// Note that if you use the `node:` prefix for Node.js builtins,
|
|
17
|
+
// you can avoid this complexity: You can simply use "^node:".
|
|
18
|
+
[
|
|
19
|
+
'^node:',
|
|
20
|
+
'^(assert|buffer|child_process|cluster|console|constants|crypto|dgram|dns|domain|events|fs|http|https|module|net|os|path|punycode|querystring|readline|repl|stream|string_decoder|sys|timers|tls|tty|url|util|vm|zlib|freelist|v8|process|async_hooks|http2|perf_hooks)(/.*|$)',
|
|
21
|
+
],
|
|
22
|
+
// Packages. `react` related packages come first.
|
|
23
|
+
['^react$', '^react/', '^react-dom', '^react', '^@?\\w'],
|
|
24
|
+
// Internal packages.
|
|
25
|
+
[
|
|
26
|
+
'^(@|@zetavg|components|utils|config|vendored-lib)(/.*|$)',
|
|
27
|
+
],
|
|
28
|
+
// Side effect imports.
|
|
29
|
+
['^\\u0000'],
|
|
30
|
+
// Parent imports. Put `..` last.
|
|
31
|
+
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
|
|
32
|
+
// Other relative imports. Put same-folder imports and `.` last.
|
|
33
|
+
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
|
|
34
|
+
// Style imports.
|
|
35
|
+
['^.+\\.s?css$'],
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
'simple-import-sort/exports': 'warn',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
]);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import importPlugin from 'eslint-plugin-import';
|
|
3
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
4
|
+
|
|
5
|
+
export default defineConfig([
|
|
6
|
+
{
|
|
7
|
+
plugins: {
|
|
8
|
+
import: {
|
|
9
|
+
...importPlugin.flatConfigs.recommended.plugins.import,
|
|
10
|
+
rules: {
|
|
11
|
+
...importPlugin.flatConfigs.recommended.plugins.import.rules,
|
|
12
|
+
/** Borrowing this rule from [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/6d15a02d48de7ecfc38d0683a8487b2f937d83a0/rules/prefer-node-protocol.js) since the [new import/enforce-node-protocol-usage rule](https://github.com/import-js/eslint-plugin-import/pull/3024) isn't published yet. */
|
|
13
|
+
'enforce-node-protocol-usage':
|
|
14
|
+
eslintPluginUnicorn.configs.all.plugins.unicorn.rules[
|
|
15
|
+
'prefer-node-protocol'
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
rules: {
|
|
21
|
+
'unicorn/prefer-node-protocol': 'off', // With this config, we are using the `import/enforce-node-protocol-usage` rule instead.
|
|
22
|
+
...importPlugin.flatConfigs.recommended.rules,
|
|
23
|
+
'import/enforce-node-protocol-usage': 'warn',
|
|
24
|
+
'import/no-unresolved': 'off', // This sometimes cannot resolve paths correctly, providing false alerts.
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
]);
|
package/configs/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as commonjs } from './commonjs.js';
|
|
2
|
+
export { default as general } from './general.js';
|
|
3
|
+
export { default as imports } from './imports.js';
|
|
4
|
+
export { default as importsSort } from './imports-sort.js';
|
|
5
|
+
export { default as json } from './json.js';
|
|
6
|
+
export { default as noUnusedVars } from './no-unused.js';
|
|
7
|
+
export { default as prettier } from './prettier.js';
|
|
8
|
+
export { default as react } from './react.js';
|
|
9
|
+
export { default as todoComments } from './todo-comments.js';
|
package/configs/json.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import json from '@eslint/json';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
plugins: {
|
|
7
|
+
json,
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
files: ['**/*.json'],
|
|
12
|
+
ignores: [
|
|
13
|
+
'**/tsconfig.json', // tsconfig files may contain comments, which ESLint can't parse
|
|
14
|
+
],
|
|
15
|
+
language: 'json/json',
|
|
16
|
+
rules: {
|
|
17
|
+
'json/no-duplicate-keys': 'error',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
plugins: {
|
|
7
|
+
'no-unused': {
|
|
8
|
+
rules: {
|
|
9
|
+
'no-unused-vars': tseslint.plugin.rules['no-unused-vars'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
'no-unused-vars': 'off',
|
|
15
|
+
'@typescript-eslint/no-unused-vars': 'off',
|
|
16
|
+
'no-unused/no-unused-vars': [
|
|
17
|
+
'warn',
|
|
18
|
+
{
|
|
19
|
+
argsIgnorePattern: '^_',
|
|
20
|
+
varsIgnorePattern: '^_',
|
|
21
|
+
caughtErrorsIgnorePattern: '^_',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
extends: [eslintPluginPrettierRecommended],
|
|
7
|
+
rules: {
|
|
8
|
+
'prettier/prettier': [
|
|
9
|
+
'warn',
|
|
10
|
+
{
|
|
11
|
+
singleQuote: true,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
]);
|
package/configs/react.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import react from 'eslint-plugin-react';
|
|
3
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
4
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
5
|
+
import globals from 'globals';
|
|
6
|
+
|
|
7
|
+
export default defineConfig([
|
|
8
|
+
react.configs.flat.recommended,
|
|
9
|
+
reactHooks.configs['recommended-latest'],
|
|
10
|
+
reactRefresh.configs.recommended,
|
|
11
|
+
{
|
|
12
|
+
languageOptions: {
|
|
13
|
+
globals: globals.browser,
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
|
|
3
|
+
|
|
4
|
+
export default defineConfig([
|
|
5
|
+
{
|
|
6
|
+
plugins: {
|
|
7
|
+
'todo-comments': {
|
|
8
|
+
rules: {
|
|
9
|
+
'expiring-todo-comments':
|
|
10
|
+
eslintPluginUnicorn.configs.all.plugins.unicorn.rules[
|
|
11
|
+
'expiring-todo-comments'
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
'no-warning-comments': 'off',
|
|
18
|
+
'unicorn/expiring-todo-comments': 'off',
|
|
19
|
+
'todo-comments/expiring-todo-comments': [
|
|
20
|
+
'warn',
|
|
21
|
+
{ allowWarningComments: false },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
]);
|
package/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
|
|
3
|
+
import * as configSets from './config-sets/index.js';
|
|
4
|
+
import * as configs from './configs/index.js';
|
|
5
|
+
import * as presets from './presets/index.js';
|
|
6
|
+
|
|
7
|
+
const defaultExport = [...presets.default];
|
|
8
|
+
defaultExport.globals = globals;
|
|
9
|
+
defaultExport.configs = configs;
|
|
10
|
+
defaultExport.configSets = configSets;
|
|
11
|
+
defaultExport.presets = presets;
|
|
12
|
+
|
|
13
|
+
export default defaultExport;
|
|
14
|
+
|
|
15
|
+
export { configs, configSets, globals, presets };
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zetavg/eslint-config",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"lint": "eslint .",
|
|
8
|
+
"build:types": "tsc",
|
|
9
|
+
"build": "yarn build:types",
|
|
10
|
+
"watch:types": "yarn build:types --watch --preserveWatchOutput",
|
|
11
|
+
"watch": "yarn watch:types",
|
|
12
|
+
"pack-package": "yarn pack",
|
|
13
|
+
"publish-packed-package": "npm publish package.tgz --access public",
|
|
14
|
+
"clean": "rm -rf package.tgz"
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"eslint": "^9",
|
|
18
|
+
"prettier": "^3",
|
|
19
|
+
"typescript": "~5.8"
|
|
20
|
+
},
|
|
21
|
+
"peerDependenciesMeta": {
|
|
22
|
+
"typescript": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@eslint/js": "^9",
|
|
28
|
+
"@eslint/json": "^0.12",
|
|
29
|
+
"@eslint/markdown": "^6",
|
|
30
|
+
"@types/eslint": "^9",
|
|
31
|
+
"@vitest/eslint-plugin": "^1",
|
|
32
|
+
"eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0",
|
|
33
|
+
"eslint-plugin-import": "^2",
|
|
34
|
+
"eslint-plugin-prettier": "^5",
|
|
35
|
+
"eslint-plugin-react": "^7",
|
|
36
|
+
"eslint-plugin-react-hooks": "^5",
|
|
37
|
+
"eslint-plugin-react-refresh": "^0.4.20",
|
|
38
|
+
"eslint-plugin-simple-import-sort": "^12",
|
|
39
|
+
"eslint-plugin-unicorn": "^59",
|
|
40
|
+
"globals": "^16",
|
|
41
|
+
"typescript-eslint": "^8"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@zetavg/prettier-config": "workspace:^",
|
|
45
|
+
"@zetavg/tsconfig": "workspace:^",
|
|
46
|
+
"eslint": "^9",
|
|
47
|
+
"prettier": "^3",
|
|
48
|
+
"typescript": "~5.8"
|
|
49
|
+
},
|
|
50
|
+
"version": "0.0.1"
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import markdown from '@eslint/markdown';
|
|
2
|
+
import vitest from '@vitest/eslint-plugin';
|
|
3
|
+
import { defineConfig } from 'eslint/config';
|
|
4
|
+
import tseslint from 'typescript-eslint';
|
|
5
|
+
|
|
6
|
+
import * as configSets from '../config-sets/index.js';
|
|
7
|
+
import * as configs from '../configs/index.js';
|
|
8
|
+
|
|
9
|
+
export default defineConfig([
|
|
10
|
+
{ ignores: ['dist', 'node_modules'] },
|
|
11
|
+
tseslint.configs.recommended,
|
|
12
|
+
vitest.configs.recommended,
|
|
13
|
+
configs.json,
|
|
14
|
+
markdown.configs.recommended,
|
|
15
|
+
{
|
|
16
|
+
name: 'Configs Applied to All JS/TS Files',
|
|
17
|
+
files: ['**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
|
|
18
|
+
extends: [configSets.default],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Configs for React Files',
|
|
22
|
+
files: ['**/*.[j,t]sx'],
|
|
23
|
+
extends: [configs.react],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Configs for CommonJS Files',
|
|
27
|
+
files: ['**/*.cjs'],
|
|
28
|
+
extends: [configs.commonjs],
|
|
29
|
+
},
|
|
30
|
+
]);
|
package/presets/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as default } from './default.js';
|