Compare commits
6 Commits
inline
...
3ac5f91988
Author | SHA1 | Date | |
---|---|---|---|
3ac5f91988 | |||
2853da4344 | |||
1e6d679af3 | |||
674eaf1811 | |||
c175f87441 | |||
003a43512c |
18
.eslintrc
18
.eslintrc
@ -3,12 +3,12 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true
|
"es6": true,
|
||||||
},
|
},
|
||||||
"extends": ["eslint:recommended", "prettier"],
|
"extends": ["eslint:recommended", "prettier"],
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
"ecmaVersion": "latest"
|
"ecmaVersion": "latest",
|
||||||
},
|
},
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-restricted-imports": [
|
"no-restricted-imports": [
|
||||||
@ -24,14 +24,14 @@
|
|||||||
"object.hasown",
|
"object.hasown",
|
||||||
"object.values",
|
"object.values",
|
||||||
"string.prototype.matchall",
|
"string.prototype.matchall",
|
||||||
"has"
|
"has",
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
],
|
],
|
||||||
"arrow-body-style": ["error", "as-needed"],
|
"arrow-body-style": ["error", "as-needed"],
|
||||||
"class-methods-use-this": [
|
"class-methods-use-this": [
|
||||||
"warn",
|
"warn",
|
||||||
{ "exceptMethods": ["toString", "shouldComponentUpdate"] }
|
{ "exceptMethods": ["toString", "shouldComponentUpdate"] },
|
||||||
],
|
],
|
||||||
"complexity": ["warn", { "max": 100 }],
|
"complexity": ["warn", { "max": 100 }],
|
||||||
"curly": ["error", "multi-line", "consistent"],
|
"curly": ["error", "multi-line", "consistent"],
|
||||||
@ -50,13 +50,13 @@
|
|||||||
"prefer-const": ["error", { "destructuring": "all" }],
|
"prefer-const": ["error", { "destructuring": "all" }],
|
||||||
"prefer-destructuring": [
|
"prefer-destructuring": [
|
||||||
"warn",
|
"warn",
|
||||||
{ "AssignmentExpression": { "array": false, "object": false } }
|
{ "AssignmentExpression": { "array": false, "object": false } },
|
||||||
],
|
],
|
||||||
"prefer-rest-params": "warn",
|
"prefer-rest-params": "warn",
|
||||||
"prefer-spread": "warn",
|
"prefer-spread": "warn",
|
||||||
"quote-props": ["error", "as-needed"],
|
"quote-props": ["error", "as-needed"],
|
||||||
"spaced-comment": ["error", "always", { "markers": ["/"] }],
|
"spaced-comment": ["error", "always", { "markers": ["/"] }],
|
||||||
"sort-imports": ["warn", { "ignoreDeclarationSort": true }],
|
"sort-imports": ["warn", { "ignoreDeclarationSort": true }],
|
||||||
"yoda": ["error", "never", { "exceptRange": true }]
|
"yoda": ["error", "never", { "exceptRange": true }],
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,8 @@
|
|||||||
|
drafts
|
||||||
!/packages/eslint-plugin-react-hooks
|
!/packages/eslint-plugin-react-hooks
|
||||||
|
/packages/eslint-define-config
|
||||||
/react
|
/react
|
||||||
|
src/types/rules
|
||||||
|
|
||||||
dist/**/*.js
|
dist/**/*.js
|
||||||
dist/**/*.js.map
|
dist/**/*.js.map
|
||||||
|
@ -4,6 +4,8 @@ Personal ESLint config. Guaranteed to have no useless polyfills.
|
|||||||
|
|
||||||
## flat config support
|
## flat config support
|
||||||
|
|
||||||
- ❌ [import](https://github.com/import-js/eslint-plugin-import/issues/2556)
|
- ⏱️ [a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/993)
|
||||||
- ✅ [react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3429)
|
- ✅ [react](https://github.com/jsx-eslint/eslint-plugin-react/pull/3429)
|
||||||
- ⏱️ [a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/pull/891)
|
- ✅ [unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn/pull/1886)
|
||||||
|
- ❌ [import](https://github.com/un-ts/eslint-plugin-import-x/issues/29)
|
||||||
|
- ❌ [jsx-a11y](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/issues/978)
|
||||||
|
14
dist/eslint-plugin-import/index.d.ts
vendored
14
dist/eslint-plugin-import/index.d.ts
vendored
@ -1,14 +0,0 @@
|
|||||||
import type { Linter } from 'eslint';
|
|
||||||
|
|
||||||
export const rules: Readonly<Linter.RulesRecord>;
|
|
||||||
|
|
||||||
export const configs: {
|
|
||||||
recommended: Linter.BaseConfig;
|
|
||||||
errors: Linter.BaseConfig;
|
|
||||||
warnings: Linter.BaseConfig;
|
|
||||||
'stage-0': Linter.BaseConfig;
|
|
||||||
react: Linter.BaseConfig;
|
|
||||||
'react-native': Linter.BaseConfig;
|
|
||||||
electron: Linter.BaseConfig;
|
|
||||||
typescript: Linter.BaseConfig;
|
|
||||||
};
|
|
35
dist/index.d.ts
vendored
35
dist/index.d.ts
vendored
@ -1,12 +1,19 @@
|
|||||||
// Generated by dts-bundle-generator v9.4.0
|
// Generated by dts-bundle-generator v9.4.0
|
||||||
|
|
||||||
|
import { ESLintConfig, KnownExtends, Rules, Settings } from '@aet/eslint-define-config';
|
||||||
import { ESLintUtils } from '@typescript-eslint/utils';
|
import { ESLintUtils } from '@typescript-eslint/utils';
|
||||||
import { Rule } from 'eslint';
|
import { Rule } from 'eslint';
|
||||||
import { ESLintConfig, Rules } from 'eslint-define-config';
|
import { Merge, SetRequired } from 'type-fest';
|
||||||
|
|
||||||
export declare const error = "error";
|
export declare const error = "error";
|
||||||
export declare const warn = "warn";
|
export declare const warn = "warn";
|
||||||
export declare const off = "off";
|
export declare const off = "off";
|
||||||
|
export declare const graphql: Middleware;
|
||||||
|
export declare const jsdoc: Middleware;
|
||||||
|
export declare const storybook: Middleware;
|
||||||
|
export declare const react: Middleware;
|
||||||
|
export declare const reactRefresh: Middleware;
|
||||||
|
export declare const tailwind: Middleware;
|
||||||
export type RuleLevel = "error" | "warn" | "off" | 0 | 1 | 2;
|
export type RuleLevel = "error" | "warn" | "off" | 0 | 1 | 2;
|
||||||
export type RuleEntry<Options> = RuleLevel | [
|
export type RuleEntry<Options> = RuleLevel | [
|
||||||
RuleLevel,
|
RuleLevel,
|
||||||
@ -32,6 +39,7 @@ export interface CustomRule {
|
|||||||
}>;
|
}>;
|
||||||
options?: RuleLevel;
|
options?: RuleLevel;
|
||||||
}
|
}
|
||||||
|
export type Middleware = (config: MiddlewareConfig, helpers: MiddlewareFunctions) => void;
|
||||||
/**
|
/**
|
||||||
* ESLint Configuration.
|
* ESLint Configuration.
|
||||||
* @see [ESLint Configuration](https://eslint.org/docs/latest/user-guide/configuring/)
|
* @see [ESLint Configuration](https://eslint.org/docs/latest/user-guide/configuring/)
|
||||||
@ -41,18 +49,32 @@ export type InputConfig = Omit<ESLintConfig, "rules"> & {
|
|||||||
* Rules.
|
* Rules.
|
||||||
* @see [Rules](https://eslint.org/docs/latest/user-guide/configuring/rules)
|
* @see [Rules](https://eslint.org/docs/latest/user-guide/configuring/rules)
|
||||||
*/
|
*/
|
||||||
rules?: RuleOptions;
|
rules?: Partial<RuleOptions>;
|
||||||
/**
|
/**
|
||||||
* Glob pattern to find paths to custom rule files in JavaScript or TypeScript.
|
* Glob pattern to find paths to custom rule files in JavaScript or TypeScript.
|
||||||
* Note this must be a string literal or an array of string literals since
|
* Note this must be a string literal or an array of string literals since
|
||||||
* this is statically analyzed.
|
* this is statically analyzed.
|
||||||
*/
|
*/
|
||||||
customRuleFiles?: string | string[];
|
customRuleFiles?: string | string[];
|
||||||
|
/**
|
||||||
|
* Automatically detect project types, dependencies and deduct the plugins.
|
||||||
|
*/
|
||||||
|
auto?: boolean;
|
||||||
};
|
};
|
||||||
|
export type OptionalObjectKey<T> = Exclude<{
|
||||||
|
[Key in keyof T]: undefined | any[] extends T[Key] ? Key : undefined | Record<any, any> extends T[Key] ? Key : never;
|
||||||
|
}[keyof T], undefined>;
|
||||||
|
export type MiddlewareConfig = Merge<SetRequired<ESLintConfig, OptionalObjectKey<ESLintConfig>>, {
|
||||||
|
extends: KnownExtends[];
|
||||||
|
}>;
|
||||||
|
export interface MiddlewareFunctions {
|
||||||
|
addRules(rules: Partial<RuleOptions>): void;
|
||||||
|
addSettings(settings: Partial<Settings>): void;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a ESLint config object.
|
* Returns a ESLint config object.
|
||||||
*
|
*
|
||||||
* By default, it includes `["@typescript-eslint", "import", "prettier"]` configs.
|
* By default, it includes `["@typescript-eslint", "import-x", "prettier", "unicorn"]` configs.
|
||||||
* Additional bundled plugins include:
|
* Additional bundled plugins include:
|
||||||
*
|
*
|
||||||
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
||||||
@ -61,12 +83,15 @@ export type InputConfig = Omit<ESLintConfig, "rules"> & {
|
|||||||
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
||||||
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
||||||
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
||||||
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific)
|
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific,
|
||||||
|
* requires `minimatch`)
|
||||||
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
||||||
*
|
*
|
||||||
* Non bundled:
|
* Non bundled:
|
||||||
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
||||||
*/
|
*/
|
||||||
export declare function extendConfig(of?: InputConfig): ESLintConfig;
|
export declare function extendConfig(of?: InputConfig & {
|
||||||
|
middlewares: Middleware[];
|
||||||
|
}): ESLintConfig;
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
45
dist/package.json
vendored
45
dist/package.json
vendored
@ -1,47 +1,50 @@
|
|||||||
{
|
{
|
||||||
"name": "@aet/eslint-rules",
|
"name": "@aet/eslint-rules",
|
||||||
"version": "0.0.24-beta.1",
|
"version": "1.0.1-beta.11",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"typescript": "^5.4.4"
|
"typescript": "^5.4.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@nolyfill/is-core-module": "^1.0.39",
|
||||||
|
"@aet/eslint-define-config": "^0.1.0-beta.15",
|
||||||
"@eslint-community/eslint-utils": "^4.4.0",
|
"@eslint-community/eslint-utils": "^4.4.0",
|
||||||
"@types/eslint": "^8.56.9",
|
"@tanstack/eslint-plugin-query": "^5.51.15",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
"@types/eslint": "^8.56.11",
|
||||||
"@typescript-eslint/parser": "^7.7.0",
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
||||||
"@typescript-eslint/type-utils": "^7.7.0",
|
"@typescript-eslint/parser": "^7.17.0",
|
||||||
"@typescript-eslint/utils": "^7.7.0",
|
"@typescript-eslint/type-utils": "^7.17.0",
|
||||||
|
"@typescript-eslint/utils": "^7.17.0",
|
||||||
|
"@eslint-react/eslint-plugin": "^1.6.0",
|
||||||
"aria-query": "^5.3.0",
|
"aria-query": "^5.3.0",
|
||||||
"axe-core": "^4.9.0",
|
"axe-core": "^4.9.1",
|
||||||
"axobject-query": "^4.0.0",
|
"axobject-query": "4.1.0",
|
||||||
"damerau-levenshtein": "1.0.8",
|
"damerau-levenshtein": "1.0.8",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.6",
|
||||||
"doctrine": "^3.0.0",
|
"doctrine": "^3.0.0",
|
||||||
"emoji-regex": "^10.3.0",
|
"emoji-regex": "^10.3.0",
|
||||||
"enhanced-resolve": "^5.16.0",
|
"enhanced-resolve": "^5.17.1",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-define-config": "^1.24.1",
|
|
||||||
"eslint-import-resolver-node": "^0.3.9",
|
"eslint-import-resolver-node": "^0.3.9",
|
||||||
"eslint-module-utils": "^2.8.1",
|
"eslint-module-utils": "^2.8.1",
|
||||||
"eslint-plugin-es-x": "^7.6.0",
|
"eslint-plugin-es-x": "^8.0.0",
|
||||||
"eslint-plugin-jsdoc": "^48.2.3",
|
"eslint-plugin-import-x": "^3.1.0",
|
||||||
"eslint-plugin-unicorn": "^52.0.0",
|
"eslint-plugin-jsdoc": "^48.8.3",
|
||||||
|
"eslint-plugin-react-refresh": "^0.4.9",
|
||||||
|
"eslint-plugin-unicorn": "^55.0.0",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"esquery": "^1.5.0",
|
"esquery": "^1.6.0",
|
||||||
"estraverse": "^5.3.0",
|
"estraverse": "^5.3.0",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"get-tsconfig": "^4.7.3",
|
"get-tsconfig": "^4.7.6",
|
||||||
|
"is-bun-module": "^1.0.2",
|
||||||
"ignore": "^5.3.1",
|
"ignore": "^5.3.1",
|
||||||
"is-builtin-module": "^3.2.1",
|
|
||||||
"is-glob": "^4.0.3",
|
"is-glob": "^4.0.3",
|
||||||
"language-tags": "^1.0.9",
|
"language-tags": "^1.0.9",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimatch": "^9.0.4",
|
|
||||||
"resolve": "^2.0.0-next.5",
|
"resolve": "^2.0.0-next.5",
|
||||||
"semver": "^7.6.0",
|
"semver": "^7.6.3"
|
||||||
"tsconfig-paths": "^4.2.0"
|
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"is-core-module": "file:./overrides/is-core-module",
|
"is-core-module": "file:./overrides/is-core-module",
|
||||||
@ -57,4 +60,4 @@
|
|||||||
"supports-preserve-symlinks-flag": "file:./overrides/supports-preserve-symlinks-flag"
|
"supports-preserve-symlinks-flag": "file:./overrides/supports-preserve-symlinks-flag"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1130
dist/yarn.lock
vendored
1130
dist/yarn.lock
vendored
File diff suppressed because it is too large
Load Diff
70
package.json
70
package.json
@ -2,47 +2,49 @@
|
|||||||
"name": "@aet/eslint-configs",
|
"name": "@aet/eslint-configs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "./scripts/build.ts",
|
"build": "./scripts/build.ts",
|
||||||
"check-import": "./scripts/check-imports.ts"
|
"check-import": "./scripts/check-imports.ts",
|
||||||
|
"define": "/usr/local/bin/codium ./packages/eslint-define-config"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.24.4",
|
"@aet/eslint-define-config": "^0.1.0-beta.15",
|
||||||
"@babel/plugin-transform-flow-strip-types": "^7.24.1",
|
"@babel/core": "^7.24.9",
|
||||||
"@babel/preset-env": "^7.24.4",
|
"@babel/plugin-transform-flow-strip-types": "^7.24.7",
|
||||||
|
"@babel/preset-env": "^7.25.0",
|
||||||
"@types/babel-plugin-macros": "^3.1.3",
|
"@types/babel-plugin-macros": "^3.1.3",
|
||||||
"@types/babel__core": "^7.20.5",
|
"@types/babel__core": "^7.20.5",
|
||||||
"@types/eslint": "^8.56.9",
|
"@types/eslint": "^9.6.0",
|
||||||
"@types/esprima": "^4.0.6",
|
"@types/esprima": "^4.0.6",
|
||||||
"@types/esquery": "^1.5.3",
|
"@types/esquery": "^1.5.4",
|
||||||
"@types/estree": "^1.0.5",
|
"@types/estree": "^1.0.5",
|
||||||
"@types/estree-jsx": "^1.0.5",
|
"@types/estree-jsx": "^1.0.5",
|
||||||
"@types/lodash": "^4.17.0",
|
"@types/lodash": "^4.17.7",
|
||||||
"@types/node": "^20.12.7",
|
"@types/node": "^20.14.12",
|
||||||
"@typescript-eslint/eslint-plugin": "7.7.0",
|
"@typescript-eslint/eslint-plugin": "7.17.0",
|
||||||
"@typescript-eslint/type-utils": "^7.7.0",
|
"@typescript-eslint/type-utils": "^7.17.0",
|
||||||
"@typescript-eslint/types": "^7.7.0",
|
"@typescript-eslint/types": "^7.17.0",
|
||||||
"@typescript-eslint/typescript-estree": "^7.7.0",
|
"@typescript-eslint/typescript-estree": "^7.17.0",
|
||||||
"@typescript-eslint/utils": "^7.7.0",
|
"@typescript-eslint/utils": "^7.17.0",
|
||||||
"babel-plugin-macros": "^3.1.0",
|
"babel-plugin-macros": "^3.1.0",
|
||||||
"dts-bundle-generator": "^9.4.0",
|
"dts-bundle-generator": "9.4.0",
|
||||||
"esbin": "0.0.4",
|
"esbuild": "0.23.0",
|
||||||
"esbuild": "0.20.2",
|
|
||||||
"esbuild-plugin-alias": "^0.2.1",
|
"esbuild-plugin-alias": "^0.2.1",
|
||||||
"eslint": "8.57.0",
|
"eslint": "8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-define-config": "^1.24.1",
|
"eslint-plugin-import-x": "^3.1.0",
|
||||||
"esprima": "^4.0.1",
|
"esprima": "^4.0.1",
|
||||||
"esquery": "^1.5.0",
|
"esquery": "^1.6.0",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"find-cache-dir": "^5.0.0",
|
"find-cache-dir": "^5.0.0",
|
||||||
"json-schema-to-ts": "^3.0.1",
|
"json-schema-to-ts": "^3.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"minimatch": "^9.0.4",
|
"nolyfill": "^1.0.39",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
"picocolors": "^1.0.0",
|
"picocolors": "^1.0.1",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.3.3",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"typescript": "^5.4.5"
|
"type-fest": "^4.23.0",
|
||||||
|
"typescript": "^5.5.4"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"arrowParens": "avoid",
|
"arrowParens": "avoid",
|
||||||
@ -54,15 +56,17 @@
|
|||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"function-bind": "npm:@nolyfill/function-bind@latest",
|
"function-bind": "npm:@nolyfill/function-bind@^1",
|
||||||
"has-proto": "npm:@nolyfill/has-proto@latest",
|
"has-proto": "npm:@nolyfill/has-proto@^1",
|
||||||
"has-symbols": "npm:@nolyfill/has-symbols@latest",
|
"has-symbols": "npm:@nolyfill/has-symbols@^1",
|
||||||
"hasown": "npm:@nolyfill/hasown@latest",
|
"hasown": "npm:@nolyfill/hasown@^1",
|
||||||
"isarray": "npm:@nolyfill/isarray@latest",
|
"isarray": "npm:@nolyfill/isarray@^1",
|
||||||
"jsonify": "npm:@nolyfill/jsonify@latest",
|
"jsonify": "npm:@nolyfill/jsonify@^1",
|
||||||
"object-keys": "npm:@nolyfill/object-keys@latest",
|
"object-keys": "npm:@nolyfill/object-keys@^1",
|
||||||
"set-function-length": "npm:@nolyfill/set-function-length@latest",
|
"set-function-length": "npm:@nolyfill/set-function-length@^1",
|
||||||
"@babel/types": "7.24.0"
|
"@babel/types": "7.24.0",
|
||||||
|
"is-core-module": "npm:@nolyfill/is-core-module@^1",
|
||||||
|
"json-stable-stringify": "npm:@nolyfill/json-stable-stringify@^1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Submodule packages/eslint-import-resolver-typescript updated: 7b6bfc3947...c9b5626ee6
Submodule packages/eslint-plugin-import deleted from 6b95a02193
Submodule packages/eslint-plugin-jsx-a11y updated: fffb05b38c...cca288b73a
Submodule packages/eslint-plugin-n updated: 47cd9a6a0e...5aad5f1c41
Submodule packages/eslint-plugin-react deleted from ecadb92609
@ -1,28 +1,10 @@
|
|||||||
diff --git a/package.json b/package.json
|
|
||||||
index 98370b5..da6cd9b 100644
|
|
||||||
--- a/package.json
|
|
||||||
+++ b/package.json
|
|
||||||
@@ -62,8 +62,7 @@
|
|
||||||
"typecov": "type-coverage"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
- "eslint": "*",
|
|
||||||
- "eslint-plugin-import": "*"
|
|
||||||
+ "eslint": "*"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"debug": "^4.3.4",
|
|
||||||
diff --git a/tsconfig.json b/tsconfig.json
|
diff --git a/tsconfig.json b/tsconfig.json
|
||||||
deleted file mode 100644
|
index 39c6900..6fd8822 100644
|
||||||
index a303861..0000000
|
|
||||||
--- a/tsconfig.json
|
--- a/tsconfig.json
|
||||||
+++ /dev/null
|
+++ b/tsconfig.json
|
||||||
@@ -1,8 +0,0 @@
|
@@ -1,5 +1,4 @@
|
||||||
-{
|
{
|
||||||
- "extends": "@1stg/tsconfig/node16",
|
- "extends": "@1stg/tsconfig/node16",
|
||||||
- "compilerOptions": {
|
"compilerOptions": {
|
||||||
- "module": "Node16",
|
"module": "Node16",
|
||||||
- "outDir": "./lib"
|
"outDir": "./lib",
|
||||||
- },
|
|
||||||
- "include": ["./src", "./shim.d.ts"]
|
|
||||||
-}
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,16 @@
|
|||||||
diff --git a/src/index.js b/src/index.js
|
diff --git a/src/index.js b/src/index.js
|
||||||
index 7b931fe..eaea267 100644
|
index 2fa185f..29d65d0 100644
|
||||||
--- a/src/index.js
|
--- a/src/index.js
|
||||||
+++ b/src/index.js
|
+++ b/src/index.js
|
||||||
@@ -1,296 +1,344 @@
|
@@ -1,48 +1,90 @@
|
||||||
/* eslint-disable global-require */
|
/* eslint-disable global-require */
|
||||||
+// @ts-check
|
-const flatConfigBase = require('./configs/flat-config-base');
|
||||||
|
-const legacyConfigBase = require('./configs/legacy-config-base');
|
||||||
|
-const { name, version } = require('../package.json');
|
||||||
|
+import flatConfigBase from './configs/flat-config-base';
|
||||||
|
+import legacyConfigBase from './configs/legacy-config-base';
|
||||||
|
+import { name, version } from '../package.json';
|
||||||
|
+
|
||||||
+import accessibleEmoji from './rules/accessible-emoji';
|
+import accessibleEmoji from './rules/accessible-emoji';
|
||||||
+import altText from './rules/alt-text';
|
+import altText from './rules/alt-text';
|
||||||
+import anchorAmbiguousText from './rules/anchor-ambiguous-text';
|
+import anchorAmbiguousText from './rules/anchor-ambiguous-text';
|
||||||
@ -45,577 +51,105 @@ index 7b931fe..eaea267 100644
|
|||||||
+import scope from './rules/scope';
|
+import scope from './rules/scope';
|
||||||
+import tabindexNoPositive from './rules/tabindex-no-positive';
|
+import tabindexNoPositive from './rules/tabindex-no-positive';
|
||||||
|
|
||||||
-module.exports = {
|
const allRules = {
|
||||||
- rules: {
|
- 'accessible-emoji': require('./rules/accessible-emoji'),
|
||||||
- 'accessible-emoji': require('./rules/accessible-emoji'),
|
- 'alt-text': require('./rules/alt-text'),
|
||||||
- 'alt-text': require('./rules/alt-text'),
|
- 'anchor-ambiguous-text': require('./rules/anchor-ambiguous-text'),
|
||||||
- 'anchor-ambiguous-text': require('./rules/anchor-ambiguous-text'),
|
- 'anchor-has-content': require('./rules/anchor-has-content'),
|
||||||
- 'anchor-has-content': require('./rules/anchor-has-content'),
|
- 'anchor-is-valid': require('./rules/anchor-is-valid'),
|
||||||
- 'anchor-is-valid': require('./rules/anchor-is-valid'),
|
- 'aria-activedescendant-has-tabindex': require('./rules/aria-activedescendant-has-tabindex'),
|
||||||
- 'aria-activedescendant-has-tabindex': require('./rules/aria-activedescendant-has-tabindex'),
|
- 'aria-props': require('./rules/aria-props'),
|
||||||
- 'aria-props': require('./rules/aria-props'),
|
- 'aria-proptypes': require('./rules/aria-proptypes'),
|
||||||
- 'aria-proptypes': require('./rules/aria-proptypes'),
|
- 'aria-role': require('./rules/aria-role'),
|
||||||
- 'aria-role': require('./rules/aria-role'),
|
- 'aria-unsupported-elements': require('./rules/aria-unsupported-elements'),
|
||||||
- 'aria-unsupported-elements': require('./rules/aria-unsupported-elements'),
|
- 'autocomplete-valid': require('./rules/autocomplete-valid'),
|
||||||
- 'autocomplete-valid': require('./rules/autocomplete-valid'),
|
- 'click-events-have-key-events': require('./rules/click-events-have-key-events'),
|
||||||
- 'click-events-have-key-events': require('./rules/click-events-have-key-events'),
|
- 'control-has-associated-label': require('./rules/control-has-associated-label'),
|
||||||
- 'control-has-associated-label': require('./rules/control-has-associated-label'),
|
- 'heading-has-content': require('./rules/heading-has-content'),
|
||||||
- 'heading-has-content': require('./rules/heading-has-content'),
|
- 'html-has-lang': require('./rules/html-has-lang'),
|
||||||
- 'html-has-lang': require('./rules/html-has-lang'),
|
- 'iframe-has-title': require('./rules/iframe-has-title'),
|
||||||
- 'iframe-has-title': require('./rules/iframe-has-title'),
|
- 'img-redundant-alt': require('./rules/img-redundant-alt'),
|
||||||
- 'img-redundant-alt': require('./rules/img-redundant-alt'),
|
- 'interactive-supports-focus': require('./rules/interactive-supports-focus'),
|
||||||
- 'interactive-supports-focus': require('./rules/interactive-supports-focus'),
|
- 'label-has-associated-control': require('./rules/label-has-associated-control'),
|
||||||
- 'label-has-associated-control': require('./rules/label-has-associated-control'),
|
- 'label-has-for': require('./rules/label-has-for'),
|
||||||
- 'label-has-for': require('./rules/label-has-for'),
|
- lang: require('./rules/lang'),
|
||||||
- lang: require('./rules/lang'),
|
- 'media-has-caption': require('./rules/media-has-caption'),
|
||||||
- 'media-has-caption': require('./rules/media-has-caption'),
|
- 'mouse-events-have-key-events': require('./rules/mouse-events-have-key-events'),
|
||||||
- 'mouse-events-have-key-events': require('./rules/mouse-events-have-key-events'),
|
- 'no-access-key': require('./rules/no-access-key'),
|
||||||
- 'no-access-key': require('./rules/no-access-key'),
|
- 'no-aria-hidden-on-focusable': require('./rules/no-aria-hidden-on-focusable'),
|
||||||
- 'no-aria-hidden-on-focusable': require('./rules/no-aria-hidden-on-focusable'),
|
- 'no-autofocus': require('./rules/no-autofocus'),
|
||||||
- 'no-autofocus': require('./rules/no-autofocus'),
|
- 'no-distracting-elements': require('./rules/no-distracting-elements'),
|
||||||
- 'no-distracting-elements': require('./rules/no-distracting-elements'),
|
- 'no-interactive-element-to-noninteractive-role': require('./rules/no-interactive-element-to-noninteractive-role'),
|
||||||
- 'no-interactive-element-to-noninteractive-role': require('./rules/no-interactive-element-to-noninteractive-role'),
|
- 'no-noninteractive-element-interactions': require('./rules/no-noninteractive-element-interactions'),
|
||||||
- 'no-noninteractive-element-interactions': require('./rules/no-noninteractive-element-interactions'),
|
- 'no-noninteractive-element-to-interactive-role': require('./rules/no-noninteractive-element-to-interactive-role'),
|
||||||
- 'no-noninteractive-element-to-interactive-role': require('./rules/no-noninteractive-element-to-interactive-role'),
|
- 'no-noninteractive-tabindex': require('./rules/no-noninteractive-tabindex'),
|
||||||
- 'no-noninteractive-tabindex': require('./rules/no-noninteractive-tabindex'),
|
- 'no-onchange': require('./rules/no-onchange'),
|
||||||
- 'no-onchange': require('./rules/no-onchange'),
|
- 'no-redundant-roles': require('./rules/no-redundant-roles'),
|
||||||
- 'no-redundant-roles': require('./rules/no-redundant-roles'),
|
- 'no-static-element-interactions': require('./rules/no-static-element-interactions'),
|
||||||
- 'no-static-element-interactions': require('./rules/no-static-element-interactions'),
|
- 'prefer-tag-over-role': require('./rules/prefer-tag-over-role'),
|
||||||
- 'prefer-tag-over-role': require('./rules/prefer-tag-over-role'),
|
- 'role-has-required-aria-props': require('./rules/role-has-required-aria-props'),
|
||||||
- 'role-has-required-aria-props': require('./rules/role-has-required-aria-props'),
|
- 'role-supports-aria-props': require('./rules/role-supports-aria-props'),
|
||||||
- 'role-supports-aria-props': require('./rules/role-supports-aria-props'),
|
- scope: require('./rules/scope'),
|
||||||
- scope: require('./rules/scope'),
|
- 'tabindex-no-positive': require('./rules/tabindex-no-positive'),
|
||||||
- 'tabindex-no-positive': require('./rules/tabindex-no-positive'),
|
+ 'accessible-emoji': accessibleEmoji,
|
||||||
- },
|
+ 'alt-text': altText,
|
||||||
- configs: {
|
+ 'anchor-ambiguous-text': anchorAmbiguousText,
|
||||||
- recommended: {
|
+ 'anchor-has-content': anchorHasContent,
|
||||||
- plugins: [
|
+ 'anchor-is-valid': anchorIsValid,
|
||||||
- 'jsx-a11y',
|
+ 'aria-activedescendant-has-tabindex': ariaActivedescendantHasTabindex,
|
||||||
+export const rules = kebabCase({
|
+ 'aria-props': ariaProps,
|
||||||
+ accessibleEmoji,
|
+ 'aria-proptypes': ariaProptypes,
|
||||||
+ altText,
|
+ 'aria-role': ariaRole,
|
||||||
+ anchorAmbiguousText,
|
+ 'aria-unsupported-elements': ariaUnsupportedElements,
|
||||||
+ anchorHasContent,
|
+ 'autocomplete-valid': autocompleteValid,
|
||||||
+ anchorIsValid,
|
+ 'click-events-have-key-events': clickEventsHaveKeyEvents,
|
||||||
+ ariaActivedescendantHasTabindex,
|
+ 'control-has-associated-label': controlHasAssociatedLabel,
|
||||||
+ ariaProps,
|
+ 'heading-has-content': headingHasContent,
|
||||||
+ ariaProptypes,
|
+ 'html-has-lang': htmlHasLang,
|
||||||
+ ariaRole,
|
+ 'iframe-has-title': iframeHasTitle,
|
||||||
+ ariaUnsupportedElements,
|
+ 'img-redundant-alt': imgRedundantAlt,
|
||||||
+ autocompleteValid,
|
+ 'interactive-supports-focus': interactiveSupportsFocus,
|
||||||
+ clickEventsHaveKeyEvents,
|
+ 'label-has-associated-control': labelHasAssociatedControl,
|
||||||
+ controlHasAssociatedLabel,
|
+ 'label-has-for': labelHasFor,
|
||||||
+ headingHasContent,
|
|
||||||
+ htmlHasLang,
|
|
||||||
+ iframeHasTitle,
|
|
||||||
+ imgRedundantAlt,
|
|
||||||
+ interactiveSupportsFocus,
|
|
||||||
+ labelHasAssociatedControl,
|
|
||||||
+ labelHasFor,
|
|
||||||
+ lang,
|
+ lang,
|
||||||
+ mediaHasCaption,
|
+ 'media-has-caption': mediaHasCaption,
|
||||||
+ mouseEventsHaveKeyEvents,
|
+ 'mouse-events-have-key-events': mouseEventsHaveKeyEvents,
|
||||||
+ noAccessKey,
|
+ 'no-access-key': noAccessKey,
|
||||||
+ noAriaHiddenOnFocusable,
|
+ 'no-aria-hidden-on-focusable': noAriaHiddenOnFocusable,
|
||||||
+ noAutofocus,
|
+ 'no-autofocus': noAutofocus,
|
||||||
+ noDistractingElements,
|
+ 'no-distracting-elements': noDistractingElements,
|
||||||
+ noInteractiveElementToNoninteractiveRole,
|
+ 'no-interactive-element-to-noninteractive-role':
|
||||||
+ noNoninteractiveElementInteractions,
|
+ noInteractiveElementToNoninteractiveRole,
|
||||||
+ noNoninteractiveElementToInteractiveRole,
|
+ 'no-noninteractive-element-interactions': noNoninteractiveElementInteractions,
|
||||||
+ noNoninteractiveTabindex,
|
+ 'no-noninteractive-element-to-interactive-role':
|
||||||
+ noOnChange,
|
+ noNoninteractiveElementToInteractiveRole,
|
||||||
+ noRedundantRoles,
|
+ 'no-noninteractive-tabindex': noNoninteractiveTabindex,
|
||||||
+ noStaticElementInteractions,
|
+ 'no-onchange': noOnChange,
|
||||||
+ preferTagOverRole,
|
+ 'no-redundant-roles': noRedundantRoles,
|
||||||
+ roleHasRequiredAriaProps,
|
+ 'no-static-element-interactions': noStaticElementInteractions,
|
||||||
+ roleSupportsAriaProps,
|
+ 'prefer-tag-over-role': preferTagOverRole,
|
||||||
|
+ 'role-has-required-aria-props': roleHasRequiredAriaProps,
|
||||||
|
+ 'role-supports-aria-props': roleSupportsAriaProps,
|
||||||
+ scope,
|
+ scope,
|
||||||
+ tabindexNoPositive,
|
+ 'tabindex-no-positive': tabindexNoPositive,
|
||||||
+});
|
|
||||||
+export const configs = {
|
|
||||||
+ recommended: {
|
|
||||||
+ plugins: [
|
|
||||||
+ 'jsx-a11y',
|
|
||||||
+ ],
|
|
||||||
+ parserOptions: {
|
|
||||||
+ ecmaFeatures: {
|
|
||||||
+ jsx: true,
|
|
||||||
+ },
|
|
||||||
+ },
|
|
||||||
+ rules: {
|
|
||||||
+ 'jsx-a11y/alt-text': 'error',
|
|
||||||
+ 'jsx-a11y/anchor-ambiguous-text': 'off', // TODO: error
|
|
||||||
+ 'jsx-a11y/anchor-has-content': 'error',
|
|
||||||
+ 'jsx-a11y/anchor-is-valid': 'error',
|
|
||||||
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
||||||
+ 'jsx-a11y/aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/aria-proptypes': 'error',
|
|
||||||
+ 'jsx-a11y/aria-role': 'error',
|
|
||||||
+ 'jsx-a11y/aria-unsupported-elements': 'error',
|
|
||||||
+ 'jsx-a11y/autocomplete-valid': 'error',
|
|
||||||
+ 'jsx-a11y/click-events-have-key-events': 'error',
|
|
||||||
+ 'jsx-a11y/control-has-associated-label': ['off', {
|
|
||||||
+ ignoreElements: [
|
|
||||||
+ 'audio',
|
|
||||||
+ 'canvas',
|
|
||||||
+ 'embed',
|
|
||||||
+ 'input',
|
|
||||||
+ 'textarea',
|
|
||||||
+ 'tr',
|
|
||||||
+ 'video',
|
|
||||||
+ ],
|
|
||||||
+ ignoreRoles: [
|
|
||||||
+ 'grid',
|
|
||||||
+ 'listbox',
|
|
||||||
+ 'menu',
|
|
||||||
+ 'menubar',
|
|
||||||
+ 'radiogroup',
|
|
||||||
+ 'row',
|
|
||||||
+ 'tablist',
|
|
||||||
+ 'toolbar',
|
|
||||||
+ 'tree',
|
|
||||||
+ 'treegrid',
|
|
||||||
+ ],
|
|
||||||
+ includeRoles: [
|
|
||||||
+ 'alert',
|
|
||||||
+ 'dialog',
|
|
||||||
+ ],
|
|
||||||
+ }],
|
|
||||||
+ 'jsx-a11y/heading-has-content': 'error',
|
|
||||||
+ 'jsx-a11y/html-has-lang': 'error',
|
|
||||||
+ 'jsx-a11y/iframe-has-title': 'error',
|
|
||||||
+ 'jsx-a11y/img-redundant-alt': 'error',
|
|
||||||
+ 'jsx-a11y/interactive-supports-focus': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ tabbable: [
|
|
||||||
+ 'button',
|
|
||||||
+ 'checkbox',
|
|
||||||
+ 'link',
|
|
||||||
+ 'searchbox',
|
|
||||||
+ 'spinbutton',
|
|
||||||
+ 'switch',
|
|
||||||
+ 'textbox',
|
|
||||||
+ ],
|
|
||||||
+ },
|
|
||||||
],
|
|
||||||
- parserOptions: {
|
|
||||||
- ecmaFeatures: {
|
|
||||||
- jsx: true,
|
|
||||||
+ 'jsx-a11y/label-has-associated-control': 'error',
|
|
||||||
+ 'jsx-a11y/label-has-for': 'off',
|
|
||||||
+ 'jsx-a11y/media-has-caption': 'error',
|
|
||||||
+ 'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
||||||
+ 'jsx-a11y/no-access-key': 'error',
|
|
||||||
+ 'jsx-a11y/no-autofocus': 'error',
|
|
||||||
+ 'jsx-a11y/no-distracting-elements': 'error',
|
|
||||||
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ tr: ['none', 'presentation'],
|
|
||||||
+ canvas: ['img'],
|
|
||||||
},
|
|
||||||
- },
|
|
||||||
- rules: {
|
|
||||||
- 'jsx-a11y/alt-text': 'error',
|
|
||||||
- 'jsx-a11y/anchor-ambiguous-text': 'off', // TODO: error
|
|
||||||
- 'jsx-a11y/anchor-has-content': 'error',
|
|
||||||
- 'jsx-a11y/anchor-is-valid': 'error',
|
|
||||||
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
||||||
- 'jsx-a11y/aria-props': 'error',
|
|
||||||
- 'jsx-a11y/aria-proptypes': 'error',
|
|
||||||
- 'jsx-a11y/aria-role': 'error',
|
|
||||||
- 'jsx-a11y/aria-unsupported-elements': 'error',
|
|
||||||
- 'jsx-a11y/autocomplete-valid': 'error',
|
|
||||||
- 'jsx-a11y/click-events-have-key-events': 'error',
|
|
||||||
- 'jsx-a11y/control-has-associated-label': ['off', {
|
|
||||||
- ignoreElements: [
|
|
||||||
- 'audio',
|
|
||||||
- 'canvas',
|
|
||||||
- 'embed',
|
|
||||||
- 'input',
|
|
||||||
- 'textarea',
|
|
||||||
- 'tr',
|
|
||||||
- 'video',
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/no-noninteractive-element-interactions': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ handlers: [
|
|
||||||
+ 'onClick',
|
|
||||||
+ 'onError',
|
|
||||||
+ 'onLoad',
|
|
||||||
+ 'onMouseDown',
|
|
||||||
+ 'onMouseUp',
|
|
||||||
+ 'onKeyPress',
|
|
||||||
+ 'onKeyDown',
|
|
||||||
+ 'onKeyUp',
|
|
||||||
],
|
|
||||||
- ignoreRoles: [
|
|
||||||
- 'grid',
|
|
||||||
+ alert: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
|
|
||||||
+ body: ['onError', 'onLoad'],
|
|
||||||
+ dialog: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
|
|
||||||
+ iframe: ['onError', 'onLoad'],
|
|
||||||
+ img: ['onError', 'onLoad'],
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ ul: [
|
|
||||||
'listbox',
|
|
||||||
'menu',
|
|
||||||
'menubar',
|
|
||||||
'radiogroup',
|
|
||||||
- 'row',
|
|
||||||
'tablist',
|
|
||||||
- 'toolbar',
|
|
||||||
'tree',
|
|
||||||
'treegrid',
|
|
||||||
],
|
|
||||||
- includeRoles: [
|
|
||||||
- 'alert',
|
|
||||||
- 'dialog',
|
|
||||||
- ],
|
|
||||||
- }],
|
|
||||||
- 'jsx-a11y/heading-has-content': 'error',
|
|
||||||
- 'jsx-a11y/html-has-lang': 'error',
|
|
||||||
- 'jsx-a11y/iframe-has-title': 'error',
|
|
||||||
- 'jsx-a11y/img-redundant-alt': 'error',
|
|
||||||
- 'jsx-a11y/interactive-supports-focus': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- tabbable: [
|
|
||||||
- 'button',
|
|
||||||
- 'checkbox',
|
|
||||||
- 'link',
|
|
||||||
- 'searchbox',
|
|
||||||
- 'spinbutton',
|
|
||||||
- 'switch',
|
|
||||||
- 'textbox',
|
|
||||||
- ],
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/label-has-associated-control': 'error',
|
|
||||||
- 'jsx-a11y/label-has-for': 'off',
|
|
||||||
- 'jsx-a11y/media-has-caption': 'error',
|
|
||||||
- 'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
||||||
- 'jsx-a11y/no-access-key': 'error',
|
|
||||||
- 'jsx-a11y/no-autofocus': 'error',
|
|
||||||
- 'jsx-a11y/no-distracting-elements': 'error',
|
|
||||||
- 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- tr: ['none', 'presentation'],
|
|
||||||
- canvas: ['img'],
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/no-noninteractive-element-interactions': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- handlers: [
|
|
||||||
- 'onClick',
|
|
||||||
- 'onError',
|
|
||||||
- 'onLoad',
|
|
||||||
- 'onMouseDown',
|
|
||||||
- 'onMouseUp',
|
|
||||||
- 'onKeyPress',
|
|
||||||
- 'onKeyDown',
|
|
||||||
- 'onKeyUp',
|
|
||||||
- ],
|
|
||||||
- alert: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
|
|
||||||
- body: ['onError', 'onLoad'],
|
|
||||||
- dialog: ['onKeyUp', 'onKeyDown', 'onKeyPress'],
|
|
||||||
- iframe: ['onError', 'onLoad'],
|
|
||||||
- img: ['onError', 'onLoad'],
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/no-noninteractive-element-to-interactive-role': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- ul: [
|
|
||||||
- 'listbox',
|
|
||||||
- 'menu',
|
|
||||||
- 'menubar',
|
|
||||||
- 'radiogroup',
|
|
||||||
- 'tablist',
|
|
||||||
- 'tree',
|
|
||||||
- 'treegrid',
|
|
||||||
- ],
|
|
||||||
- ol: [
|
|
||||||
- 'listbox',
|
|
||||||
- 'menu',
|
|
||||||
- 'menubar',
|
|
||||||
- 'radiogroup',
|
|
||||||
- 'tablist',
|
|
||||||
- 'tree',
|
|
||||||
- 'treegrid',
|
|
||||||
- ],
|
|
||||||
- li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
|
|
||||||
- table: ['grid'],
|
|
||||||
- td: ['gridcell'],
|
|
||||||
- fieldset: ['radiogroup', 'presentation'],
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/no-noninteractive-tabindex': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- tags: [],
|
|
||||||
- roles: ['tabpanel'],
|
|
||||||
- allowExpressionValues: true,
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/no-redundant-roles': 'error',
|
|
||||||
- 'jsx-a11y/no-static-element-interactions': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- allowExpressionValues: true,
|
|
||||||
- handlers: [
|
|
||||||
- 'onClick',
|
|
||||||
- 'onMouseDown',
|
|
||||||
- 'onMouseUp',
|
|
||||||
- 'onKeyPress',
|
|
||||||
- 'onKeyDown',
|
|
||||||
- 'onKeyUp',
|
|
||||||
- ],
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
- 'jsx-a11y/role-has-required-aria-props': 'error',
|
|
||||||
- 'jsx-a11y/role-supports-aria-props': 'error',
|
|
||||||
- 'jsx-a11y/scope': 'error',
|
|
||||||
- 'jsx-a11y/tabindex-no-positive': 'error',
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- strict: {
|
|
||||||
- plugins: [
|
|
||||||
- 'jsx-a11y',
|
|
||||||
- ],
|
|
||||||
- parserOptions: {
|
|
||||||
- ecmaFeatures: {
|
|
||||||
- jsx: true,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- rules: {
|
|
||||||
- 'jsx-a11y/alt-text': 'error',
|
|
||||||
- 'jsx-a11y/anchor-has-content': 'error',
|
|
||||||
- 'jsx-a11y/anchor-is-valid': 'error',
|
|
||||||
- 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
||||||
- 'jsx-a11y/aria-props': 'error',
|
|
||||||
- 'jsx-a11y/aria-proptypes': 'error',
|
|
||||||
- 'jsx-a11y/aria-role': 'error',
|
|
||||||
- 'jsx-a11y/aria-unsupported-elements': 'error',
|
|
||||||
- 'jsx-a11y/autocomplete-valid': 'error',
|
|
||||||
- 'jsx-a11y/click-events-have-key-events': 'error',
|
|
||||||
- 'jsx-a11y/control-has-associated-label': ['off', {
|
|
||||||
- ignoreElements: [
|
|
||||||
- 'audio',
|
|
||||||
- 'canvas',
|
|
||||||
- 'embed',
|
|
||||||
- 'input',
|
|
||||||
- 'textarea',
|
|
||||||
- 'tr',
|
|
||||||
- 'video',
|
|
||||||
- ],
|
|
||||||
- ignoreRoles: [
|
|
||||||
- 'grid',
|
|
||||||
+ ol: [
|
|
||||||
'listbox',
|
|
||||||
'menu',
|
|
||||||
'menubar',
|
|
||||||
'radiogroup',
|
|
||||||
- 'row',
|
|
||||||
'tablist',
|
|
||||||
- 'toolbar',
|
|
||||||
'tree',
|
|
||||||
'treegrid',
|
|
||||||
],
|
|
||||||
- includeRoles: [
|
|
||||||
- 'alert',
|
|
||||||
- 'dialog',
|
|
||||||
+ li: ['menuitem', 'option', 'row', 'tab', 'treeitem'],
|
|
||||||
+ table: ['grid'],
|
|
||||||
+ td: ['gridcell'],
|
|
||||||
+ fieldset: ['radiogroup', 'presentation'],
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/no-noninteractive-tabindex': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ tags: [],
|
|
||||||
+ roles: ['tabpanel'],
|
|
||||||
+ allowExpressionValues: true,
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/no-redundant-roles': 'error',
|
|
||||||
+ 'jsx-a11y/no-static-element-interactions': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ allowExpressionValues: true,
|
|
||||||
+ handlers: [
|
|
||||||
+ 'onClick',
|
|
||||||
+ 'onMouseDown',
|
|
||||||
+ 'onMouseUp',
|
|
||||||
+ 'onKeyPress',
|
|
||||||
+ 'onKeyDown',
|
|
||||||
+ 'onKeyUp',
|
|
||||||
],
|
|
||||||
- }],
|
|
||||||
- 'jsx-a11y/heading-has-content': 'error',
|
|
||||||
- 'jsx-a11y/html-has-lang': 'error',
|
|
||||||
- 'jsx-a11y/iframe-has-title': 'error',
|
|
||||||
- 'jsx-a11y/img-redundant-alt': 'error',
|
|
||||||
- 'jsx-a11y/interactive-supports-focus': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- tabbable: [
|
|
||||||
- 'button',
|
|
||||||
- 'checkbox',
|
|
||||||
- 'link',
|
|
||||||
- 'progressbar',
|
|
||||||
- 'searchbox',
|
|
||||||
- 'slider',
|
|
||||||
- 'spinbutton',
|
|
||||||
- 'switch',
|
|
||||||
- 'textbox',
|
|
||||||
- ],
|
|
||||||
- },
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/role-has-required-aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/role-supports-aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/scope': 'error',
|
|
||||||
+ 'jsx-a11y/tabindex-no-positive': 'error',
|
|
||||||
+ },
|
|
||||||
+ },
|
|
||||||
+ strict: {
|
|
||||||
+ plugins: [
|
|
||||||
+ 'jsx-a11y',
|
|
||||||
+ ],
|
|
||||||
+ parserOptions: {
|
|
||||||
+ ecmaFeatures: {
|
|
||||||
+ jsx: true,
|
|
||||||
+ },
|
|
||||||
+ },
|
|
||||||
+ rules: {
|
|
||||||
+ 'jsx-a11y/alt-text': 'error',
|
|
||||||
+ 'jsx-a11y/anchor-has-content': 'error',
|
|
||||||
+ 'jsx-a11y/anchor-is-valid': 'error',
|
|
||||||
+ 'jsx-a11y/aria-activedescendant-has-tabindex': 'error',
|
|
||||||
+ 'jsx-a11y/aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/aria-proptypes': 'error',
|
|
||||||
+ 'jsx-a11y/aria-role': 'error',
|
|
||||||
+ 'jsx-a11y/aria-unsupported-elements': 'error',
|
|
||||||
+ 'jsx-a11y/autocomplete-valid': 'error',
|
|
||||||
+ 'jsx-a11y/click-events-have-key-events': 'error',
|
|
||||||
+ 'jsx-a11y/control-has-associated-label': ['off', {
|
|
||||||
+ ignoreElements: [
|
|
||||||
+ 'audio',
|
|
||||||
+ 'canvas',
|
|
||||||
+ 'embed',
|
|
||||||
+ 'input',
|
|
||||||
+ 'textarea',
|
|
||||||
+ 'tr',
|
|
||||||
+ 'video',
|
|
||||||
],
|
|
||||||
- 'jsx-a11y/label-has-for': 'off',
|
|
||||||
- 'jsx-a11y/label-has-associated-control': 'error',
|
|
||||||
- 'jsx-a11y/media-has-caption': 'error',
|
|
||||||
- 'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
||||||
- 'jsx-a11y/no-access-key': 'error',
|
|
||||||
- 'jsx-a11y/no-autofocus': 'error',
|
|
||||||
- 'jsx-a11y/no-distracting-elements': 'error',
|
|
||||||
- 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
|
|
||||||
- 'jsx-a11y/no-noninteractive-element-interactions': [
|
|
||||||
- 'error',
|
|
||||||
- {
|
|
||||||
- body: ['onError', 'onLoad'],
|
|
||||||
- iframe: ['onError', 'onLoad'],
|
|
||||||
- img: ['onError', 'onLoad'],
|
|
||||||
- },
|
|
||||||
+ ignoreRoles: [
|
|
||||||
+ 'grid',
|
|
||||||
+ 'listbox',
|
|
||||||
+ 'menu',
|
|
||||||
+ 'menubar',
|
|
||||||
+ 'radiogroup',
|
|
||||||
+ 'row',
|
|
||||||
+ 'tablist',
|
|
||||||
+ 'toolbar',
|
|
||||||
+ 'tree',
|
|
||||||
+ 'treegrid',
|
|
||||||
],
|
|
||||||
- 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
|
|
||||||
- 'jsx-a11y/no-noninteractive-tabindex': 'error',
|
|
||||||
- 'jsx-a11y/no-redundant-roles': 'error',
|
|
||||||
- 'jsx-a11y/no-static-element-interactions': 'error',
|
|
||||||
- 'jsx-a11y/role-has-required-aria-props': 'error',
|
|
||||||
- 'jsx-a11y/role-supports-aria-props': 'error',
|
|
||||||
- 'jsx-a11y/scope': 'error',
|
|
||||||
- 'jsx-a11y/tabindex-no-positive': 'error',
|
|
||||||
- },
|
|
||||||
+ includeRoles: [
|
|
||||||
+ 'alert',
|
|
||||||
+ 'dialog',
|
|
||||||
+ ],
|
|
||||||
+ }],
|
|
||||||
+ 'jsx-a11y/heading-has-content': 'error',
|
|
||||||
+ 'jsx-a11y/html-has-lang': 'error',
|
|
||||||
+ 'jsx-a11y/iframe-has-title': 'error',
|
|
||||||
+ 'jsx-a11y/img-redundant-alt': 'error',
|
|
||||||
+ 'jsx-a11y/interactive-supports-focus': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ tabbable: [
|
|
||||||
+ 'button',
|
|
||||||
+ 'checkbox',
|
|
||||||
+ 'link',
|
|
||||||
+ 'progressbar',
|
|
||||||
+ 'searchbox',
|
|
||||||
+ 'slider',
|
|
||||||
+ 'spinbutton',
|
|
||||||
+ 'switch',
|
|
||||||
+ 'textbox',
|
|
||||||
+ ],
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/label-has-for': 'off',
|
|
||||||
+ 'jsx-a11y/label-has-associated-control': 'error',
|
|
||||||
+ 'jsx-a11y/media-has-caption': 'error',
|
|
||||||
+ 'jsx-a11y/mouse-events-have-key-events': 'error',
|
|
||||||
+ 'jsx-a11y/no-access-key': 'error',
|
|
||||||
+ 'jsx-a11y/no-autofocus': 'error',
|
|
||||||
+ 'jsx-a11y/no-distracting-elements': 'error',
|
|
||||||
+ 'jsx-a11y/no-interactive-element-to-noninteractive-role': 'error',
|
|
||||||
+ 'jsx-a11y/no-noninteractive-element-interactions': [
|
|
||||||
+ 'error',
|
|
||||||
+ {
|
|
||||||
+ body: ['onError', 'onLoad'],
|
|
||||||
+ iframe: ['onError', 'onLoad'],
|
|
||||||
+ img: ['onError', 'onLoad'],
|
|
||||||
+ },
|
|
||||||
+ ],
|
|
||||||
+ 'jsx-a11y/no-noninteractive-element-to-interactive-role': 'error',
|
|
||||||
+ 'jsx-a11y/no-noninteractive-tabindex': 'error',
|
|
||||||
+ 'jsx-a11y/no-redundant-roles': 'error',
|
|
||||||
+ 'jsx-a11y/no-static-element-interactions': 'error',
|
|
||||||
+ 'jsx-a11y/role-has-required-aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/role-supports-aria-props': 'error',
|
|
||||||
+ 'jsx-a11y/scope': 'error',
|
|
||||||
+ 'jsx-a11y/tabindex-no-positive': 'error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
+
|
|
||||||
+/** @param {object} obj */
|
const recommendedRules = {
|
||||||
+function kebabCase(obj) {
|
@@ -299,10 +341,10 @@ const jsxA11y = {
|
||||||
+ return Object.fromEntries(
|
const createConfig = (rules, flatConfigName) => ({
|
||||||
+ Object.entries(obj).map(([key, value]) => [
|
...(flatConfigName
|
||||||
+ key.replace(/([A-Z])/g, '-$1').toLowerCase(),
|
? {
|
||||||
+ value,
|
- ...flatConfigBase,
|
||||||
+ ]),
|
- name: `jsx-a11y/${flatConfigName}`,
|
||||||
+ );
|
- plugins: { 'jsx-a11y': jsxA11y },
|
||||||
+}
|
- }
|
||||||
|
+ ...flatConfigBase,
|
||||||
|
+ name: `jsx-a11y/${flatConfigName}`,
|
||||||
|
+ plugins: { 'jsx-a11y': jsxA11y },
|
||||||
|
+ }
|
||||||
|
: { ...legacyConfigBase, plugins: ['jsx-a11y'] }),
|
||||||
|
rules: { ...rules },
|
||||||
|
});
|
||||||
diff --git a/src/util/mayContainChildComponent.js b/src/util/mayContainChildComponent.js
|
diff --git a/src/util/mayContainChildComponent.js b/src/util/mayContainChildComponent.js
|
||||||
index 43a03ef..5e1035e 100644
|
index 43a03ef..5e1035e 100644
|
||||||
--- a/src/util/mayContainChildComponent.js
|
--- a/src/util/mayContainChildComponent.js
|
||||||
|
@ -27,3 +27,98 @@ index 49fd4c7..a0fdd81 100644
|
|||||||
},
|
},
|
||||||
rules: /** @type {Record<string, import('eslint').Rule.RuleModule>} */ ({
|
rules: /** @type {Record<string, import('eslint').Rule.RuleModule>} */ ({
|
||||||
"callback-return": require("./rules/callback-return"),
|
"callback-return": require("./rules/callback-return"),
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/dependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/dependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/dependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/devDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/noDependencies/node_modules/bbb.js b/tests/fixtures/no-extraneous/noDependencies/node_modules/bbb.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/optionalDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/@bbb/aaa.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/@bbb/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/aaa.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/aaa.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/index.js b/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json b/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json
|
||||||
|
deleted file mode 100644
|
||||||
|
index b7d25e2..0000000
|
||||||
|
--- a/tests/fixtures/no-extraneous/peerDependencies/node_modules/bbb/package.json
|
||||||
|
+++ /dev/null
|
||||||
|
@@ -1,4 +0,0 @@
|
||||||
|
-{
|
||||||
|
- "name": "bbb",
|
||||||
|
- "main": "index.js"
|
||||||
|
-}
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/tests/fixtures/no-hide-core-modules/indirect-thirdparty/node_modules/util/index.js b/tests/fixtures/no-hide-core-modules/indirect-thirdparty/node_modules/util/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
diff --git a/tests/fixtures/no-hide-core-modules/thirdparty/node_modules/util/index.js b/tests/fixtures/no-hide-core-modules/thirdparty/node_modules/util/index.js
|
||||||
|
deleted file mode 100644
|
||||||
|
index e69de29..0000000
|
||||||
|
@ -1,336 +0,0 @@
|
|||||||
diff --git a/.eslintrc b/.eslintrc
|
|
||||||
deleted file mode 100644
|
|
||||||
index 4991f200..00000000
|
|
||||||
--- a/.eslintrc
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,82 +0,0 @@
|
|
||||||
-{
|
|
||||||
- "root": true,
|
|
||||||
- "extends": ["airbnb-base", "plugin:eslint-plugin/recommended"],
|
|
||||||
- "plugins": ["eslint-plugin"],
|
|
||||||
- "env": {
|
|
||||||
- "es6": true,
|
|
||||||
- "node": true
|
|
||||||
- },
|
|
||||||
- "parserOptions": {
|
|
||||||
- "ecmaVersion": 6,
|
|
||||||
- "ecmaFeatures": {
|
|
||||||
- "jsx": true
|
|
||||||
- },
|
|
||||||
- "sourceType": "script",
|
|
||||||
- },
|
|
||||||
- "ignorePatterns": [
|
|
||||||
- "coverage/",
|
|
||||||
- ".nyc_output/",
|
|
||||||
- ],
|
|
||||||
- "rules": {
|
|
||||||
- "comma-dangle": [2, "always-multiline"],
|
|
||||||
- "object-shorthand": [2, "always", {
|
|
||||||
- "ignoreConstructors": false,
|
|
||||||
- "avoidQuotes": false, // this is the override vs airbnb
|
|
||||||
- }],
|
|
||||||
- "max-len": [2, 120, {
|
|
||||||
- "ignoreStrings": true,
|
|
||||||
- "ignoreTemplateLiterals": true,
|
|
||||||
- "ignoreComments": true,
|
|
||||||
- }],
|
|
||||||
- "consistent-return": 0,
|
|
||||||
-
|
|
||||||
- "prefer-destructuring": [2, { "array": false, "object": false }, { "enforceForRenamedProperties": false }],
|
|
||||||
- "prefer-object-spread": 0, // until node 8 is required
|
|
||||||
- "prefer-rest-params": 0, // until node 6 is required
|
|
||||||
- "prefer-spread": 0, // until node 6 is required
|
|
||||||
- "function-call-argument-newline": 1, // TODO: enable
|
|
||||||
- "function-paren-newline": 0,
|
|
||||||
- "no-plusplus": [2, {"allowForLoopAfterthoughts": true}],
|
|
||||||
- "no-param-reassign": 1,
|
|
||||||
- "no-restricted-syntax": [2, {
|
|
||||||
- "selector": "ObjectPattern",
|
|
||||||
- "message": "Object destructuring is not compatible with Node v4"
|
|
||||||
- }],
|
|
||||||
- "strict": [2, "safe"],
|
|
||||||
- "valid-jsdoc": [2, {
|
|
||||||
- "requireReturn": false,
|
|
||||||
- "requireParamDescription": false,
|
|
||||||
- "requireReturnDescription": false,
|
|
||||||
- }],
|
|
||||||
-
|
|
||||||
- "eslint-plugin/consistent-output": 0,
|
|
||||||
- "eslint-plugin/require-meta-docs-description": [2, { "pattern": "^(Enforce|Require|Disallow)" }],
|
|
||||||
- "eslint-plugin/require-meta-schema": 0,
|
|
||||||
- "eslint-plugin/require-meta-type": 0
|
|
||||||
- },
|
|
||||||
- "overrides": [
|
|
||||||
- {
|
|
||||||
- "files": "tests/**",
|
|
||||||
- "rules": {
|
|
||||||
- "no-template-curly-in-string": 1,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- {
|
|
||||||
- "files": "markdown.config.js",
|
|
||||||
- "rules": {
|
|
||||||
- "no-console": 0,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- {
|
|
||||||
- "files": ".github/workflows/*.js",
|
|
||||||
- "parserOptions": {
|
|
||||||
- "ecmaVersion": 2019,
|
|
||||||
- },
|
|
||||||
- "rules": {
|
|
||||||
- "camelcase": 0,
|
|
||||||
- "no-console": 0,
|
|
||||||
- "no-restricted-syntax": 0,
|
|
||||||
- },
|
|
||||||
- },
|
|
||||||
- ],
|
|
||||||
-}
|
|
||||||
diff --git a/index.js b/index.js
|
|
||||||
index 4140c6c8..03e623af 100644
|
|
||||||
--- a/index.js
|
|
||||||
+++ b/index.js
|
|
||||||
@@ -1,31 +1,25 @@
|
|
||||||
-'use strict';
|
|
||||||
-
|
|
||||||
-const configAll = require('./configs/all');
|
|
||||||
-const configRecommended = require('./configs/recommended');
|
|
||||||
-const configRuntime = require('./configs/jsx-runtime');
|
|
||||||
-
|
|
||||||
-const allRules = require('./lib/rules');
|
|
||||||
+import configAll from './configs/all';
|
|
||||||
+import configRecommended from './configs/recommended';
|
|
||||||
+import configRuntime from './configs/jsx-runtime';
|
|
||||||
+import { name } from './package.json';
|
|
||||||
+export { default as rules } from './lib/rules';
|
|
||||||
|
|
||||||
// for legacy config system
|
|
||||||
-const plugins = [
|
|
||||||
- 'react',
|
|
||||||
-];
|
|
||||||
+const plugins = [name];
|
|
||||||
+
|
|
||||||
+export const deprecatedRules = configAll.plugins.react.deprecatedRules;
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
- deprecatedRules: configAll.plugins.react.deprecatedRules,
|
|
||||||
- rules: allRules,
|
|
||||||
- configs: {
|
|
||||||
- recommended: Object.assign({}, configRecommended, {
|
|
||||||
- parserOptions: configRecommended.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- all: Object.assign({}, configAll, {
|
|
||||||
- parserOptions: configAll.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- 'jsx-runtime': Object.assign({}, configRuntime, {
|
|
||||||
- parserOptions: configRuntime.languageOptions.parserOptions,
|
|
||||||
- plugins,
|
|
||||||
- }),
|
|
||||||
- },
|
|
||||||
+export const configs = {
|
|
||||||
+ recommended: Object.assign({}, configRecommended, {
|
|
||||||
+ parserOptions: configRecommended.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
+ all: Object.assign({}, configAll, {
|
|
||||||
+ parserOptions: configAll.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
+ 'jsx-runtime': Object.assign({}, configRuntime, {
|
|
||||||
+ parserOptions: configRuntime.languageOptions.parserOptions,
|
|
||||||
+ plugins,
|
|
||||||
+ }),
|
|
||||||
};
|
|
||||||
diff --git a/lib/rules/button-has-type.js b/lib/rules/button-has-type.js
|
|
||||||
index 204a33c4..01d992c2 100644
|
|
||||||
--- a/lib/rules/button-has-type.js
|
|
||||||
+++ b/lib/rules/button-has-type.js
|
|
||||||
@@ -5,8 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const getProp = require('jsx-ast-utils/getProp');
|
|
||||||
-const getLiteralPropValue = require('jsx-ast-utils/getLiteralPropValue');
|
|
||||||
+const { getProp, getLiteralPropValue } = require('jsx-ast-utils');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const isCreateElement = require('../util/isCreateElement');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/jsx-fragments.js b/lib/rules/jsx-fragments.js
|
|
||||||
index 38b4dd8b..d0575572 100644
|
|
||||||
--- a/lib/rules/jsx-fragments.js
|
|
||||||
+++ b/lib/rules/jsx-fragments.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const pragmaUtil = require('../util/pragma');
|
|
||||||
const variableUtil = require('../util/variable');
|
|
||||||
const testReactVersion = require('../util/version').testReactVersion;
|
|
||||||
diff --git a/lib/rules/jsx-key.js b/lib/rules/jsx-key.js
|
|
||||||
index 7ea874d0..48df0dba 100644
|
|
||||||
--- a/lib/rules/jsx-key.js
|
|
||||||
+++ b/lib/rules/jsx-key.js
|
|
||||||
@@ -5,8 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const hasProp = require('jsx-ast-utils/hasProp');
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { hasProp, propName } from 'jsx-ast-utils';
|
|
||||||
const values = require('object.values');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const pragmaUtil = require('../util/pragma');
|
|
||||||
diff --git a/lib/rules/jsx-no-bind.js b/lib/rules/jsx-no-bind.js
|
|
||||||
index 17e56e2e..cb6dec1a 100644
|
|
||||||
--- a/lib/rules/jsx-no-bind.js
|
|
||||||
+++ b/lib/rules/jsx-no-bind.js
|
|
||||||
@@ -7,7 +7,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { propName } from 'jsx-ast-utils';
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const jsxUtil = require('../util/jsx');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/jsx-pascal-case.js b/lib/rules/jsx-pascal-case.js
|
|
||||||
index efeef403..33df4653 100644
|
|
||||||
--- a/lib/rules/jsx-pascal-case.js
|
|
||||||
+++ b/lib/rules/jsx-pascal-case.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const minimatch = require('minimatch');
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const jsxUtil = require('../util/jsx');
|
|
||||||
diff --git a/lib/rules/jsx-sort-props.js b/lib/rules/jsx-sort-props.js
|
|
||||||
index 3ca1724e..faf58f91 100644
|
|
||||||
--- a/lib/rules/jsx-sort-props.js
|
|
||||||
+++ b/lib/rules/jsx-sort-props.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const propName = require('jsx-ast-utils/propName');
|
|
||||||
+import { propName } from 'jsx-ast-utils';
|
|
||||||
const includes = require('array-includes');
|
|
||||||
const toSorted = require('array.prototype.tosorted');
|
|
||||||
|
|
||||||
diff --git a/lib/rules/no-namespace.js b/lib/rules/no-namespace.js
|
|
||||||
index d7559f5e..fbfad23a 100644
|
|
||||||
--- a/lib/rules/no-namespace.js
|
|
||||||
+++ b/lib/rules/no-namespace.js
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
const docsUrl = require('../util/docsUrl');
|
|
||||||
const isCreateElement = require('../util/isCreateElement');
|
|
||||||
const report = require('../util/report');
|
|
||||||
diff --git a/lib/rules/no-unknown-property.js b/lib/rules/no-unknown-property.js
|
|
||||||
index 9491f9c6..44396948 100644
|
|
||||||
--- a/lib/rules/no-unknown-property.js
|
|
||||||
+++ b/lib/rules/no-unknown-property.js
|
|
||||||
@@ -543,7 +543,7 @@ module.exports = {
|
|
||||||
|
|
||||||
create(context) {
|
|
||||||
function getIgnoreConfig() {
|
|
||||||
- return (context.options[0] && context.options[0].ignore) || DEFAULTS.ignore;
|
|
||||||
+ return context.options[0]?.ignore || DEFAULTS.ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRequireDataLowercase() {
|
|
||||||
@@ -556,7 +556,7 @@ module.exports = {
|
|
||||||
JSXAttribute(node) {
|
|
||||||
const ignoreNames = getIgnoreConfig();
|
|
||||||
const actualName = context.getSourceCode().getText(node.name);
|
|
||||||
- if (ignoreNames.indexOf(actualName) >= 0) {
|
|
||||||
+ if (ignoreNames.includes(actualName)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const name = normalizeAttributeCase(actualName);
|
|
||||||
diff --git a/lib/util/annotations.js b/lib/util/annotations.js
|
|
||||||
index 60aaef8c..ad8dc0bf 100644
|
|
||||||
--- a/lib/util/annotations.js
|
|
||||||
+++ b/lib/util/annotations.js
|
|
||||||
@@ -27,6 +27,6 @@ function isAnnotatedFunctionPropsDeclaration(node, context) {
|
|
||||||
return (isAnnotated && (isDestructuredProps || isProps));
|
|
||||||
}
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
+export {
|
|
||||||
isAnnotatedFunctionPropsDeclaration,
|
|
||||||
};
|
|
||||||
diff --git a/lib/util/ast.js b/lib/util/ast.js
|
|
||||||
index fd6019a3..3cbc293e 100644
|
|
||||||
--- a/lib/util/ast.js
|
|
||||||
+++ b/lib/util/ast.js
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const estraverse = require('estraverse');
|
|
||||||
+import estraverse from 'estraverse';
|
|
||||||
// const pragmaUtil = require('./pragma');
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -428,7 +428,7 @@ function isTSTypeParameterInstantiation(node) {
|
|
||||||
return nodeType === 'TSTypeParameterInstantiation';
|
|
||||||
}
|
|
||||||
|
|
||||||
-module.exports = {
|
|
||||||
+export {
|
|
||||||
traverse,
|
|
||||||
findReturnStatement,
|
|
||||||
getFirstNodeInLine,
|
|
||||||
diff --git a/lib/util/jsx.js b/lib/util/jsx.js
|
|
||||||
index 55073bfe..efc07af1 100644
|
|
||||||
--- a/lib/util/jsx.js
|
|
||||||
+++ b/lib/util/jsx.js
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
-const elementType = require('jsx-ast-utils/elementType');
|
|
||||||
+import { elementType } from 'jsx-ast-utils';
|
|
||||||
|
|
||||||
const astUtil = require('./ast');
|
|
||||||
const isCreateElement = require('./isCreateElement');
|
|
||||||
diff --git a/tsconfig.json b/tsconfig.json
|
|
||||||
deleted file mode 100644
|
|
||||||
index 39187b7f..00000000
|
|
||||||
--- a/tsconfig.json
|
|
||||||
+++ /dev/null
|
|
||||||
@@ -1,23 +0,0 @@
|
|
||||||
-{
|
|
||||||
- "compilerOptions": {
|
|
||||||
- "target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
||||||
- "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
||||||
- // "lib": ["es2015"], /* Specify library files to be included in the compilation. */
|
|
||||||
- "allowJs": true, /* Allow javascript files to be compiled. */
|
|
||||||
- "checkJs": true, /* Report errors in .js files. */
|
|
||||||
- "noEmit": true, /* Do not emit outputs. */
|
|
||||||
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
-
|
|
||||||
- /* Strict Type-Checking Options */
|
|
||||||
- // "strict": true, /* Enable all strict type-checking options. */
|
|
||||||
- "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
||||||
- // "strictNullChecks": true, /* Enable strict null checks. */
|
|
||||||
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
||||||
- "strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
||||||
- "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
||||||
- "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
||||||
- "alwaysStrict": false, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
||||||
- "resolveJsonModule": true
|
|
||||||
- },
|
|
||||||
- "include": ["lib"],
|
|
||||||
-}
|
|
5386
pnpm-lock.yaml
generated
5386
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -7,7 +7,7 @@ import type { Plugin } from 'esbuild';
|
|||||||
import { memoize } from 'lodash';
|
import { memoize } from 'lodash';
|
||||||
import { gray, green } from 'picocolors';
|
import { gray, green } from 'picocolors';
|
||||||
import { dependencies } from '../dist/package.json';
|
import { dependencies } from '../dist/package.json';
|
||||||
import { buildLocalRules } from '../src/build-local-rules';
|
import { buildLocalRules } from './build-local-rules';
|
||||||
import { dts } from './dts';
|
import { dts } from './dts';
|
||||||
import { babelPlugin } from './modifier';
|
import { babelPlugin } from './modifier';
|
||||||
|
|
||||||
@ -134,8 +134,6 @@ async function main() {
|
|||||||
|
|
||||||
console.log('Building packages...');
|
console.log('Building packages...');
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
bundle('./packages/eslint-plugin-react/index.js'),
|
|
||||||
bundle('./packages/eslint-plugin-import/src/index.js'),
|
|
||||||
bundle('./packages/eslint-plugin-jsx-a11y/src/index.js'),
|
bundle('./packages/eslint-plugin-jsx-a11y/src/index.js'),
|
||||||
bundle('./packages/eslint-plugin-react-hooks/index.ts'),
|
bundle('./packages/eslint-plugin-react-hooks/index.ts'),
|
||||||
bundle('./packages/eslint-plugin-n/lib/index.js', './dist/eslint-plugin-n/index.js'),
|
bundle('./packages/eslint-plugin-n/lib/index.js', './dist/eslint-plugin-n/index.js'),
|
||||||
|
@ -18,11 +18,6 @@ export function dts({
|
|||||||
filePath: source,
|
filePath: source,
|
||||||
failOnClass: false,
|
failOnClass: false,
|
||||||
output: {
|
output: {
|
||||||
inlineDeclareExternals: false,
|
|
||||||
inlineDeclareGlobals: false,
|
|
||||||
sortNodes: false,
|
|
||||||
noBanner: false,
|
|
||||||
respectPreserveConstEnum: false,
|
|
||||||
exportReferencedTypes: true,
|
exportReferencedTypes: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,25 +1,15 @@
|
|||||||
#!/usr/bin/env tsx
|
#!/usr/bin/env tsx
|
||||||
import assert from 'node:assert';
|
import assert from 'node:assert';
|
||||||
import { readFileSync, promises as fs } from 'node:fs';
|
import { readFileSync } from 'node:fs';
|
||||||
import { resolve, extname, relative } from 'node:path';
|
import { resolve, extname } from 'node:path';
|
||||||
import { isBuiltin } from 'node:module';
|
|
||||||
import esbuild from 'esbuild';
|
|
||||||
import type { Loader, Plugin } from 'esbuild';
|
import type { Loader, Plugin } from 'esbuild';
|
||||||
import * as babel from '@babel/core';
|
import * as babel from '@babel/core';
|
||||||
import { memoize } from 'lodash';
|
|
||||||
import { gray, green } from 'picocolors';
|
|
||||||
import type { types as t, types } from '@babel/core';
|
import type { types as t, types } from '@babel/core';
|
||||||
import { dependencies } from '../dist/package.json';
|
|
||||||
import { createMacro, type MacroHandler } from 'babel-plugin-macros';
|
import { createMacro, type MacroHandler } from 'babel-plugin-macros';
|
||||||
import * as polyfill from '../src/polyfill';
|
import * as polyfill from '../src/polyfill';
|
||||||
import { buildLocalRules } from '../src/build-local-rules';
|
|
||||||
import { dts } from './dts';
|
|
||||||
|
|
||||||
const polyfills = Object.keys(polyfill);
|
const polyfills = Object.keys(polyfill);
|
||||||
|
|
||||||
const ENV = (process.env.NODE_ENV ??= 'production');
|
|
||||||
const PROD = ENV === 'production';
|
|
||||||
|
|
||||||
class HandlerMap {
|
class HandlerMap {
|
||||||
map = new Map<string, MacroHandler>();
|
map = new Map<string, MacroHandler>();
|
||||||
|
|
||||||
|
@ -21,8 +21,6 @@ pull() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pull import-js eslint-import-resolver-typescript
|
pull import-js eslint-import-resolver-typescript
|
||||||
pull import-js eslint-plugin-import
|
|
||||||
pull jsx-eslint eslint-plugin-jsx-a11y
|
pull jsx-eslint eslint-plugin-jsx-a11y
|
||||||
pull eslint-community eslint-plugin-n
|
pull eslint-community eslint-plugin-n
|
||||||
pull jsx-eslint eslint-plugin-react
|
|
||||||
pull jsx-eslint jsx-ast-utils
|
pull jsx-eslint jsx-ast-utils
|
||||||
|
@ -4,8 +4,6 @@ sync() (
|
|||||||
)
|
)
|
||||||
|
|
||||||
sync eslint-import-resolver-typescript
|
sync eslint-import-resolver-typescript
|
||||||
sync eslint-plugin-import
|
|
||||||
sync eslint-plugin-jsx-a11y
|
sync eslint-plugin-jsx-a11y
|
||||||
sync eslint-plugin-n
|
sync eslint-plugin-n
|
||||||
sync eslint-plugin-react
|
|
||||||
sync jsx-ast-utils
|
sync jsx-ast-utils
|
||||||
|
@ -1,33 +1,33 @@
|
|||||||
{
|
{
|
||||||
"eslint-plugin-import": {
|
"eslint-plugin-import": {
|
||||||
"hash": "f77ceb679d59ced5d9a633123385470a9eea10d9",
|
"hash": "6554bd5c30976290024cecc44ef1e96746cf3cf7",
|
||||||
"date": "2024-04-07T12:55:28+12:00",
|
"date": "2024-05-23T12:47:41-07:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[actions] cancel in-progress runs on PR updates"
|
"subject": "[meta] add `repository.directory` field"
|
||||||
},
|
},
|
||||||
"eslint-import-resolver-typescript": {
|
"eslint-import-resolver-typescript": {
|
||||||
"hash": "7a02ac08b5aaac8c217f0e87142f97eafcc38fbc",
|
"hash": "c9b5626ee69bd529c7e391e40928a4fb28dce179",
|
||||||
"date": "2024-04-01T01:06:20+00:00",
|
"date": "2024-07-23T20:40:14+08:00",
|
||||||
"committer": "GitHub",
|
"committer": "GitHub",
|
||||||
"subject": "chore(deps): update dependency npm-run-all2 to ^5.0.2 (#277)"
|
"subject": "chore: release eslint-import-resolver-typescript (#302)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-jsx-a11y": {
|
"eslint-plugin-jsx-a11y": {
|
||||||
"hash": "0d5321a5457c5f0da0ca216053cc5b4f571b53ae",
|
"hash": "cca288b73a39fa0932a57c02a7a88de68fc971fc",
|
||||||
"date": "2024-01-27T22:18:19-08:00",
|
"date": "2024-07-22T02:39:43+01:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[Deps] update `@babel/runtime`, `safe-regex-test`"
|
"subject": "[readme] fix typo in shareable config section in readme"
|
||||||
},
|
},
|
||||||
"eslint-plugin-n": {
|
"eslint-plugin-n": {
|
||||||
"hash": "8d711f5446655c9874aeffb2ef28b3c4d8463fb6",
|
"hash": "6744257b43560181412a76eadeb7de564b886ad4",
|
||||||
"date": "2024-04-16T16:08:04+08:00",
|
"date": "2024-07-26T11:46:54+01:00",
|
||||||
"committer": "GitHub",
|
"committer": "GitHub",
|
||||||
"subject": "chore: update outdated funding (#246)"
|
"subject": "chore(master): release 17.10.1 (#319)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-react": {
|
"eslint-plugin-react": {
|
||||||
"hash": "4467db503e38b9356517cf6926d11be544ccf4b1",
|
"hash": "983b88dd3cb5e07919517d3fde4085f60883ded7",
|
||||||
"date": "2024-03-16T12:54:58+09:00",
|
"date": "2024-07-24T15:26:33-07:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[Fix] `boolean-prop-naming`: avoid a crash with a non-TSTypeReference type"
|
"subject": "[Tests] `no-array-index-key`: actually run valid tests"
|
||||||
},
|
},
|
||||||
"jsx-ast-utils": {
|
"jsx-ast-utils": {
|
||||||
"hash": "5943318eaf23764eec3ff397ebb969613d728a95",
|
"hash": "5943318eaf23764eec3ff397ebb969613d728a95",
|
||||||
|
39
src/env.ts
Normal file
39
src/env.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import * as fs from 'node:fs';
|
||||||
|
import { resolve } from 'node:path';
|
||||||
|
import { Middleware, storybook } from './index';
|
||||||
|
import { react, reactRefresh } from './presets/react';
|
||||||
|
import { tailwind } from './presets/tailwind';
|
||||||
|
import { reactQuery } from './presets/misc';
|
||||||
|
|
||||||
|
export function* checkEnv(): Generator<Middleware> {
|
||||||
|
const rootDir = process.cwd();
|
||||||
|
|
||||||
|
const pkgJsonPath = resolve(rootDir, 'package.json');
|
||||||
|
const pkgJson = fs.existsSync(pkgJsonPath)
|
||||||
|
? JSON.parse(fs.readFileSync(pkgJsonPath, 'utf-8'))
|
||||||
|
: {};
|
||||||
|
|
||||||
|
const deps = new Set(
|
||||||
|
Object.keys({
|
||||||
|
...pkgJson.dependencies,
|
||||||
|
...pkgJson.devDependencies,
|
||||||
|
...pkgJson.peerDependencies,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (deps.has('react')) {
|
||||||
|
yield react;
|
||||||
|
}
|
||||||
|
if (deps.has('@vitejs/plugin-react') && deps.has('eslint-plugin-react-refresh')) {
|
||||||
|
yield reactRefresh;
|
||||||
|
}
|
||||||
|
if (deps.has('tailwindcss') && deps.has('eslint-plugin-tailwindcss')) {
|
||||||
|
yield tailwind;
|
||||||
|
}
|
||||||
|
if (deps.has('storybook') && deps.has('eslint-plugin-storybook')) {
|
||||||
|
yield storybook;
|
||||||
|
}
|
||||||
|
if (deps.has('@tanstack/react-query') && deps.has('@tanstack/eslint-plugin-query')) {
|
||||||
|
yield reactQuery;
|
||||||
|
}
|
||||||
|
}
|
216
src/index.ts
216
src/index.ts
@ -1,20 +1,30 @@
|
|||||||
/// <reference path="./modules.d.ts" />
|
/// <reference path="./modules.d.ts" />
|
||||||
import './redirect';
|
import './redirect';
|
||||||
import fs from 'node:fs';
|
import { uniq } from 'lodash';
|
||||||
|
import type { Merge, SetRequired } from 'type-fest';
|
||||||
import type { Rule } from 'eslint';
|
import type { Rule } from 'eslint';
|
||||||
import type { ESLintUtils } from '@typescript-eslint/utils';
|
import type { ESLintUtils } from '@typescript-eslint/utils';
|
||||||
import type { ESLintConfig, Rules } from 'eslint-define-config';
|
import type {
|
||||||
// import findCacheDirectory from 'find-cache-dir';
|
ESLintConfig,
|
||||||
import { typescriptRules } from './presets/typescript';
|
Extends,
|
||||||
import { unicornRules } from './presets/unicorn';
|
KnownExtends,
|
||||||
|
Plugin,
|
||||||
|
Rules,
|
||||||
|
Settings,
|
||||||
|
} from '@aet/eslint-define-config';
|
||||||
|
|
||||||
|
import { importTypeScript } from './presets/typescript';
|
||||||
|
import { unicorn } from './presets/unicorn';
|
||||||
import { eslintRules } from './presets/eslint';
|
import { eslintRules } from './presets/eslint';
|
||||||
import { reactRules } from './presets/react';
|
import { local } from './presets/local';
|
||||||
import { importRules } from './presets/import';
|
|
||||||
import { jsDocRules } from './presets/jsdoc';
|
|
||||||
import { graphqlRules } from './presets/graphql';
|
|
||||||
import { localRules } from './presets/local';
|
|
||||||
import { error, warn, off } from './constants';
|
import { error, warn, off } from './constants';
|
||||||
import { tailwindRules } from './presets/tailwind';
|
import { checkEnv } from './env';
|
||||||
|
|
||||||
|
export { graphql } from './presets/graphql';
|
||||||
|
export { jsdoc } from './presets/jsdoc';
|
||||||
|
export { storybook } from './presets/misc';
|
||||||
|
export { react, reactRefresh } from './presets/react';
|
||||||
|
export { tailwind } from './presets/tailwind';
|
||||||
|
|
||||||
export { error, warn, off };
|
export { error, warn, off };
|
||||||
|
|
||||||
@ -36,12 +46,6 @@ const ensureArray = <T>(value?: T | T[]): T[] =>
|
|||||||
type RuleLevel = 'error' | 'warn' | 'off' | 0 | 1 | 2;
|
type RuleLevel = 'error' | 'warn' | 'off' | 0 | 1 | 2;
|
||||||
type RuleEntry<Options> = RuleLevel | [RuleLevel, Partial<Options>];
|
type RuleEntry<Options> = RuleLevel | [RuleLevel, Partial<Options>];
|
||||||
|
|
||||||
declare module 'eslint-define-config/src/rules/react/no-unknown-property.d.ts' {
|
|
||||||
export interface NoUnknownPropertyOption {
|
|
||||||
extends: ('next' | 'emotion')[];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LocalRuleOptions {
|
export interface LocalRuleOptions {
|
||||||
/** Bans import from the specifier '.' and '..' and replaces it with '.+/index' */
|
/** Bans import from the specifier '.' and '..' and replaces it with '.+/index' */
|
||||||
'rules/no-import-dot': RuleEntry<unknown>;
|
'rules/no-import-dot': RuleEntry<unknown>;
|
||||||
@ -63,6 +67,8 @@ export interface CustomRule {
|
|||||||
options?: RuleLevel;
|
options?: RuleLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Middleware = (config: MiddlewareConfig, helpers: MiddlewareFunctions) => void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ESLint Configuration.
|
* ESLint Configuration.
|
||||||
* @see [ESLint Configuration](https://eslint.org/docs/latest/user-guide/configuring/)
|
* @see [ESLint Configuration](https://eslint.org/docs/latest/user-guide/configuring/)
|
||||||
@ -72,7 +78,7 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
* Rules.
|
* Rules.
|
||||||
* @see [Rules](https://eslint.org/docs/latest/user-guide/configuring/rules)
|
* @see [Rules](https://eslint.org/docs/latest/user-guide/configuring/rules)
|
||||||
*/
|
*/
|
||||||
rules?: RuleOptions;
|
rules?: Partial<RuleOptions>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Glob pattern to find paths to custom rule files in JavaScript or TypeScript.
|
* Glob pattern to find paths to custom rule files in JavaScript or TypeScript.
|
||||||
@ -80,12 +86,38 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
* this is statically analyzed.
|
* this is statically analyzed.
|
||||||
*/
|
*/
|
||||||
customRuleFiles?: string | string[];
|
customRuleFiles?: string | string[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically detect project types, dependencies and deduct the plugins.
|
||||||
|
*/
|
||||||
|
auto?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type OptionalObjectKey<T> = Exclude<
|
||||||
|
{
|
||||||
|
[Key in keyof T]: undefined | any[] extends T[Key]
|
||||||
|
? Key
|
||||||
|
: undefined | Record<any, any> extends T[Key]
|
||||||
|
? Key
|
||||||
|
: never;
|
||||||
|
}[keyof T],
|
||||||
|
undefined
|
||||||
|
>;
|
||||||
|
|
||||||
|
type MiddlewareConfig = Merge<
|
||||||
|
SetRequired<ESLintConfig, OptionalObjectKey<ESLintConfig>>,
|
||||||
|
{ extends: KnownExtends[] }
|
||||||
|
>;
|
||||||
|
|
||||||
|
interface MiddlewareFunctions {
|
||||||
|
addRules(rules: Partial<RuleOptions>): void;
|
||||||
|
addSettings(settings: Partial<Settings>): void;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a ESLint config object.
|
* Returns a ESLint config object.
|
||||||
*
|
*
|
||||||
* By default, it includes `["@typescript-eslint", "import", "prettier"]` configs.
|
* By default, it includes `["@typescript-eslint", "import-x", "prettier", "unicorn"]` configs.
|
||||||
* Additional bundled plugins include:
|
* Additional bundled plugins include:
|
||||||
*
|
*
|
||||||
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
* 1. [`react`](https://github.com/jsx-eslint/eslint-plugin-react#list-of-supported-rules)
|
||||||
@ -94,128 +126,82 @@ export type InputConfig = Omit<ESLintConfig, 'rules'> & {
|
|||||||
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
* 2. [`react-refresh`](https://github.com/ArnaudBarre/eslint-plugin-react-refresh)
|
||||||
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
* 3. [`jsx-a11y`](https://github.com/jsx-eslint/eslint-plugin-jsx-a11y#supported-rules)
|
||||||
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
* 4. [`unicorn`](https://github.com/sindresorhus/eslint-plugin-unicorn#rules)
|
||||||
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific)
|
* 5. [`n`](https://github.com/eslint-community/eslint-plugin-n#-rules) (Node.js specific,
|
||||||
|
* requires `minimatch`)
|
||||||
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
* 6. [`jsdoc`](https://github.com/gajus/eslint-plugin-jsdoc#rules)
|
||||||
*
|
*
|
||||||
* Non bundled:
|
* Non bundled:
|
||||||
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
||||||
*/
|
*/
|
||||||
export function extendConfig(of: InputConfig = {}): ESLintConfig {
|
export function extendConfig(
|
||||||
|
of: InputConfig & {
|
||||||
|
middlewares: Middleware[];
|
||||||
|
} = {
|
||||||
|
middlewares: [],
|
||||||
|
},
|
||||||
|
): ESLintConfig {
|
||||||
const {
|
const {
|
||||||
plugins = [],
|
auto = true,
|
||||||
settings,
|
plugins: _plugins = [],
|
||||||
|
settings = {},
|
||||||
rules,
|
rules,
|
||||||
extends: _extends,
|
extends: _extends,
|
||||||
overrides,
|
overrides,
|
||||||
customRuleFiles,
|
customRuleFiles,
|
||||||
|
parserOptions,
|
||||||
|
middlewares: _middlewares = [],
|
||||||
|
// @ts-expect-error
|
||||||
|
localRules: _,
|
||||||
...rest
|
...rest
|
||||||
} = of;
|
} = of;
|
||||||
|
|
||||||
const hasReact = plugins.includes('react');
|
let plugins: Plugin[] = [..._plugins];
|
||||||
const hasReactRefresh = plugins.includes('react-refresh');
|
let extend: Extends[] = ensureArray(_extends);
|
||||||
const hasUnicorn = plugins.includes('unicorn');
|
|
||||||
const hasJsDoc = plugins.includes('jsdoc');
|
|
||||||
const hasGraphQL = plugins.includes('@graphql-eslint');
|
|
||||||
const hasNext = ensureArray(_extends).some(name => name.includes(':@next/next'));
|
|
||||||
const hasTailwind = ensureArray(_extends).some(name =>
|
|
||||||
name.includes('plugin:tailwindcss/'),
|
|
||||||
);
|
|
||||||
|
|
||||||
const ruleDir = false; // ?? findCacheDirectory({ name: '_eslint-rules' });
|
const middlewares: Middleware[] = uniq([
|
||||||
if (ruleDir) {
|
importTypeScript,
|
||||||
fs.rmSync(ruleDir, { recursive: true, force: true });
|
unicorn,
|
||||||
fs.mkdirSync(ruleDir, { recursive: true });
|
local,
|
||||||
}
|
...(auto ? checkEnv() : []),
|
||||||
|
..._middlewares,
|
||||||
|
]);
|
||||||
|
|
||||||
const result: InputConfig = {
|
const result: MiddlewareConfig = {
|
||||||
root: true,
|
root: true,
|
||||||
parser: '@typescript-eslint/parser',
|
plugins: unique('rules', plugins),
|
||||||
plugins: unique('@typescript-eslint', 'import', 'rules', plugins),
|
|
||||||
env: { node: true, browser: true, es2023: true },
|
env: { node: true, browser: true, es2023: true },
|
||||||
reportUnusedDisableDirectives: true,
|
reportUnusedDisableDirectives: true,
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: true,
|
project: true,
|
||||||
|
...parserOptions,
|
||||||
},
|
},
|
||||||
extends: unique(
|
ignorePatterns: [],
|
||||||
'eslint:recommended',
|
globals: {},
|
||||||
'prettier',
|
extends: ['eslint:recommended', 'prettier', ...(extend as string[])],
|
||||||
'plugin:@typescript-eslint/recommended-type-checked',
|
settings,
|
||||||
'plugin:import/errors',
|
|
||||||
'plugin:import/typescript',
|
|
||||||
hasReact && [
|
|
||||||
'plugin:react/recommended',
|
|
||||||
'plugin:react-hooks/recommended',
|
|
||||||
'plugin:jsx-a11y/recommended',
|
|
||||||
],
|
|
||||||
hasJsDoc && 'plugin:jsdoc/recommended-typescript',
|
|
||||||
hasGraphQL && 'plugin:@graphql-eslint/recommended',
|
|
||||||
_extends,
|
|
||||||
),
|
|
||||||
settings: {
|
|
||||||
'import/parsers': {
|
|
||||||
'@typescript-eslint/parser': ['.ts', '.tsx', '.mts', '.cts'],
|
|
||||||
},
|
|
||||||
'import/resolver': {
|
|
||||||
typescript: {
|
|
||||||
alwaysTryTypes: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
react: {
|
|
||||||
version: 'detect',
|
|
||||||
},
|
|
||||||
...settings,
|
|
||||||
},
|
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{ files: ['repl.ts', 'scripts/**/*.ts'], rules: { 'no-console': off } },
|
||||||
files: [
|
|
||||||
'.eslintrc.js',
|
|
||||||
'*.config.js',
|
|
||||||
'index.js',
|
|
||||||
'babel.config.js',
|
|
||||||
'next.config.js',
|
|
||||||
],
|
|
||||||
extends: ['plugin:@typescript-eslint/disable-type-checked'],
|
|
||||||
rules: {
|
|
||||||
'rules/restrict-template-expressions': off,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['*.d.ts'],
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/consistent-type-imports': off,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
files: ['repl.ts'],
|
|
||||||
rules: {
|
|
||||||
'no-console': off,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...(overrides ?? []),
|
...(overrides ?? []),
|
||||||
],
|
],
|
||||||
rules: {
|
rules: { ...eslintRules, ...rules },
|
||||||
...eslintRules,
|
|
||||||
...typescriptRules,
|
|
||||||
...importRules,
|
|
||||||
...localRules,
|
|
||||||
...(hasReact && {
|
|
||||||
...reactRules,
|
|
||||||
'react/no-unknown-property': [
|
|
||||||
error,
|
|
||||||
{ ignore: hasNext ? ['css', 'next'] : ['css'] },
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
...(hasReactRefresh && {
|
|
||||||
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
|
|
||||||
}),
|
|
||||||
...(hasUnicorn && unicornRules),
|
|
||||||
...(hasJsDoc && jsDocRules),
|
|
||||||
...(hasGraphQL && graphqlRules),
|
|
||||||
...(hasTailwind && tailwindRules),
|
|
||||||
...rules,
|
|
||||||
},
|
|
||||||
...rest,
|
...rest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const functions: MiddlewareFunctions = {
|
||||||
|
addRules(newRules) {
|
||||||
|
Object.assign(result.rules, newRules);
|
||||||
|
},
|
||||||
|
addSettings(newSettings) {
|
||||||
|
Object.assign(result.settings, newSettings);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const fn of middlewares) {
|
||||||
|
fn(result, functions);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.plugins = unique(result.plugins);
|
||||||
|
result.extends = unique(result.extends);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import type { Node, Property } from 'estree';
|
|||||||
|
|
||||||
// https://github.com/gulpjs/interpret
|
// https://github.com/gulpjs/interpret
|
||||||
const transpilers = [
|
const transpilers = [
|
||||||
'esbin/register',
|
|
||||||
'esbuild-register',
|
'esbuild-register',
|
||||||
'ts-node/register/transpile-only',
|
'ts-node/register/transpile-only',
|
||||||
'@swc/register',
|
'@swc/register',
|
||||||
|
164
src/presets/_restrictedGlobals.json
Normal file
164
src/presets/_restrictedGlobals.json
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
[
|
||||||
|
"addEventListener",
|
||||||
|
"blur",
|
||||||
|
"caches",
|
||||||
|
"captureEvents",
|
||||||
|
"clientInformation",
|
||||||
|
"close",
|
||||||
|
"closed",
|
||||||
|
"crossOriginIsolated",
|
||||||
|
"devicePixelRatio",
|
||||||
|
"dispatchEvent",
|
||||||
|
"event",
|
||||||
|
"external",
|
||||||
|
"focus",
|
||||||
|
"innerHeight",
|
||||||
|
"innerWidth",
|
||||||
|
"length",
|
||||||
|
"locationbar",
|
||||||
|
"menubar",
|
||||||
|
"name",
|
||||||
|
"onabort",
|
||||||
|
"onafterprint",
|
||||||
|
"onanimationcancel",
|
||||||
|
"onanimationend",
|
||||||
|
"onanimationiteration",
|
||||||
|
"onanimationstart",
|
||||||
|
"onauxclick",
|
||||||
|
"onbeforeinput",
|
||||||
|
"onbeforeprint",
|
||||||
|
"onbeforetoggle",
|
||||||
|
"onbeforeunload",
|
||||||
|
"onblur",
|
||||||
|
"oncancel",
|
||||||
|
"oncanplay",
|
||||||
|
"oncanplaythrough",
|
||||||
|
"onchange",
|
||||||
|
"onclick",
|
||||||
|
"onclose",
|
||||||
|
"oncontextmenu",
|
||||||
|
"oncopy",
|
||||||
|
"oncuechange",
|
||||||
|
"oncut",
|
||||||
|
"ondblclick",
|
||||||
|
"ondevicemotion",
|
||||||
|
"ondeviceorientation",
|
||||||
|
"ondeviceorientationabsolute",
|
||||||
|
"ondrag",
|
||||||
|
"ondragend",
|
||||||
|
"ondragenter",
|
||||||
|
"ondragleave",
|
||||||
|
"ondragover",
|
||||||
|
"ondragstart",
|
||||||
|
"ondrop",
|
||||||
|
"ondurationchange",
|
||||||
|
"onemptied",
|
||||||
|
"onended",
|
||||||
|
"onerror",
|
||||||
|
"onfocus",
|
||||||
|
"onformdata",
|
||||||
|
"ongamepadconnected",
|
||||||
|
"ongamepaddisconnected",
|
||||||
|
"ongotpointercapture",
|
||||||
|
"onhashchange",
|
||||||
|
"oninput",
|
||||||
|
"oninvalid",
|
||||||
|
"onkeydown",
|
||||||
|
"onkeypress",
|
||||||
|
"onkeyup",
|
||||||
|
"onlanguagechange",
|
||||||
|
"onload",
|
||||||
|
"onloadeddata",
|
||||||
|
"onloadedmetadata",
|
||||||
|
"onloadstart",
|
||||||
|
"onlostpointercapture",
|
||||||
|
"onmessage",
|
||||||
|
"onmessageerror",
|
||||||
|
"onmousedown",
|
||||||
|
"onmouseenter",
|
||||||
|
"onmouseleave",
|
||||||
|
"onmousemove",
|
||||||
|
"onmouseout",
|
||||||
|
"onmouseover",
|
||||||
|
"onmouseup",
|
||||||
|
"onoffline",
|
||||||
|
"ononline",
|
||||||
|
"onorientationchange",
|
||||||
|
"onpagehide",
|
||||||
|
"onpageshow",
|
||||||
|
"onpaste",
|
||||||
|
"onpause",
|
||||||
|
"onplay",
|
||||||
|
"onplaying",
|
||||||
|
"onpointercancel",
|
||||||
|
"onpointerdown",
|
||||||
|
"onpointerenter",
|
||||||
|
"onpointerleave",
|
||||||
|
"onpointermove",
|
||||||
|
"onpointerout",
|
||||||
|
"onpointerover",
|
||||||
|
"onpointerup",
|
||||||
|
"onpopstate",
|
||||||
|
"onprogress",
|
||||||
|
"onratechange",
|
||||||
|
"onrejectionhandled",
|
||||||
|
"onreset",
|
||||||
|
"onresize",
|
||||||
|
"onscroll",
|
||||||
|
"onscrollend",
|
||||||
|
"onsecuritypolicyviolation",
|
||||||
|
"onseeked",
|
||||||
|
"onseeking",
|
||||||
|
"onselect",
|
||||||
|
"onselectionchange",
|
||||||
|
"onselectstart",
|
||||||
|
"onslotchange",
|
||||||
|
"onstalled",
|
||||||
|
"onstorage",
|
||||||
|
"onsubmit",
|
||||||
|
"onsuspend",
|
||||||
|
"ontimeupdate",
|
||||||
|
"ontoggle",
|
||||||
|
"ontouchcancel",
|
||||||
|
"ontouchend",
|
||||||
|
"ontouchmove",
|
||||||
|
"ontouchstart",
|
||||||
|
"ontransitioncancel",
|
||||||
|
"ontransitionend",
|
||||||
|
"ontransitionrun",
|
||||||
|
"ontransitionstart",
|
||||||
|
"onunhandledrejection",
|
||||||
|
"onunload",
|
||||||
|
"onvolumechange",
|
||||||
|
"onwaiting",
|
||||||
|
"onwebkitanimationend",
|
||||||
|
"onwebkitanimationiteration",
|
||||||
|
"onwebkitanimationstart",
|
||||||
|
"onwebkittransitionend",
|
||||||
|
"onwheel",
|
||||||
|
"orientation",
|
||||||
|
"origin",
|
||||||
|
"outerHeight",
|
||||||
|
"outerWidth",
|
||||||
|
"pageXOffset",
|
||||||
|
"pageYOffset",
|
||||||
|
"personalbar",
|
||||||
|
"releaseEvents",
|
||||||
|
"removeEventListener",
|
||||||
|
"reportError",
|
||||||
|
"screenLeft",
|
||||||
|
"screenTop",
|
||||||
|
"screenX",
|
||||||
|
"screenY",
|
||||||
|
"scroll",
|
||||||
|
"scrollbars",
|
||||||
|
"scrollBy",
|
||||||
|
"scrollTo",
|
||||||
|
"scrollX",
|
||||||
|
"scrollY",
|
||||||
|
"status",
|
||||||
|
"statusbar",
|
||||||
|
"stop",
|
||||||
|
"toolbar",
|
||||||
|
"top"
|
||||||
|
]
|
@ -1,9 +1,10 @@
|
|||||||
import { error, warn, off } from '../constants';
|
import { error, warn, off } from '../constants';
|
||||||
import { EslintRules } from 'eslint-define-config/src/rules/eslint';
|
import { EslintRulesObject } from '@aet/eslint-define-config/src/rules/eslint';
|
||||||
|
import restrictedGlobals from './_restrictedGlobals.json';
|
||||||
|
|
||||||
export const eslintRules: Partial<EslintRules> = {
|
export const eslintRules: Partial<EslintRulesObject> = {
|
||||||
'arrow-body-style': [error, 'as-needed'],
|
'arrow-body-style': [error, 'as-needed'],
|
||||||
'class-methods-use-this': off,
|
'class-methods-use-this': warn,
|
||||||
'func-style': [error, 'declaration', { allowArrowFunctions: true }],
|
'func-style': [error, 'declaration', { allowArrowFunctions: true }],
|
||||||
'no-async-promise-executor': off,
|
'no-async-promise-executor': off,
|
||||||
'no-case-declarations': off,
|
'no-case-declarations': off,
|
||||||
@ -14,7 +15,7 @@ export const eslintRules: Partial<EslintRules> = {
|
|||||||
'no-empty': [error, { allowEmptyCatch: true }],
|
'no-empty': [error, { allowEmptyCatch: true }],
|
||||||
'no-inner-declarations': off,
|
'no-inner-declarations': off,
|
||||||
'no-lonely-if': error,
|
'no-lonely-if': error,
|
||||||
'no-restricted-globals': [error, 'event', 'name', 'length'],
|
'no-restricted-globals': [error, ...restrictedGlobals],
|
||||||
'no-restricted-imports': [
|
'no-restricted-imports': [
|
||||||
error,
|
error,
|
||||||
{
|
{
|
||||||
@ -30,7 +31,7 @@ export const eslintRules: Partial<EslintRules> = {
|
|||||||
'no-template-curly-in-string': error,
|
'no-template-curly-in-string': error,
|
||||||
'no-var': error,
|
'no-var': error,
|
||||||
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
|
'object-shorthand': [error, 'always', { ignoreConstructors: true }],
|
||||||
'one-var': [error, { var: 'never', let: 'never' }],
|
'one-var': [error, { var: 'never', let: 'never', const: 'never' }],
|
||||||
'prefer-arrow-callback': error,
|
'prefer-arrow-callback': error,
|
||||||
'prefer-const': [error, { destructuring: 'all' }],
|
'prefer-const': [error, { destructuring: 'all' }],
|
||||||
'prefer-destructuring': [
|
'prefer-destructuring': [
|
||||||
@ -42,7 +43,15 @@ export const eslintRules: Partial<EslintRules> = {
|
|||||||
'prefer-spread': warn,
|
'prefer-spread': warn,
|
||||||
'quote-props': [error, 'as-needed'],
|
'quote-props': [error, 'as-needed'],
|
||||||
'sort-imports': [warn, { ignoreDeclarationSort: true }],
|
'sort-imports': [warn, { ignoreDeclarationSort: true }],
|
||||||
'spaced-comment': [error, 'always', { markers: ['/', '#', '@'] }],
|
'spaced-comment': [
|
||||||
|
error,
|
||||||
|
'always',
|
||||||
|
{
|
||||||
|
markers: ['/', '#', '@'],
|
||||||
|
// allow /*@__PURE__*/
|
||||||
|
block: { exceptions: ['@'] },
|
||||||
|
},
|
||||||
|
],
|
||||||
complexity: [warn, { max: 100 }],
|
complexity: [warn, { max: 100 }],
|
||||||
curly: [error, 'multi-line', 'consistent'],
|
curly: [error, 'multi-line', 'consistent'],
|
||||||
eqeqeq: [error, 'smart'],
|
eqeqeq: [error, 'smart'],
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
import { GraphQLRules } from 'eslint-define-config/src/rules/graphql-eslint';
|
import { GraphQLRulesObject } from '@aet/eslint-define-config/src/rules/graphql-eslint';
|
||||||
|
import type { Middleware } from '../index';
|
||||||
|
|
||||||
// https://the-guild.dev/graphql/eslint/rules
|
// https://the-guild.dev/graphql/eslint/rules
|
||||||
export const graphqlRules: Partial<GraphQLRules> = {};
|
const graphqlRules: Partial<GraphQLRulesObject> = {};
|
||||||
|
|
||||||
|
export const graphql: Middleware = (config, { addRules }) => {
|
||||||
|
config.plugins.push('@graphql-eslint');
|
||||||
|
config.extends.push('plugin:@graphql-eslint/recommended');
|
||||||
|
addRules(graphqlRules);
|
||||||
|
};
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import { error, off } from '../constants';
|
|
||||||
import { ImportRules } from 'eslint-define-config/src/rules/import';
|
|
||||||
|
|
||||||
export const importRules: Partial<ImportRules> = {
|
|
||||||
'import/export': off,
|
|
||||||
'import/no-duplicates': error,
|
|
||||||
'import/order': [error, { groups: ['builtin', 'external'] }],
|
|
||||||
};
|
|
@ -1,3 +1,10 @@
|
|||||||
import { JSDocRules } from 'eslint-define-config/src/rules/jsdoc';
|
import { JSDocRulesObject } from '@aet/eslint-define-config/src/rules/jsdoc';
|
||||||
|
import type { Middleware } from '../index';
|
||||||
|
|
||||||
export const jsDocRules: Partial<JSDocRules> = {};
|
const jsdocRules: Partial<JSDocRulesObject> = {};
|
||||||
|
|
||||||
|
export const jsdoc: Middleware = (config, { addRules }) => {
|
||||||
|
config.plugins.push('jsdoc');
|
||||||
|
config.extends.push('plugin:jsdoc/recommended-typescript');
|
||||||
|
addRules(jsdocRules);
|
||||||
|
};
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import type { LocalRuleOptions } from '..';
|
import type { LocalRuleOptions, Middleware } from '../index';
|
||||||
import { error } from '../constants';
|
import { error } from '../constants';
|
||||||
|
|
||||||
export const localRules: Partial<LocalRuleOptions> = {
|
const localRules: Partial<LocalRuleOptions> = {
|
||||||
'rules/no-import-dot': error,
|
'rules/no-import-dot': error,
|
||||||
'rules/restrict-template-expressions': error,
|
'rules/restrict-template-expressions': error,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const local: Middleware = (_, { addRules }) => {
|
||||||
|
addRules(localRules);
|
||||||
|
};
|
||||||
|
9
src/presets/misc.ts
Normal file
9
src/presets/misc.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import type { Middleware } from '../index';
|
||||||
|
|
||||||
|
export const storybook: Middleware = config => {
|
||||||
|
config.extends.push('plugin:storybook/recommended');
|
||||||
|
};
|
||||||
|
|
||||||
|
export const reactQuery: Middleware = config => {
|
||||||
|
config.extends.push('plugin:@tanstack/eslint-plugin-query/recommended');
|
||||||
|
};
|
@ -1,9 +1,35 @@
|
|||||||
import { error, off } from '../constants';
|
import type { Middleware } from '../index';
|
||||||
import { ReactRules } from 'eslint-define-config/src/rules/react';
|
import { error, off, warn } from '../constants';
|
||||||
|
import { ReactRulesObject } from '@aet/eslint-define-config/src/rules/react';
|
||||||
|
import { ReactRefreshRulesObject } from '@aet/eslint-define-config/src/rules/react-refresh';
|
||||||
|
|
||||||
export const reactRules: Partial<ReactRules> = {
|
const reactRules: Partial<ReactRulesObject> = {
|
||||||
'react/display-name': off,
|
'@eslint-react/no-missing-component-display-name': off,
|
||||||
'react/no-children-prop': error,
|
'@eslint-react/no-children-prop': error,
|
||||||
'react/prop-types': off,
|
};
|
||||||
'react/react-in-jsx-scope': off,
|
|
||||||
|
export const react: Middleware = (config, { addRules }) => {
|
||||||
|
config.plugins.push('@eslint-react/eslint-plugin', 'react-hooks');
|
||||||
|
config.extends.push(
|
||||||
|
'plugin:@eslint-react/recommended-legacy',
|
||||||
|
'plugin:@eslint-react/dom-legacy',
|
||||||
|
'plugin:react-hooks/recommended',
|
||||||
|
'plugin:jsx-a11y/recommended',
|
||||||
|
);
|
||||||
|
config.overrides.push({
|
||||||
|
files: ['*.tsx'],
|
||||||
|
rules: {
|
||||||
|
'@eslint-react/no-leaked-conditional-rendering': error,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
addRules(reactRules);
|
||||||
|
};
|
||||||
|
|
||||||
|
const refreshRules: Partial<ReactRefreshRulesObject> = {
|
||||||
|
'react-refresh/only-export-components': [warn, { allowConstantExport: true }],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const reactRefresh: Middleware = (config, { addRules }) => {
|
||||||
|
config.plugins.push('react-refresh');
|
||||||
|
addRules(refreshRules);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
import type { Middleware } from '../index';
|
||||||
import { off } from '../constants';
|
import { off } from '../constants';
|
||||||
|
import type { TailwindRulesObject } from '@aet/eslint-define-config/src/rules/tailwind';
|
||||||
|
|
||||||
export const tailwindRules = {
|
const tailwindRules: Partial<TailwindRulesObject> = {
|
||||||
'tailwindcss/no-custom-classname': off,
|
'tailwindcss/no-custom-classname': off,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const tailwind: Middleware = (config, { addRules }) => {
|
||||||
|
config.extends.push('plugin:tailwindcss/recommended');
|
||||||
|
addRules(tailwindRules);
|
||||||
|
};
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
import { error, off, warn } from '../constants';
|
import { error, off, warn } from '../constants';
|
||||||
import type { TypeScriptRules } from 'eslint-define-config/src/rules/typescript-eslint';
|
import type { TypeScriptRulesObject } from '@aet/eslint-define-config/src/rules/typescript-eslint';
|
||||||
|
import type { ImportXRulesObject } from '@aet/eslint-define-config/src/rules/import-x';
|
||||||
|
import type { Middleware } from '../index';
|
||||||
|
|
||||||
export const typescriptRules: Partial<TypeScriptRules> = {
|
const importRules: Partial<ImportXRulesObject> = {
|
||||||
|
'import-x/export': off,
|
||||||
|
'import-x/no-duplicates': error,
|
||||||
|
'import-x/order': [error, { groups: ['builtin', 'external'] }],
|
||||||
|
};
|
||||||
|
|
||||||
|
const typescriptRules: Partial<TypeScriptRulesObject> = {
|
||||||
'@typescript-eslint/ban-ts-comment': [
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
error,
|
error,
|
||||||
{
|
{
|
||||||
@ -37,3 +45,39 @@ export const typescriptRules: Partial<TypeScriptRules> = {
|
|||||||
'@typescript-eslint/triple-slash-reference': off,
|
'@typescript-eslint/triple-slash-reference': off,
|
||||||
'@typescript-eslint/unbound-method': off,
|
'@typescript-eslint/unbound-method': off,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const importTypeScript: Middleware = (config, { addRules, addSettings }) => {
|
||||||
|
config.parser = '@typescript-eslint/parser';
|
||||||
|
config.plugins.push('@typescript-eslint', 'import-x');
|
||||||
|
config.extends.push(
|
||||||
|
'plugin:@typescript-eslint/recommended-type-checked',
|
||||||
|
'plugin:import-x/errors',
|
||||||
|
'plugin:import-x/typescript',
|
||||||
|
);
|
||||||
|
addSettings({
|
||||||
|
'import-x/parsers': {
|
||||||
|
'@typescript-eslint/parser': ['.ts', '.tsx', '.mts', '.cts'],
|
||||||
|
},
|
||||||
|
'import-x/resolver': {
|
||||||
|
typescript: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
config.overrides.push(
|
||||||
|
{
|
||||||
|
files: ['.eslintrc.js', '.eslintrc.cjs', '*.config.js', 'index.js'],
|
||||||
|
extends: ['plugin:@typescript-eslint/disable-type-checked'],
|
||||||
|
rules: {
|
||||||
|
'rules/restrict-template-expressions': off,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['*.d.ts'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/consistent-type-imports': off,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
addRules(importRules);
|
||||||
|
addRules(typescriptRules);
|
||||||
|
};
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
import type { Middleware } from '../index';
|
||||||
import { error, warn } from '../constants';
|
import { error, warn } from '../constants';
|
||||||
import { UnicornRules } from 'eslint-define-config/src/rules/unicorn';
|
import { UnicornRulesObject } from '@aet/eslint-define-config/src/rules/unicorn';
|
||||||
|
|
||||||
const suggest = (suggest: string) => ({ suggest, fix: false });
|
const suggest = (suggest: string) => ({ suggest, fix: false });
|
||||||
|
|
||||||
// https://github.com/sindresorhus/eslint-plugin-unicorn/tree/28e7498ad06679bb92343db53bb40a7b5ba2990a
|
// https://github.com/sindresorhus/eslint-plugin-unicorn/tree/28e7498ad06679bb92343db53bb40a7b5ba2990a
|
||||||
export const unicornRules: Partial<UnicornRules> = {
|
const unicornRules: Partial<UnicornRulesObject> = {
|
||||||
'unicorn/better-regex': error,
|
'unicorn/better-regex': error,
|
||||||
'unicorn/consistent-function-scoping': warn,
|
'unicorn/consistent-function-scoping': warn,
|
||||||
'unicorn/escape-case': error,
|
'unicorn/escape-case': error,
|
||||||
@ -69,3 +70,8 @@ export const unicornRules: Partial<UnicornRules> = {
|
|||||||
],
|
],
|
||||||
'unicorn/template-indent': warn,
|
'unicorn/template-indent': warn,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const unicorn: Middleware = (config, { addRules }) => {
|
||||||
|
config.plugins.push('unicorn');
|
||||||
|
addRules(unicornRules);
|
||||||
|
};
|
||||||
|
@ -4,12 +4,10 @@ const { name } = [require][0]('./package.json');
|
|||||||
const _resolveFilename = Module._resolveFilename;
|
const _resolveFilename = Module._resolveFilename;
|
||||||
const alias = new Set([
|
const alias = new Set([
|
||||||
'eslint-import-resolver-typescript',
|
'eslint-import-resolver-typescript',
|
||||||
'eslint-plugin-import',
|
|
||||||
'eslint-plugin-jsx-a11y',
|
'eslint-plugin-jsx-a11y',
|
||||||
'eslint-plugin-local',
|
'eslint-plugin-local',
|
||||||
'eslint-plugin-n',
|
'eslint-plugin-n',
|
||||||
'eslint-plugin-react-hooks',
|
'eslint-plugin-react-hooks',
|
||||||
'eslint-plugin-react',
|
|
||||||
'eslint-plugin-rules',
|
'eslint-plugin-rules',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user