@smartive/eslint-config 6.5.0 → 7.0.0-next.2
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 +2 -14
- package/dist/configs.d.ts +3 -0
- package/dist/configs.js +73 -0
- package/dist/index.d.ts +1 -9
- package/dist/index.js +13 -0
- package/dist/rules.d.ts +5 -0
- package/dist/rules.js +46 -0
- package/package.json +30 -34
- package/dist/cjs/index.js +0 -183
- package/dist/cjs/react-legacy.js +0 -3
- package/dist/cjs/typescript-legacy.js +0 -3
- package/dist/esm/index.js +0 -153
- package/dist/esm/react-legacy.js +0 -11
- package/dist/esm/typescript-legacy.js +0 -11
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ $ npm install eslint @smartive/eslint-config -D
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
This package offers
|
|
13
|
+
This package offers three different rule sets, one for plain TypeScript applications, a separate one for React applications and one that works well with Next.js applications (minimum supported version is Next.js v16).
|
|
14
14
|
|
|
15
15
|
### Flat Config (`eslint.config.mjs`)
|
|
16
16
|
|
|
@@ -24,23 +24,11 @@ export default config('typescript');
|
|
|
24
24
|
export default config('react');
|
|
25
25
|
|
|
26
26
|
// .. or Next.js applications
|
|
27
|
-
// make sure to add `eslint-config-next`
|
|
27
|
+
// make sure to add `eslint-config-next@16`
|
|
28
28
|
// to your devDependencies
|
|
29
29
|
export default config('nextjs');
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
### Legacy Config (`.eslintrc`)
|
|
33
|
-
|
|
34
|
-
```json
|
|
35
|
-
{
|
|
36
|
-
"extends": [
|
|
37
|
-
"@smartive/eslint-config/typescript-legacy" // Plain TS applications
|
|
38
|
-
// or
|
|
39
|
-
"@smartive/eslint-config/react-legacy" // React applications
|
|
40
|
-
]
|
|
41
|
-
}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
32
|
### NPM scripts
|
|
45
33
|
|
|
46
34
|
To use eslint add the following to your package.json:
|
package/dist/configs.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import { flatConfigs as eslintPluginImportConfigs } from 'eslint-plugin-import';
|
|
3
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
4
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
5
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
6
|
+
import { defineConfig } from 'eslint/config';
|
|
7
|
+
import globals from 'globals';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import tsEslint from 'typescript-eslint';
|
|
10
|
+
import { defaultRules, prettierRules, reactRules, typescriptRules } from './rules.js';
|
|
11
|
+
const tsEslintConfigs = [...tsEslint.configs.recommendedTypeChecked, ...tsEslint.configs.stylisticTypeChecked];
|
|
12
|
+
const baseConfig = {
|
|
13
|
+
name: '@smartive/eslint-config/base',
|
|
14
|
+
rules: { ...defaultRules, ...typescriptRules, ...prettierRules },
|
|
15
|
+
languageOptions: {
|
|
16
|
+
ecmaVersion: 2020,
|
|
17
|
+
sourceType: 'module',
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.browser,
|
|
20
|
+
...globals.node,
|
|
21
|
+
...globals.es2020,
|
|
22
|
+
Atomics: 'readonly',
|
|
23
|
+
SharedArrayBuffer: 'readonly',
|
|
24
|
+
},
|
|
25
|
+
parserOptions: {
|
|
26
|
+
ecmaVersion: 2020,
|
|
27
|
+
sourceType: 'module',
|
|
28
|
+
projectService: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const reactConfig = { name: '@smartive/eslint-config/react', rules: reactRules };
|
|
33
|
+
export const flatConfigTypescript = (rulesOnly = false) => defineConfig([
|
|
34
|
+
js.configs.recommended,
|
|
35
|
+
eslintPluginPrettierRecommended,
|
|
36
|
+
rulesOnly
|
|
37
|
+
? {
|
|
38
|
+
rules: tsEslintConfigs.reduce((combinedRules, { rules }) => ({ ...combinedRules, ...(rules ? rules : {}) }), {}),
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
...eslintPluginImportConfigs.errors,
|
|
42
|
+
...eslintPluginImportConfigs.warnings,
|
|
43
|
+
...eslintPluginImportConfigs.typescript,
|
|
44
|
+
...{
|
|
45
|
+
settings: {
|
|
46
|
+
'import/resolver': {
|
|
47
|
+
node: true,
|
|
48
|
+
typescript: {
|
|
49
|
+
alwaysTryTypes: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
...tsEslintConfigs,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
files: ['**/*.js', '**/*.mjs'],
|
|
58
|
+
extends: [tsEslint.configs.disableTypeChecked],
|
|
59
|
+
},
|
|
60
|
+
baseConfig,
|
|
61
|
+
]);
|
|
62
|
+
export const flatConfigReact = defineConfig([
|
|
63
|
+
...flatConfigTypescript(),
|
|
64
|
+
reactPlugin.configs.flat.recommended,
|
|
65
|
+
reactPlugin.configs.flat['jsx-runtime'],
|
|
66
|
+
reactHooks.configs.flat.recommended,
|
|
67
|
+
reactConfig,
|
|
68
|
+
]);
|
|
69
|
+
export const flatConfigNext = defineConfig([
|
|
70
|
+
...createRequire(import.meta.url)('eslint-config-next/core-web-vitals'),
|
|
71
|
+
...flatConfigTypescript(true),
|
|
72
|
+
reactConfig,
|
|
73
|
+
]);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
|
-
|
|
3
|
-
* @deprecated Use `config(type)` instead
|
|
4
|
-
*/
|
|
5
|
-
export declare const configs: {
|
|
6
|
-
typescript: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
|
|
7
|
-
react: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
|
|
8
|
-
};
|
|
9
|
-
export declare const config: (type: string) => import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
|
|
10
|
-
export declare const generateLegacyConfig: (react: boolean) => Linter.LegacyConfig;
|
|
2
|
+
export declare const config: (type: "typescript" | "react" | "nextjs") => Linter.Config[];
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { flatConfigNext, flatConfigReact, flatConfigTypescript } from './configs.js';
|
|
2
|
+
export const config = (type) => {
|
|
3
|
+
switch (type) {
|
|
4
|
+
case 'typescript':
|
|
5
|
+
return flatConfigTypescript();
|
|
6
|
+
case 'react':
|
|
7
|
+
return flatConfigReact;
|
|
8
|
+
case 'nextjs':
|
|
9
|
+
return flatConfigNext;
|
|
10
|
+
default:
|
|
11
|
+
throw new Error(`Unknown config type: ${type}`);
|
|
12
|
+
}
|
|
13
|
+
};
|
package/dist/rules.d.ts
ADDED
package/dist/rules.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const defaultRules = {
|
|
2
|
+
'no-constant-binary-expression': 'error',
|
|
3
|
+
'array-callback-return': 'error',
|
|
4
|
+
'no-debugger': 'error',
|
|
5
|
+
'no-alert': 'error',
|
|
6
|
+
'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error', 'trace', 'time', 'timeEnd'] }],
|
|
7
|
+
'newline-before-return': 'error',
|
|
8
|
+
'prefer-const': 'error',
|
|
9
|
+
'no-else-return': 'error',
|
|
10
|
+
'no-extra-semi': 'error',
|
|
11
|
+
curly: 'error',
|
|
12
|
+
eqeqeq: 'error',
|
|
13
|
+
'default-case-last': 'error',
|
|
14
|
+
};
|
|
15
|
+
export const typescriptRules = {
|
|
16
|
+
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
|
|
17
|
+
'@typescript-eslint/consistent-type-definitions': 'off',
|
|
18
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
19
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
20
|
+
'@typescript-eslint/prefer-regexp-exec': 'off',
|
|
21
|
+
'@typescript-eslint/no-var-requires': 'warn',
|
|
22
|
+
'@typescript-eslint/no-unused-vars': ['error'],
|
|
23
|
+
'@typescript-eslint/no-floating-promises': ['error'],
|
|
24
|
+
'@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
|
|
25
|
+
};
|
|
26
|
+
export const reactRules = {
|
|
27
|
+
'react/prop-types': 'off',
|
|
28
|
+
'react/display-name': 'off',
|
|
29
|
+
'react/forbid-component-props': ['warn', { forbid: ['style', 'className'] }],
|
|
30
|
+
'@typescript-eslint/no-misused-promises': [
|
|
31
|
+
'error',
|
|
32
|
+
{
|
|
33
|
+
checksVoidReturn: {
|
|
34
|
+
attributes: false,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
39
|
+
export const prettierRules = {
|
|
40
|
+
'prettier/prettier': [
|
|
41
|
+
'error',
|
|
42
|
+
{
|
|
43
|
+
endOfLine: 'auto',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
package/package.json
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smartive/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-next.2",
|
|
4
4
|
"description": "ESLint configuration by smartive",
|
|
5
5
|
"files": [
|
|
6
6
|
"README.md",
|
|
7
7
|
"LICENSE",
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"import": "./dist/esm/index.js",
|
|
14
|
-
"require": "./dist/cjs/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./react-legacy": {
|
|
17
|
-
"import": "./dist/esm/react-legacy.js",
|
|
18
|
-
"require": "./dist/cjs/react-legacy.js"
|
|
19
|
-
},
|
|
20
|
-
"./typescript-legacy": {
|
|
21
|
-
"import": "./dist/esm/typescript-legacy.js",
|
|
22
|
-
"require": "./dist/cjs/typescript-legacy.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
25
13
|
"repository": {
|
|
26
14
|
"type": "git",
|
|
27
15
|
"url": "git+https://github.com/smartive/eslint-config.git"
|
|
@@ -39,40 +27,48 @@
|
|
|
39
27
|
},
|
|
40
28
|
"homepage": "https://github.com/smartive/eslint-config#readme",
|
|
41
29
|
"dependencies": {
|
|
42
|
-
"@eslint/eslintrc": "^3.2.0",
|
|
43
30
|
"@typescript-eslint/eslint-plugin": "^8.15.0",
|
|
44
31
|
"@typescript-eslint/parser": "^8.15.0",
|
|
45
|
-
"eslint-config-prettier": "^10.
|
|
32
|
+
"eslint-config-prettier": "^10.1.8",
|
|
33
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
46
34
|
"eslint-plugin-import": "^2.31.0",
|
|
47
|
-
"eslint-plugin-prettier": "^5.
|
|
48
|
-
"eslint-plugin-react": "^7.37.
|
|
49
|
-
"eslint-plugin-react-hooks": "^
|
|
35
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
36
|
+
"eslint-plugin-react": "^7.37.5",
|
|
37
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
50
38
|
"globals": "^16.0.0",
|
|
51
39
|
"typescript-eslint": "^8.15.0"
|
|
52
40
|
},
|
|
53
41
|
"peerDependencies": {
|
|
54
|
-
"eslint": "^
|
|
55
|
-
"
|
|
42
|
+
"eslint": "^9.22.0",
|
|
43
|
+
"next": "^16.0.0",
|
|
44
|
+
"eslint-config-next": "^16.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"next": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"eslint-config-next": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
56
53
|
},
|
|
57
54
|
"devDependencies": {
|
|
58
|
-
"@commitlint/cli": "^
|
|
59
|
-
"@commitlint/config-conventional": "^
|
|
55
|
+
"@commitlint/cli": "^20.1.0",
|
|
56
|
+
"@commitlint/config-conventional": "^20.0.0",
|
|
60
57
|
"@eslint/js": "^9.15.0",
|
|
61
58
|
"@smartive/prettier-config": "^3.0.0",
|
|
62
|
-
"@types/eslint__eslintrc": "^2.1.2",
|
|
63
59
|
"@types/node": "^22.9.1",
|
|
64
60
|
"cz-conventional-changelog": "^3.3.0",
|
|
65
|
-
"
|
|
66
|
-
"eslint": "^9.15.0",
|
|
61
|
+
"eslint": "^9.22.0",
|
|
67
62
|
"husky": "^9.1.7",
|
|
68
|
-
"prettier": "^3.
|
|
69
|
-
"typescript": "^5.
|
|
63
|
+
"prettier": "^3.6.2",
|
|
64
|
+
"typescript": "^5.9.3"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": "^20.19.0 || >=22.12"
|
|
70
68
|
},
|
|
71
69
|
"scripts": {
|
|
72
|
-
"
|
|
73
|
-
"build
|
|
74
|
-
"build:mjs": "esbuild --platform=neutral --format=esm --outdir=dist/esm/ ./src/*.ts",
|
|
75
|
-
"build": "rm -rf dist && npm run build:cjs && npm run build:mjs && npm run build:types",
|
|
70
|
+
"tsc": "tsc",
|
|
71
|
+
"build": "rm -rf dist && tsc",
|
|
76
72
|
"commitlint": "commitlint --edit",
|
|
77
73
|
"prepare": "[ ! -f node_modules/.bin/husky ] || husky"
|
|
78
74
|
},
|
package/dist/cjs/index.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var index_exports = {};
|
|
30
|
-
__export(index_exports, {
|
|
31
|
-
config: () => config,
|
|
32
|
-
configs: () => configs,
|
|
33
|
-
generateLegacyConfig: () => generateLegacyConfig
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(index_exports);
|
|
36
|
-
var import_eslintrc = require("@eslint/eslintrc");
|
|
37
|
-
var import_js = __toESM(require("@eslint/js"));
|
|
38
|
-
var import_eslint_plugin_import = require("eslint-plugin-import");
|
|
39
|
-
var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"));
|
|
40
|
-
var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"));
|
|
41
|
-
var import_globals = __toESM(require("globals"));
|
|
42
|
-
var import_typescript_eslint = __toESM(require("typescript-eslint"));
|
|
43
|
-
const JS_FILES = ["**/*.js", "**/*.mjs"];
|
|
44
|
-
const reactRules = {
|
|
45
|
-
"react/prop-types": "off",
|
|
46
|
-
"react/display-name": "off",
|
|
47
|
-
"react/forbid-component-props": ["warn", { forbid: ["style", "className"] }],
|
|
48
|
-
"@typescript-eslint/no-misused-promises": [
|
|
49
|
-
"error",
|
|
50
|
-
{
|
|
51
|
-
checksVoidReturn: {
|
|
52
|
-
attributes: false
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
};
|
|
57
|
-
const rules = (react) => ({
|
|
58
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
59
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
60
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
61
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
62
|
-
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
63
|
-
"@typescript-eslint/no-var-requires": "warn",
|
|
64
|
-
"@typescript-eslint/no-unused-vars": ["error"],
|
|
65
|
-
"@typescript-eslint/no-floating-promises": ["error"],
|
|
66
|
-
"@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
|
|
67
|
-
"no-constant-binary-expression": "error",
|
|
68
|
-
"array-callback-return": "error",
|
|
69
|
-
"no-debugger": "error",
|
|
70
|
-
"no-alert": "error",
|
|
71
|
-
"no-console": ["error", { allow: ["debug", "info", "warn", "error", "trace", "time", "timeEnd"] }],
|
|
72
|
-
"newline-before-return": "error",
|
|
73
|
-
"prefer-const": "error",
|
|
74
|
-
"no-else-return": "error",
|
|
75
|
-
"no-extra-semi": "error",
|
|
76
|
-
curly: "error",
|
|
77
|
-
eqeqeq: "error",
|
|
78
|
-
"default-case-last": "error",
|
|
79
|
-
"prettier/prettier": [
|
|
80
|
-
"error",
|
|
81
|
-
{
|
|
82
|
-
endOfLine: "auto"
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
...react ? reactRules : {}
|
|
86
|
-
});
|
|
87
|
-
const flatConfigTypescript = import_typescript_eslint.default.config(
|
|
88
|
-
import_js.default.configs.recommended,
|
|
89
|
-
import_recommended.default,
|
|
90
|
-
import_eslint_plugin_import.flatConfigs.errors,
|
|
91
|
-
import_eslint_plugin_import.flatConfigs.warnings,
|
|
92
|
-
import_eslint_plugin_import.flatConfigs.typescript,
|
|
93
|
-
import_typescript_eslint.default.configs.recommendedTypeChecked,
|
|
94
|
-
import_typescript_eslint.default.configs.stylisticTypeChecked,
|
|
95
|
-
{
|
|
96
|
-
files: JS_FILES,
|
|
97
|
-
extends: [import_typescript_eslint.default.configs.disableTypeChecked]
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
rules: rules(false),
|
|
101
|
-
languageOptions: {
|
|
102
|
-
ecmaVersion: 2020,
|
|
103
|
-
sourceType: "module",
|
|
104
|
-
globals: {
|
|
105
|
-
...import_globals.default.browser,
|
|
106
|
-
...import_globals.default.node,
|
|
107
|
-
...import_globals.default.es2020,
|
|
108
|
-
Atomics: "readonly",
|
|
109
|
-
SharedArrayBuffer: "readonly"
|
|
110
|
-
},
|
|
111
|
-
parserOptions: {
|
|
112
|
-
ecmaVersion: 2020,
|
|
113
|
-
sourceType: "module",
|
|
114
|
-
projectService: true
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
const flatConfigNext = () => new import_eslintrc.FlatCompat().extends("next").map((config2) => {
|
|
120
|
-
const { plugins } = config2;
|
|
121
|
-
if (plugins?.import) {
|
|
122
|
-
plugins.import = import_eslint_plugin_import.flatConfigs.errors.plugins.import;
|
|
123
|
-
}
|
|
124
|
-
return config2;
|
|
125
|
-
});
|
|
126
|
-
const flatConfigReact = (includeNextJsConfig = false) => import_typescript_eslint.default.config(
|
|
127
|
-
flatConfigTypescript,
|
|
128
|
-
import_eslint_plugin_react.default.configs.flat.recommended,
|
|
129
|
-
import_eslint_plugin_react.default.configs.flat["jsx-runtime"],
|
|
130
|
-
...includeNextJsConfig ? flatConfigNext() : [],
|
|
131
|
-
{ rules: reactRules }
|
|
132
|
-
);
|
|
133
|
-
const configs = {
|
|
134
|
-
typescript: flatConfigTypescript,
|
|
135
|
-
react: flatConfigReact()
|
|
136
|
-
};
|
|
137
|
-
const config = (type) => {
|
|
138
|
-
switch (type) {
|
|
139
|
-
case "typescript":
|
|
140
|
-
return flatConfigTypescript;
|
|
141
|
-
case "react":
|
|
142
|
-
return flatConfigReact();
|
|
143
|
-
case "nextjs":
|
|
144
|
-
return flatConfigReact(true);
|
|
145
|
-
default:
|
|
146
|
-
throw new Error(`Unknown config type: ${type}`);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
const generateLegacyConfig = (react) => ({
|
|
150
|
-
rules: rules(react),
|
|
151
|
-
env: {
|
|
152
|
-
es2020: true,
|
|
153
|
-
browser: true,
|
|
154
|
-
node: true
|
|
155
|
-
},
|
|
156
|
-
parserOptions: {
|
|
157
|
-
ecmaVersion: 2020,
|
|
158
|
-
sourceType: "module",
|
|
159
|
-
projectService: true
|
|
160
|
-
},
|
|
161
|
-
extends: [
|
|
162
|
-
"eslint:recommended",
|
|
163
|
-
"plugin:prettier/recommended",
|
|
164
|
-
"plugin:import/errors",
|
|
165
|
-
"plugin:import/warnings",
|
|
166
|
-
"plugin:import/typescript",
|
|
167
|
-
"plugin:@typescript-eslint/recommended-type-checked",
|
|
168
|
-
"plugin:@typescript-eslint/stylistic-type-checked",
|
|
169
|
-
...react ? ["plugin:react/recommended", "plugin:react/jsx-runtime"] : []
|
|
170
|
-
],
|
|
171
|
-
globals: {
|
|
172
|
-
Atomics: "readonly",
|
|
173
|
-
SharedArrayBuffer: "readonly"
|
|
174
|
-
},
|
|
175
|
-
parser: "@typescript-eslint/parser",
|
|
176
|
-
plugins: ["@typescript-eslint", "prettier"],
|
|
177
|
-
overrides: [
|
|
178
|
-
{
|
|
179
|
-
files: JS_FILES,
|
|
180
|
-
extends: ["plugin:@typescript-eslint/disable-type-checked"]
|
|
181
|
-
}
|
|
182
|
-
]
|
|
183
|
-
});
|
package/dist/cjs/react-legacy.js
DELETED
package/dist/esm/index.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { FlatCompat } from "@eslint/eslintrc";
|
|
2
|
-
import js from "@eslint/js";
|
|
3
|
-
import { flatConfigs as eslintPluginImportConfigs } from "eslint-plugin-import";
|
|
4
|
-
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
-
import reactPlugin from "eslint-plugin-react";
|
|
6
|
-
import globals from "globals";
|
|
7
|
-
import tsEslint from "typescript-eslint";
|
|
8
|
-
const JS_FILES = ["**/*.js", "**/*.mjs"];
|
|
9
|
-
const reactRules = {
|
|
10
|
-
"react/prop-types": "off",
|
|
11
|
-
"react/display-name": "off",
|
|
12
|
-
"react/forbid-component-props": ["warn", { forbid: ["style", "className"] }],
|
|
13
|
-
"@typescript-eslint/no-misused-promises": [
|
|
14
|
-
"error",
|
|
15
|
-
{
|
|
16
|
-
checksVoidReturn: {
|
|
17
|
-
attributes: false
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
};
|
|
22
|
-
const rules = (react) => ({
|
|
23
|
-
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
24
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
25
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
26
|
-
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
27
|
-
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
28
|
-
"@typescript-eslint/no-var-requires": "warn",
|
|
29
|
-
"@typescript-eslint/no-unused-vars": ["error"],
|
|
30
|
-
"@typescript-eslint/no-floating-promises": ["error"],
|
|
31
|
-
"@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
|
|
32
|
-
"no-constant-binary-expression": "error",
|
|
33
|
-
"array-callback-return": "error",
|
|
34
|
-
"no-debugger": "error",
|
|
35
|
-
"no-alert": "error",
|
|
36
|
-
"no-console": ["error", { allow: ["debug", "info", "warn", "error", "trace", "time", "timeEnd"] }],
|
|
37
|
-
"newline-before-return": "error",
|
|
38
|
-
"prefer-const": "error",
|
|
39
|
-
"no-else-return": "error",
|
|
40
|
-
"no-extra-semi": "error",
|
|
41
|
-
curly: "error",
|
|
42
|
-
eqeqeq: "error",
|
|
43
|
-
"default-case-last": "error",
|
|
44
|
-
"prettier/prettier": [
|
|
45
|
-
"error",
|
|
46
|
-
{
|
|
47
|
-
endOfLine: "auto"
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
...react ? reactRules : {}
|
|
51
|
-
});
|
|
52
|
-
const flatConfigTypescript = tsEslint.config(
|
|
53
|
-
js.configs.recommended,
|
|
54
|
-
eslintPluginPrettierRecommended,
|
|
55
|
-
eslintPluginImportConfigs.errors,
|
|
56
|
-
eslintPluginImportConfigs.warnings,
|
|
57
|
-
eslintPluginImportConfigs.typescript,
|
|
58
|
-
tsEslint.configs.recommendedTypeChecked,
|
|
59
|
-
tsEslint.configs.stylisticTypeChecked,
|
|
60
|
-
{
|
|
61
|
-
files: JS_FILES,
|
|
62
|
-
extends: [tsEslint.configs.disableTypeChecked]
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
rules: rules(false),
|
|
66
|
-
languageOptions: {
|
|
67
|
-
ecmaVersion: 2020,
|
|
68
|
-
sourceType: "module",
|
|
69
|
-
globals: {
|
|
70
|
-
...globals.browser,
|
|
71
|
-
...globals.node,
|
|
72
|
-
...globals.es2020,
|
|
73
|
-
Atomics: "readonly",
|
|
74
|
-
SharedArrayBuffer: "readonly"
|
|
75
|
-
},
|
|
76
|
-
parserOptions: {
|
|
77
|
-
ecmaVersion: 2020,
|
|
78
|
-
sourceType: "module",
|
|
79
|
-
projectService: true
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
const flatConfigNext = () => new FlatCompat().extends("next").map((config2) => {
|
|
85
|
-
const { plugins } = config2;
|
|
86
|
-
if (plugins?.import) {
|
|
87
|
-
plugins.import = eslintPluginImportConfigs.errors.plugins.import;
|
|
88
|
-
}
|
|
89
|
-
return config2;
|
|
90
|
-
});
|
|
91
|
-
const flatConfigReact = (includeNextJsConfig = false) => tsEslint.config(
|
|
92
|
-
flatConfigTypescript,
|
|
93
|
-
reactPlugin.configs.flat.recommended,
|
|
94
|
-
reactPlugin.configs.flat["jsx-runtime"],
|
|
95
|
-
...includeNextJsConfig ? flatConfigNext() : [],
|
|
96
|
-
{ rules: reactRules }
|
|
97
|
-
);
|
|
98
|
-
const configs = {
|
|
99
|
-
typescript: flatConfigTypescript,
|
|
100
|
-
react: flatConfigReact()
|
|
101
|
-
};
|
|
102
|
-
const config = (type) => {
|
|
103
|
-
switch (type) {
|
|
104
|
-
case "typescript":
|
|
105
|
-
return flatConfigTypescript;
|
|
106
|
-
case "react":
|
|
107
|
-
return flatConfigReact();
|
|
108
|
-
case "nextjs":
|
|
109
|
-
return flatConfigReact(true);
|
|
110
|
-
default:
|
|
111
|
-
throw new Error(`Unknown config type: ${type}`);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const generateLegacyConfig = (react) => ({
|
|
115
|
-
rules: rules(react),
|
|
116
|
-
env: {
|
|
117
|
-
es2020: true,
|
|
118
|
-
browser: true,
|
|
119
|
-
node: true
|
|
120
|
-
},
|
|
121
|
-
parserOptions: {
|
|
122
|
-
ecmaVersion: 2020,
|
|
123
|
-
sourceType: "module",
|
|
124
|
-
projectService: true
|
|
125
|
-
},
|
|
126
|
-
extends: [
|
|
127
|
-
"eslint:recommended",
|
|
128
|
-
"plugin:prettier/recommended",
|
|
129
|
-
"plugin:import/errors",
|
|
130
|
-
"plugin:import/warnings",
|
|
131
|
-
"plugin:import/typescript",
|
|
132
|
-
"plugin:@typescript-eslint/recommended-type-checked",
|
|
133
|
-
"plugin:@typescript-eslint/stylistic-type-checked",
|
|
134
|
-
...react ? ["plugin:react/recommended", "plugin:react/jsx-runtime"] : []
|
|
135
|
-
],
|
|
136
|
-
globals: {
|
|
137
|
-
Atomics: "readonly",
|
|
138
|
-
SharedArrayBuffer: "readonly"
|
|
139
|
-
},
|
|
140
|
-
parser: "@typescript-eslint/parser",
|
|
141
|
-
plugins: ["@typescript-eslint", "prettier"],
|
|
142
|
-
overrides: [
|
|
143
|
-
{
|
|
144
|
-
files: JS_FILES,
|
|
145
|
-
extends: ["plugin:@typescript-eslint/disable-type-checked"]
|
|
146
|
-
}
|
|
147
|
-
]
|
|
148
|
-
});
|
|
149
|
-
export {
|
|
150
|
-
config,
|
|
151
|
-
configs,
|
|
152
|
-
generateLegacyConfig
|
|
153
|
-
};
|
package/dist/esm/react-legacy.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
import { generateLegacyConfig } from "./";
|
|
6
|
-
var require_react_legacy = __commonJS({
|
|
7
|
-
"src/react-legacy.ts"(exports, module) {
|
|
8
|
-
module.exports = generateLegacyConfig(true);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
export default require_react_legacy();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
import { generateLegacyConfig } from "./";
|
|
6
|
-
var require_typescript_legacy = __commonJS({
|
|
7
|
-
"src/typescript-legacy.ts"(exports, module) {
|
|
8
|
-
module.exports = generateLegacyConfig(false);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
export default require_typescript_legacy();
|