Monkey patch directly
This commit is contained in:
parent
13f2f75acf
commit
a27416f190
0
dist/basic.d.ts → dist/index.d.ts
vendored
0
dist/basic.d.ts → dist/index.d.ts
vendored
14
dist/package.json
vendored
14
dist/package.json
vendored
@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "@aet/eslint-rules",
|
||||
"version": "0.0.1-beta.21",
|
||||
"version": "0.0.1-beta.22",
|
||||
"license": "UNLICENSED",
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"bin": {
|
||||
"eslint-add-alias": "./add-alias.js",
|
||||
"eslint-remove-alias": "./remove-alias.js"
|
||||
"typescript": "^5.1.6",
|
||||
"@typescript-eslint/eslint-plugin": "6.2.0",
|
||||
"@typescript-eslint/parser": "6.2.0",
|
||||
"eslint-config-prettier": "8.9.0",
|
||||
"eslint-import-resolver-typescript": "3.5.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/eslint": "^8.44.1",
|
||||
@ -18,7 +18,7 @@
|
||||
"debug": "^4.3.4",
|
||||
"doctrine": "^3.0.0",
|
||||
"emoji-regex": "^10.2.1",
|
||||
"eslint-define-config": "^1.21.0",
|
||||
"eslint-define-config": "^1.22.0",
|
||||
"eslint-import-resolver-node": "^0.3.7",
|
||||
"eslint-module-utils": "^2.8.0",
|
||||
"estraverse": "^5.3.0",
|
||||
|
@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { name } from '../dist/package.json';
|
||||
|
||||
const pkgPath = resolve(process.cwd(), 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
|
||||
const devDeps = (pkg.devDependencies ??= {});
|
||||
|
||||
Object.assign(devDeps, {
|
||||
'eslint-plugin-import': `file:./node_modules/${name}/import`,
|
||||
'eslint-plugin-jsx-a11y': `file:./node_modules/${name}/jsx-a11y`,
|
||||
'eslint-plugin-local': `file:./node_modules/${name}/local`,
|
||||
'eslint-plugin-rules': `file:./node_modules/${name}/rules`,
|
||||
'eslint-plugin-react': `file:./node_modules/${name}/react`,
|
||||
'eslint-plugin-react-hooks': `file:./node_modules/${name}/react-hooks`,
|
||||
});
|
||||
|
||||
devDeps['@typescript-eslint/eslint-plugin'] ??= '6.2.0';
|
||||
devDeps['@typescript-eslint/parser'] ??= '6.2.0';
|
||||
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
||||
|
||||
const eslintrc = resolve(process.cwd(), '.eslintrc.js');
|
||||
if (fs.existsSync(eslintrc)) {
|
||||
fs.writeFileSync(
|
||||
eslintrc,
|
||||
`const { extendConfig } = require('@aet/eslint-rules/basic');
|
||||
|
||||
module.exports = extendConfig({
|
||||
extends: [],
|
||||
});`,
|
||||
);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
// @ts-check
|
||||
import Module from 'module';
|
||||
import type { ESLintConfig } from 'eslint-define-config';
|
||||
// @ts-expect-error
|
||||
const { name } = (0, require)('./package.json');
|
||||
|
||||
function unique<T>(arr: T[]): T[] {
|
||||
return [...new Set(arr)];
|
||||
@ -18,6 +20,7 @@ export function extendConfig({
|
||||
}: ESLintConfig): ESLintConfig {
|
||||
const hasReact = plugins?.includes('react');
|
||||
const hasUnicorn = plugins?.includes('unicorn');
|
||||
const hasReactRefresh = plugins?.includes('react-refresh');
|
||||
|
||||
const result: ESLintConfig = {
|
||||
root: true,
|
||||
@ -166,6 +169,14 @@ export function extendConfig({
|
||||
'unicorn/no-unnecessary-await': off,
|
||||
}
|
||||
: {}),
|
||||
...(hasReactRefresh
|
||||
? {
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
}
|
||||
: {}),
|
||||
...rules,
|
||||
},
|
||||
...rest,
|
||||
@ -173,3 +184,18 @@ export function extendConfig({
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const _resolveFilename = (Module as any)._resolveFilename;
|
||||
(Module as any)._resolveFilename = function (module: string, ...args: any[]) {
|
||||
switch (module) {
|
||||
case 'eslint-plugin-import':
|
||||
case 'eslint-plugin-jsx-a11y':
|
||||
case 'eslint-plugin-local':
|
||||
case 'eslint-plugin-react':
|
||||
case 'eslint-plugin-react-hooks':
|
||||
case 'eslint-plugin-rules':
|
||||
module = `${name}/${module.slice(14)}`;
|
||||
}
|
||||
|
||||
return _resolveFilename(module, ...args);
|
||||
};
|
@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'node:fs';
|
||||
import { resolve } from 'node:path';
|
||||
import { name } from '../dist/package.json';
|
||||
|
||||
const pkgPath = resolve(process.cwd(), 'package.json');
|
||||
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
||||
|
||||
const devDeps = (pkg.devDependencies ??= {});
|
||||
for (const dep of [
|
||||
'eslint-plugin-import',
|
||||
'eslint-plugin-jsx-a11y',
|
||||
'eslint-plugin-local',
|
||||
'eslint-plugin-rules',
|
||||
'eslint-plugin-react',
|
||||
'eslint-plugin-react-hooks',
|
||||
]) {
|
||||
if (devDeps[dep]?.startsWith(`file:./node_modules/${name}/`)) {
|
||||
delete devDeps[dep];
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
|
Loading…
x
Reference in New Issue
Block a user