read gitignore
This commit is contained in:
@ -12,16 +12,16 @@
|
||||
"subject": "fix(deps): update dependency debug to ^4.3.7 (#316)"
|
||||
},
|
||||
"eslint-plugin-jsx-a11y": {
|
||||
"hash": "4925ba8d0bf80a4b1d8e8645d310590bf1b40b64",
|
||||
"date": "2024-09-20T14:09:27-07:00",
|
||||
"hash": "cb6788c56d7108f2faa102d041dfa37dbc0e9f59",
|
||||
"date": "2024-10-18T16:13:23+10:00",
|
||||
"committer": "Jordan Harband",
|
||||
"subject": "[Fix] handle interactive/noninteractive changes from aria-query"
|
||||
"subject": "[Docs] Use consistent spelling of 'screen reader'"
|
||||
},
|
||||
"eslint-plugin-n": {
|
||||
"hash": "23d0e846e9dbfb68ccf7f410a83457514d432263",
|
||||
"date": "2024-10-09T13:49:20+02:00",
|
||||
"hash": "bf34ca53864e059e3fbf632f33429ba10a75ee9b",
|
||||
"date": "2024-10-19T14:26:54+02:00",
|
||||
"committer": "GitHub",
|
||||
"subject": "chore(master): release 17.11.1 (#352)"
|
||||
"subject": "fix: update dependencies (#365)"
|
||||
},
|
||||
"eslint-plugin-react": {
|
||||
"hash": "983b88dd3cb5e07919517d3fde4085f60883ded7",
|
||||
|
23
src/config.d.ts
vendored
23
src/config.d.ts
vendored
@ -26,18 +26,21 @@ export type Middleware =
|
||||
* Non bundled:
|
||||
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
||||
*
|
||||
* @param of Configuration options.
|
||||
* @returns ESLint configuration object.
|
||||
*/
|
||||
export function extendConfig({
|
||||
auto,
|
||||
middlewares: addMiddlewares,
|
||||
configs,
|
||||
}: {
|
||||
auto?: boolean;
|
||||
middlewares?: Middleware[];
|
||||
configs: FlatESLintConfig[];
|
||||
}): Promise<FlatESLintConfig[]>;
|
||||
export function extendConfig(
|
||||
options:
|
||||
| FlatESLintConfig[]
|
||||
| {
|
||||
auto?: boolean;
|
||||
middlewares?: Middleware[];
|
||||
configs: FlatESLintConfig[];
|
||||
/**
|
||||
* Use `.gitignore` file to exclude files from ESLint.
|
||||
*/
|
||||
gitignore?: boolean;
|
||||
},
|
||||
): Promise<FlatESLintConfig[]>;
|
||||
|
||||
export const error = 'error';
|
||||
export const warn = 'warn';
|
||||
|
46
src/index.ts
46
src/index.ts
@ -1,5 +1,8 @@
|
||||
import fs from 'node:fs';
|
||||
|
||||
import type { FlatESLintConfig } from '@aet/eslint-define-config';
|
||||
import * as tsParser from '@typescript-eslint/parser';
|
||||
import prettier from 'eslint-config-prettier';
|
||||
import importPlugin from 'eslint-plugin-import-x';
|
||||
import { uniq } from 'lodash-es';
|
||||
import tseslint from 'typescript-eslint';
|
||||
@ -14,15 +17,23 @@ import unicorn from './presets/unicorn';
|
||||
|
||||
export { error, warn, off } from './constants';
|
||||
|
||||
export async function extendConfig({
|
||||
auto = true,
|
||||
middlewares: addMiddlewares = [],
|
||||
configs = [],
|
||||
}: {
|
||||
auto?: boolean;
|
||||
middlewares?: Middleware[];
|
||||
configs: FlatESLintConfig[];
|
||||
}): Promise<FlatESLintConfig[]> {
|
||||
export async function extendConfig(
|
||||
options:
|
||||
| FlatESLintConfig[]
|
||||
| {
|
||||
auto?: boolean;
|
||||
middlewares?: Middleware[];
|
||||
configs: FlatESLintConfig[];
|
||||
gitignore?: boolean;
|
||||
},
|
||||
): Promise<FlatESLintConfig[]> {
|
||||
const {
|
||||
auto = true,
|
||||
middlewares: addMiddlewares = [],
|
||||
configs = [],
|
||||
gitignore = true,
|
||||
} = Array.isArray(options) ? { configs: options } : options;
|
||||
|
||||
const middlewares: Middleware[] = uniq([
|
||||
() => import('./presets/custom'),
|
||||
...(auto ? checkEnv() : []),
|
||||
@ -41,7 +52,7 @@ export async function extendConfig({
|
||||
...unicorn,
|
||||
stylistic,
|
||||
{
|
||||
name: 'eslint-rules: TypeScript and import-x',
|
||||
name: 'eslint-rules/typescript-and-import-x',
|
||||
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
@ -81,7 +92,7 @@ export async function extendConfig({
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'eslint-rules: .d.ts files',
|
||||
name: 'eslint-rules/.d.ts-files',
|
||||
files: ['*.d.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/consistent-type-imports': off,
|
||||
@ -106,5 +117,18 @@ export async function extendConfig({
|
||||
result.push(...configs);
|
||||
}
|
||||
|
||||
result.push(prettier);
|
||||
|
||||
if (gitignore && fs.existsSync('.gitignore')) {
|
||||
const ignores = fs
|
||||
.readFileSync('.gitignore', 'utf8')
|
||||
.trim()
|
||||
.split('\n')
|
||||
.map(line => line.trim())
|
||||
.filter(line => line && !line.startsWith('#'));
|
||||
|
||||
result.push({ ignores });
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user