Skip to content

Commit

Permalink
chore: release
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Mar 28, 2024
1 parent 204ac10 commit 9b733ca
Show file tree
Hide file tree
Showing 30 changed files with 843 additions and 99 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules
.idea
.DS_Store
dist
playground
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ pnpm add eslint @minko-fe/eslint-config -D

##### eslint.config.js
```js
import { defineConfig } from '@minko-fe/eslint-config'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)

const { defineConfig } = require('@minko-fe/eslint-config')


export default defineConfig([
// your config
Expand All @@ -31,6 +35,51 @@ export default defineConfig([
})
```
#### astro
```bash
pnpm add prettier-plugin-astro -D
```
`.prettierrc.js`
```js
/** @type {import("prettier").Config} */
export default {
overrides: [
{
files: '*.astro',
options: {
parser: 'astro',
},
},
],
plugins: ['prettier-plugin-astro'],
}

```
#### svelte
```bash
pnpm add prettier-plugin-svelte -D
```
`.prettierrc.js`
```js
/** @type {import("prettier").Config} */
export default {
overrides: [
{
files: '*.svelte',
options: {
parser: 'svelte',
},
},
],
plugins: ['prettier-plugin-svelte'],
}
```
<img style="width: 14px; height: 14px" src="https://raw.githubusercontent.com/vscode-icons/vscode-icons/70702eb811036276c75b7ddf33060ee109026fe9/icons/file_type_light_prettier.svg" />
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ require('sucrase/register')
const { defineConfig } = require('./packages/eslint/index.ts')

export default defineConfig([], {
gitignore: false,
sortObjects: true,
})
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "eslint . --fix",
"up": "taze -r -w -I",
"prepare": "simple-git-hooks",
"bump": "changeset",
"changeset": "changeset",
"version": "changeset version && changeset tag"
},
"devDependencies": {
Expand All @@ -31,7 +31,9 @@
"@minko-fe/eslint-config": "workspace:*",
"@minko-fe/tsconfig": "workspace:*",
"@types/node": "^20.8.3",
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"prettier-plugin-astro": "^0.13.0",
"prettier-plugin-svelte": "^3.2.2",
"simple-git-hooks": "^2.9.0",
"sucrase": "^3.34.0",
"taze": "^0.11.3",
Expand Down
11 changes: 11 additions & 0 deletions packages/eslint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @minko-fe/eslint-config

## 2.2.0

### Minor Changes

- feat: support astro/svelte/node

### Patch Changes

- Updated dependencies
- @minko-fe/prettier-config@2.1.0

## 2.1.2

### Patch Changes
Expand Down
3 changes: 0 additions & 3 deletions packages/eslint/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# Eslint config

## Known issues

- `eslint-plugin-tailwindcss` only support tailwinscss version >= 3.3.0
38 changes: 38 additions & 0 deletions packages/eslint/configs/astro.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as parser from 'astro-eslint-parser'
import { type FlatESLintConfigItem, type Rules } from 'eslint-define-config'
import eslintPluginAstro from 'eslint-plugin-astro'
import globals from 'globals'
import { GLOB_ASTRO } from '../globs'
import { parserTypeScript } from '../plugins'

export function resolveAstro(ts?: boolean): FlatESLintConfigItem[] {
return [
{
files: [GLOB_ASTRO],
languageOptions: {
globals: {
...globals.node,
// Astro object
Astro: false,
// JSX Fragment
Fragment: false,
},
parser,
parserOptions: {
extraFileExtensions: ['.astro'],
parser: parserTypeScript,
},
// The script of Astro components uses ESM.
sourceType: 'module',
},
plugins: {
astro: eslintPluginAstro,
},
processor: ts ? 'astro/client-side-ts' : 'astro/astro',
rules: {
...eslintPluginAstro.configs.recommended.rules,
'astro/no-set-text-directive': ['error'],
} as Rules,
},
]
}
3 changes: 2 additions & 1 deletion packages/eslint/configs/ignores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ function gitignore(options: FlatGitignoreOptions = {}): FlatConfigItem {
}
}

export const ignores: FlatESLintConfigItem[] = [{ ignores: [...GLOB_EXCLUDE, ...gitignore().ignores] }]
export const ignores: FlatESLintConfigItem[] = [{ ignores: GLOB_EXCLUDE }]
export const gitignores: FlatConfigItem[] = [{ ignores: gitignore().ignores }]
3 changes: 3 additions & 0 deletions packages/eslint/configs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ export * from './unicorn'
export * from './vue'
export * from './yml'
export * from './tailwindcss'
export * from './node'
export * from './astro'
export * from './svelte'
19 changes: 19 additions & 0 deletions packages/eslint/configs/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { FlatESLintConfigItem } from 'eslint-define-config'
import { pluginNode } from '../plugins'

export const node: FlatESLintConfigItem[] = [
{
plugins: {
node: pluginNode,
},
rules: {
'node/handle-callback-err': ['error', '^(err|error)$'],
'node/no-deprecated-api': 'error',
'node/no-exports-assign': 'error',
'node/no-new-require': 'error',
'node/no-path-concat': 'error',
'node/no-unsupported-features/es-builtins': 'error',
'node/process-exit-as-throw': 'error',
},
},
]
11 changes: 2 additions & 9 deletions packages/eslint/configs/prettier.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
// @ts-expect-error missing types
import prettierConfig from '@minko-fe/prettier-config'
import { type FlatESLintConfigItem } from 'eslint-define-config'
import { configPrettier, pluginPrettier } from '../plugins'

const prettierConflictRules = { ...configPrettier.rules }
delete prettierConflictRules['vue/html-self-closing']
import pluginPrettier from 'eslint-plugin-prettier/recommended'

export const prettier: FlatESLintConfigItem[] = [
{
plugins: {
prettier: pluginPrettier,
},
...pluginPrettier,
rules: {
...prettierConflictRules,
...pluginPrettier.configs.recommended.rules,
'prettier/prettier': ['warn', prettierConfig],
},
},
Expand Down
29 changes: 29 additions & 0 deletions packages/eslint/configs/svelte.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { type FlatESLintConfigItem, type Rules } from 'eslint-define-config'
import { GLOB_SVELTE } from '../globs'
import { pluginTypeScript } from '../plugins'

export async function asyncSvelte(): Promise<FlatESLintConfigItem[]> {
const eslintPluginSvelte = (await import('eslint-plugin-svelte')).default
const svelteParser = (await import('svelte-eslint-parser')).default
return [
{
files: [GLOB_SVELTE],
languageOptions: {
parser: svelteParser,
parserOptions: {
extraFileExtensions: ['.svelte'],
parser: '@typescript-eslint/parser',
},
},
plugins: {
'@typescript-eslint': pluginTypeScript,
'svelte': eslintPluginSvelte,
},
processor: eslintPluginSvelte.processors.svelte,
rules: {
...eslintPluginSvelte.configs.recommended.rules,
...eslintPluginSvelte.configs.prettier.rules,
} as Rules,
},
]
}
12 changes: 11 additions & 1 deletion packages/eslint/globs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export const GLOB_JSX = '**/*.?([cm])jsx'
export const GLOB_TS = '**/*.?([cm])ts'
export const GLOB_TSX = '**/*.?([cm])tsx'

export const GLOB_ASTRO = '**/*.astro'
export const GLOB_SVELTE = '**/*.svelte'

export const GLOB_STYLE = '**/*.{c,le,sc}ss'
export const GLOB_CSS = '**/*.css'
export const GLOB_LESS = '**/*.less'
Expand Down Expand Up @@ -36,7 +39,12 @@ export const GLOB_TSCONFIG = /** @type {const} */ ['**/tsconfig.json', '**/tscon
export const GLOB_PACKAGEJSON = /** @type {const} */ '**/package.json'
export const GLOB_NODE_MODULES = /** @type {const} */ '**/node_modules'
export const GLOB_DIST = /** @type {const} */ '**/dist'
export const GLOB_LOCKFILE = /** @type {const} */ ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml']
export const GLOB_LOCKFILE = /** @type {const} */ [
'**/package-lock.json',
'**/yarn.lock',
'**/pnpm-lock.yaml',
'**/bun.lockb',
]

export const GLOB_EXCLUDE = /** @type {const} */ [
GLOB_NODE_MODULES,
Expand All @@ -59,6 +67,8 @@ export const GLOB_EXCLUDE = /** @type {const} */ [
'**/.idea',
'**/.output',
'**/.vite-inspect',
'**/.astro',
'**/.svelte-kit',

'**/CHANGELOG*.md',
'**/*.min.*',
Expand Down
16 changes: 15 additions & 1 deletion packages/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@minko-fe/eslint-config",
"version": "2.1.2",
"version": "2.2.0",
"description": "eslint-config",
"type": "module",
"repository": {
Expand All @@ -27,30 +27,42 @@
},
"peerDependencies": {
"eslint": "^8.56.0",
"prettier-plugin-astro": "^0.13.0",
"prettier-plugin-svelte": "^3.2.2",
"tailwindcss": "^3.2.2"
},
"peerDependenciesMeta": {
"tailwindcss": {
"optional": true
},
"prettier-plugin-astro": {
"optional": true
},
"prettier-plugin-svelte": {
"optional": true
}
},
"dependencies": {
"@minko-fe/prettier-config": "workspace:*",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"astro-eslint-parser": "^0.16.3",
"eslint-config-prettier": "^9.1.0",
"eslint-define-config": "^1.24.1",
"eslint-plugin-antfu": "^2.1.2",
"eslint-plugin-astro": "^0.33.1",
"eslint-plugin-disable-autofix": "^4.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsonc": "^2.13.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-tailwindcss-3.11.0": "npm:[email protected]",
"eslint-plugin-tailwindcss-3.13.1": "npm:[email protected]",
"eslint-plugin-tailwindcss-3.14.1": "npm:[email protected]",
Expand All @@ -65,13 +77,15 @@
"parse-gitignore": "^2.0.0",
"prettier": "^3.2.4",
"semver": "^7.5.4",
"svelte-eslint-parser": "^0.33.1",
"typescript": "^5.3.3",
"yaml-eslint-parser": "^1.2.2"
},
"devDependencies": {
"@types/semver": "^7.5.6",
"eslint": "^8.56.0",
"sucrase": "^3.35.0",
"svelte": "^4.2.7",
"tailwindcss": "3.3.2"
},
"pnpm": {
Expand Down
Loading

0 comments on commit 9b733ca

Please sign in to comment.