This commit is contained in:
Alex 2023-10-04 17:52:39 -04:00
parent 8a07010f29
commit 91bbcba2e8
11 changed files with 53 additions and 24 deletions

15
dist/index.d.ts vendored
View File

@ -2,16 +2,9 @@
import { ESLintConfig } from 'eslint-define-config';
export declare const error = 'error';
export declare const warn = 'warn';
export declare const off = 'off';
export declare function extendConfig({
plugins,
settings,
rules,
extends: _extends,
overrides,
...rest
}?: ESLintConfig): ESLintConfig;
export declare const error = "error";
export declare const warn = "warn";
export declare const off = "off";
export declare function extendConfig({ plugins, settings, rules, extends: _extends, overrides, ...rest }?: ESLintConfig): ESLintConfig;
export {};

3
dist/package.json vendored
View File

@ -1,6 +1,6 @@
{
"name": "@aet/eslint-rules",
"version": "0.0.1-beta.37",
"version": "0.0.1-beta.40",
"license": "UNLICENSED",
"peerDependencies": {
"typescript": "^5.2.2"
@ -30,7 +30,6 @@
"language-tags": "^1.0.9",
"lodash": "^4.17.21",
"minimatch": "^9.0.3",
"prop-types": "^15.8.1",
"resolve": "^2.0.0-next.4",
"semver": "^7.5.4",
"tsconfig-paths": "^4.2.0"

View File

@ -149,7 +149,11 @@ export const babelPlugin: Plugin = {
let source = readFileSync(path, 'utf-8')
.replaceAll("require('object.hasown/polyfill')()", 'Object.hasOwn')
.replaceAll("require('object.fromentries/polyfill')()", 'Object.fromEntries');
.replaceAll("require('object.fromentries/polyfill')()", 'Object.fromEntries')
.replaceAll(
"Object.keys(require('prop-types'))",
JSON.stringify(Object.keys(require('prop-types'))),
);
if (
path.includes('packages/eslint-plugin-import/src/rules/') ||

View File

@ -31,6 +31,7 @@
"minimatch": "^9.0.3",
"picocolors": "^1.0.0",
"prettier": "^3.0.3",
"prop-types": "^15.8.1",
"typescript": "5.2.2"
},
"prettier": {

27
pnpm-lock.yaml generated
View File

@ -80,6 +80,9 @@ devDependencies:
prettier:
specifier: ^3.0.3
version: 3.0.3
prop-types:
specifier: ^15.8.1
version: 15.8.1
typescript:
specifier: 5.2.2
version: 5.2.2
@ -2458,6 +2461,13 @@ packages:
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
dev: true
/loose-envify@1.4.0:
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
hasBin: true
dependencies:
js-tokens: 4.0.0
dev: true
/lru-cache@5.1.1:
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
dependencies:
@ -2506,6 +2516,11 @@ packages:
resolution: {integrity: sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ==}
dev: true
/object-assign@4.1.1:
resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==}
engines: {node: '>=0.10.0'}
dev: true
/once@1.4.0:
resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==}
dependencies:
@ -2604,6 +2619,14 @@ packages:
hasBin: true
dev: true
/prop-types@15.8.1:
resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==}
dependencies:
loose-envify: 1.4.0
object-assign: 4.1.1
react-is: 16.13.1
dev: true
/punycode@2.3.0:
resolution: {integrity: sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==}
engines: {node: '>=6'}
@ -2613,6 +2636,10 @@ packages:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
dev: true
/react-is@16.13.1:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
dev: true
/regenerate-unicode-properties@10.1.0:
resolution: {integrity: sha512-d1VudCLoIGitcU/hEg2QqvyGZQmdC0Lf8BqdOMXGFSvJP4bNV1+XqbPQeHHLD51Jh4QJJ225dlIFvY4Ly6MXmQ==}
engines: {node: '>=4'}

3
src/constants.ts Normal file
View File

@ -0,0 +1,3 @@
export const error = 'error';
export const warn = 'warn';
export const off = 'off';

View File

@ -4,17 +4,16 @@ import { typescriptRules } from './presets/typescript';
import { unicornRules } from './presets/unicorn';
import { eslintRules } from './presets/eslint';
import { reactRules } from './presets/react';
import { error, warn, off } from './constants';
// @ts-expect-error
const { name } = (0, require)('./package.json');
export { error, warn, off };
const unique = <T>(arr: T[]): T[] => [...new Set(arr)];
const ensureArray = <T>(value?: T | T[]): T[] =>
value == null ? [] : Array.isArray(value) ? value : [value];
export const error = 'error';
export const warn = 'warn';
export const off = 'off';
declare module 'eslint-define-config/src/rules/react/no-unknown-property.d.ts' {
export interface NoUnknownPropertyOption {
extends: ('next' | 'emotion')[];

View File

@ -1,4 +1,4 @@
import { error, warn, off } from '../index';
import { error, warn, off } from '../constants';
import { EslintRules } from 'eslint-define-config/src/rules/eslint';
export const eslintRules: Partial<EslintRules> = {

View File

@ -1,4 +1,4 @@
import { error, off } from '../index';
import { error, off } from '../constants';
import { ReactRules } from 'eslint-define-config/src/rules/react';
export const reactRules: Partial<ReactRules> = {

View File

@ -1,4 +1,4 @@
import { error, off } from '../index';
import { error, off } from '../constants';
import type { TypeScriptRules } from 'eslint-define-config/src/rules/typescript-eslint';
export const typescriptRules: Partial<TypeScriptRules> = {

View File

@ -1,4 +1,4 @@
import { error, warn } from '../index';
import { error, warn } from '../constants';
import { UnicornRules } from 'eslint-define-config/src/rules/unicorn';
const suggest = (suggest: string) => ({ suggest, fix: false });
@ -22,7 +22,9 @@ export const unicornRules: Partial<UnicornRules> = {
'unicorn/no-useless-promise-resolve-reject': error,
'unicorn/no-useless-spread': error,
'unicorn/no-useless-switch-case': error,
'unicorn/number-literal-case': error,
// https://github.com/prettier/eslint-config-prettier/issues/51
// 'unicorn/number-literal-case': error,
'unicorn/prefer-array-find': error,
'unicorn/prefer-array-flat-map': error,
'unicorn/prefer-array-some': error,
@ -60,7 +62,8 @@ export const unicornRules: Partial<UnicornRules> = {
'>=': suggest('≥'),
'!=': suggest('≠'),
'<=>': suggest('⇔'),
'...': suggest('…'),
'\\.\\.\\.': suggest('…'),
"'s ": suggest('s '),
},
},
],