-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(changeset): feat: add nailyProxy() function to proxy eslint conf…
…ig to naily.config.ts
- Loading branch information
Showing
9 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@nailyjs/eslint": patch | ||
--- | ||
|
||
feat: add nailyProxy() function to proxy eslint config to naily.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,3 @@ | ||
// @ts-check | ||
import naily from '@nailyjs/eslint' | ||
import { nailyProxy } from '@nailyjs/eslint' | ||
|
||
export default naily({ | ||
type: 'lib', | ||
rules: { | ||
'antfu/curly': 'off', | ||
'antfu/if-newline': 'off', | ||
'ts/method-signature-style': 'off', | ||
'ts/no-wrapper-object-types': 'off', | ||
'no-console': 'off', | ||
'unicorn/throw-new-error': 'off', | ||
}, | ||
}) | ||
export default await nailyProxy() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import antfu from '@antfu/eslint-config' | ||
import { Value } from '@nailyjs/config' | ||
import { AbstractBootstrap, ClassWrapper, Container, Injectable } from '@nailyjs/ioc' | ||
|
||
@Injectable() | ||
export class EslintService { | ||
constructor( | ||
@Value('naily.eslint') | ||
private readonly value: Naily.Configuration.NailyUserConfig['eslint'], | ||
) {} | ||
|
||
getEslintConfig(): Parameters<typeof antfu> { | ||
return [ | ||
(this.value || {}), | ||
...((this.value || {}).extraOptions || []), | ||
] | ||
} | ||
|
||
static getInstance(container: Container): EslintService { | ||
const wrapper = container.getContainer().get(EslintService) as ClassWrapper<EslintService> | ||
if (!wrapper) return container.createClassWrapper(EslintService).getClassFactory().getOrCreateInstance() | ||
return wrapper.getClassFactory().getOrCreateInstance() | ||
} | ||
} | ||
|
||
export class ESLintBootstrap extends AbstractBootstrap { | ||
async run(): Promise<ReturnType<typeof antfu>> { | ||
await this.getPluginRunner().runBeforeRun() | ||
const args = EslintService.getInstance(this).getEslintConfig() | ||
|
||
return antfu({ | ||
...args[0], | ||
rules: { | ||
'ts/method-signature-style': 'off', | ||
'ts/consistent-type-imports': 'off', | ||
'ts/no-redeclare': 'off', | ||
'ts/no-namespace': 'off', | ||
...(args[0] || {}).rules, | ||
}, | ||
}, ...args.slice(1)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import antfu from '@antfu/eslint-config' | ||
|
||
declare global { | ||
namespace Naily { | ||
namespace Configuration { | ||
interface NailyUserConfig { | ||
eslint?: Parameters<typeof antfu>[0] & { | ||
extraOptions?: Array<Parameters<typeof antfu>[1]> | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.