read gitignore
This commit is contained in:
23
dist/config/index.d.ts
vendored
23
dist/config/index.d.ts
vendored
@ -26,18 +26,21 @@ export type Middleware =
|
|||||||
* Non bundled:
|
* Non bundled:
|
||||||
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
||||||
*
|
*
|
||||||
* @param of Configuration options.
|
|
||||||
* @returns ESLint configuration object.
|
* @returns ESLint configuration object.
|
||||||
*/
|
*/
|
||||||
export function extendConfig({
|
export function extendConfig(
|
||||||
auto,
|
options:
|
||||||
middlewares: addMiddlewares,
|
| FlatESLintConfig[]
|
||||||
configs,
|
| {
|
||||||
}: {
|
auto?: boolean;
|
||||||
auto?: boolean;
|
middlewares?: Middleware[];
|
||||||
middlewares?: Middleware[];
|
configs: FlatESLintConfig[];
|
||||||
configs: FlatESLintConfig[];
|
/**
|
||||||
}): Promise<FlatESLintConfig[]>;
|
* Use `.gitignore` file to exclude files from ESLint.
|
||||||
|
*/
|
||||||
|
gitignore?: boolean;
|
||||||
|
},
|
||||||
|
): Promise<FlatESLintConfig[]>;
|
||||||
|
|
||||||
export const error = 'error';
|
export const error = 'error';
|
||||||
export const warn = 'warn';
|
export const warn = 'warn';
|
||||||
|
6
dist/package.json
vendored
6
dist/package.json
vendored
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@aet/eslint-rules",
|
"name": "@aet/eslint-rules",
|
||||||
"version": "2.0.1-beta.8",
|
"version": "2.0.1-beta.11",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -18,8 +18,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antfu/install-pkg": "^0.4.1",
|
"@antfu/install-pkg": "^0.4.1",
|
||||||
"@nolyfill/is-core-module": "^1.0.39",
|
"@nolyfill/is-core-module": "^1.0.39",
|
||||||
"@aet/eslint-define-config": "^0.1.0-beta.28",
|
"@aet/eslint-define-config": "^0.1.0-beta.29",
|
||||||
"@eslint/js": "^9.12.0",
|
"@eslint/js": "^9.13.0",
|
||||||
"@eslint-community/eslint-utils": "^4.4.0",
|
"@eslint-community/eslint-utils": "^4.4.0",
|
||||||
"@types/eslint": "^9.6.1",
|
"@types/eslint": "^9.6.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
"@typescript-eslint/eslint-plugin": "^8.10.0",
|
||||||
|
2267
dist/pnpm-lock.yaml
generated
vendored
2267
dist/pnpm-lock.yaml
generated
vendored
File diff suppressed because it is too large
Load Diff
@ -23,6 +23,7 @@
|
|||||||
"@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": "^9.6.1",
|
"@types/eslint": "^9.6.1",
|
||||||
|
"@types/eslint-config-prettier": "^6.11.3",
|
||||||
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
||||||
"@types/eslint__js": "^8.42.3",
|
"@types/eslint__js": "^8.42.3",
|
||||||
"@types/esprima": "^4.0.6",
|
"@types/esprima": "^4.0.6",
|
||||||
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -72,6 +72,9 @@ importers:
|
|||||||
'@types/eslint':
|
'@types/eslint':
|
||||||
specifier: ^9.6.1
|
specifier: ^9.6.1
|
||||||
version: 9.6.1
|
version: 9.6.1
|
||||||
|
'@types/eslint-config-prettier':
|
||||||
|
specifier: ^6.11.3
|
||||||
|
version: 6.11.3
|
||||||
'@types/eslint-plugin-tailwindcss':
|
'@types/eslint-plugin-tailwindcss':
|
||||||
specifier: ^3.17.0
|
specifier: ^3.17.0
|
||||||
version: 3.17.0
|
version: 3.17.0
|
||||||
@ -1360,6 +1363,9 @@ packages:
|
|||||||
'@types/babel__traverse@7.20.6':
|
'@types/babel__traverse@7.20.6':
|
||||||
resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==}
|
resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==}
|
||||||
|
|
||||||
|
'@types/eslint-config-prettier@6.11.3':
|
||||||
|
resolution: {integrity: sha512-3wXCiM8croUnhg9LdtZUJQwNcQYGWxxdOWDjPe1ykCqJFPVpzAKfs/2dgSoCtAvdPeaponcWPI7mPcGGp9dkKQ==}
|
||||||
|
|
||||||
'@types/eslint-plugin-tailwindcss@3.17.0':
|
'@types/eslint-plugin-tailwindcss@3.17.0':
|
||||||
resolution: {integrity: sha512-ucQGf2YIdTcndYcxRU3UdZgmhUHsOlbIF4BaRtl0op+7k2JmqM2i3aXZ6XIcfZgVq1ZKov7VM5c/BR81ukmkyg==}
|
resolution: {integrity: sha512-ucQGf2YIdTcndYcxRU3UdZgmhUHsOlbIF4BaRtl0op+7k2JmqM2i3aXZ6XIcfZgVq1ZKov7VM5c/BR81ukmkyg==}
|
||||||
|
|
||||||
@ -4368,6 +4374,8 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.25.2
|
'@babel/types': 7.25.2
|
||||||
|
|
||||||
|
'@types/eslint-config-prettier@6.11.3': {}
|
||||||
|
|
||||||
'@types/eslint-plugin-tailwindcss@3.17.0':
|
'@types/eslint-plugin-tailwindcss@3.17.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/eslint': 9.6.1
|
'@types/eslint': 9.6.1
|
||||||
|
@ -12,16 +12,16 @@
|
|||||||
"subject": "fix(deps): update dependency debug to ^4.3.7 (#316)"
|
"subject": "fix(deps): update dependency debug to ^4.3.7 (#316)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-jsx-a11y": {
|
"eslint-plugin-jsx-a11y": {
|
||||||
"hash": "4925ba8d0bf80a4b1d8e8645d310590bf1b40b64",
|
"hash": "cb6788c56d7108f2faa102d041dfa37dbc0e9f59",
|
||||||
"date": "2024-09-20T14:09:27-07:00",
|
"date": "2024-10-18T16:13:23+10:00",
|
||||||
"committer": "Jordan Harband",
|
"committer": "Jordan Harband",
|
||||||
"subject": "[Fix] handle interactive/noninteractive changes from aria-query"
|
"subject": "[Docs] Use consistent spelling of 'screen reader'"
|
||||||
},
|
},
|
||||||
"eslint-plugin-n": {
|
"eslint-plugin-n": {
|
||||||
"hash": "23d0e846e9dbfb68ccf7f410a83457514d432263",
|
"hash": "bf34ca53864e059e3fbf632f33429ba10a75ee9b",
|
||||||
"date": "2024-10-09T13:49:20+02:00",
|
"date": "2024-10-19T14:26:54+02:00",
|
||||||
"committer": "GitHub",
|
"committer": "GitHub",
|
||||||
"subject": "chore(master): release 17.11.1 (#352)"
|
"subject": "fix: update dependencies (#365)"
|
||||||
},
|
},
|
||||||
"eslint-plugin-react": {
|
"eslint-plugin-react": {
|
||||||
"hash": "983b88dd3cb5e07919517d3fde4085f60883ded7",
|
"hash": "983b88dd3cb5e07919517d3fde4085f60883ded7",
|
||||||
|
23
src/config.d.ts
vendored
23
src/config.d.ts
vendored
@ -26,18 +26,21 @@ export type Middleware =
|
|||||||
* Non bundled:
|
* Non bundled:
|
||||||
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
* 1. [`graphql`](https://the-guild.dev/graphql/eslint/rules)
|
||||||
*
|
*
|
||||||
* @param of Configuration options.
|
|
||||||
* @returns ESLint configuration object.
|
* @returns ESLint configuration object.
|
||||||
*/
|
*/
|
||||||
export function extendConfig({
|
export function extendConfig(
|
||||||
auto,
|
options:
|
||||||
middlewares: addMiddlewares,
|
| FlatESLintConfig[]
|
||||||
configs,
|
| {
|
||||||
}: {
|
auto?: boolean;
|
||||||
auto?: boolean;
|
middlewares?: Middleware[];
|
||||||
middlewares?: Middleware[];
|
configs: FlatESLintConfig[];
|
||||||
configs: FlatESLintConfig[];
|
/**
|
||||||
}): Promise<FlatESLintConfig[]>;
|
* Use `.gitignore` file to exclude files from ESLint.
|
||||||
|
*/
|
||||||
|
gitignore?: boolean;
|
||||||
|
},
|
||||||
|
): Promise<FlatESLintConfig[]>;
|
||||||
|
|
||||||
export const error = 'error';
|
export const error = 'error';
|
||||||
export const warn = 'warn';
|
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 type { FlatESLintConfig } from '@aet/eslint-define-config';
|
||||||
import * as tsParser from '@typescript-eslint/parser';
|
import * as tsParser from '@typescript-eslint/parser';
|
||||||
|
import prettier from 'eslint-config-prettier';
|
||||||
import importPlugin from 'eslint-plugin-import-x';
|
import importPlugin from 'eslint-plugin-import-x';
|
||||||
import { uniq } from 'lodash-es';
|
import { uniq } from 'lodash-es';
|
||||||
import tseslint from 'typescript-eslint';
|
import tseslint from 'typescript-eslint';
|
||||||
@ -14,15 +17,23 @@ import unicorn from './presets/unicorn';
|
|||||||
|
|
||||||
export { error, warn, off } from './constants';
|
export { error, warn, off } from './constants';
|
||||||
|
|
||||||
export async function extendConfig({
|
export async function extendConfig(
|
||||||
auto = true,
|
options:
|
||||||
middlewares: addMiddlewares = [],
|
| FlatESLintConfig[]
|
||||||
configs = [],
|
| {
|
||||||
}: {
|
auto?: boolean;
|
||||||
auto?: boolean;
|
middlewares?: Middleware[];
|
||||||
middlewares?: Middleware[];
|
configs: FlatESLintConfig[];
|
||||||
configs: FlatESLintConfig[];
|
gitignore?: boolean;
|
||||||
}): Promise<FlatESLintConfig[]> {
|
},
|
||||||
|
): Promise<FlatESLintConfig[]> {
|
||||||
|
const {
|
||||||
|
auto = true,
|
||||||
|
middlewares: addMiddlewares = [],
|
||||||
|
configs = [],
|
||||||
|
gitignore = true,
|
||||||
|
} = Array.isArray(options) ? { configs: options } : options;
|
||||||
|
|
||||||
const middlewares: Middleware[] = uniq([
|
const middlewares: Middleware[] = uniq([
|
||||||
() => import('./presets/custom'),
|
() => import('./presets/custom'),
|
||||||
...(auto ? checkEnv() : []),
|
...(auto ? checkEnv() : []),
|
||||||
@ -41,7 +52,7 @@ export async function extendConfig({
|
|||||||
...unicorn,
|
...unicorn,
|
||||||
stylistic,
|
stylistic,
|
||||||
{
|
{
|
||||||
name: 'eslint-rules: TypeScript and import-x',
|
name: 'eslint-rules/typescript-and-import-x',
|
||||||
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
|
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
@ -81,7 +92,7 @@ export async function extendConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'eslint-rules: .d.ts files',
|
name: 'eslint-rules/.d.ts-files',
|
||||||
files: ['*.d.ts'],
|
files: ['*.d.ts'],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/consistent-type-imports': off,
|
'@typescript-eslint/consistent-type-imports': off,
|
||||||
@ -106,5 +117,18 @@ export async function extendConfig({
|
|||||||
result.push(...configs);
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user