@mouse_484/eslint-config 5.3.8 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mouse_484/eslint-config",
3
3
  "type": "module",
4
- "version": "5.3.8",
4
+ "version": "5.4.0",
5
5
  "author": "mouse_484",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/mouse484/config/tree/main/packages/eslint",
@@ -6,28 +6,38 @@ export default createConfigs({
6
6
  baseWithOption: 'tailwind',
7
7
  configs: [
8
8
  (meta) => {
9
+ if (!meta?.entryPoint) return
10
+
9
11
  return {
10
12
  name: 'tailwind',
11
13
  plugins: {
12
14
  tailwind: eslintPluginBetterTailwindcss,
13
15
  },
14
16
  rules: {
15
- // stylistic
16
- 'tailwind/multiline': ['warn', {
17
+ // Stylistic rules
18
+ 'tailwind/enforce-consistent-line-wrapping': ['warn', {
17
19
  group: 'newLine',
18
20
  }],
19
- 'tailwind/no-unnecessary-whitespace': 'warn',
20
- 'tailwind/sort-classes': 'warn',
21
+ 'tailwind/enforce-consistent-class-order': ['warn', {
22
+ order: 'improved',
23
+ }],
24
+ 'tailwind/enforce-consistent-variable-syntax': 'warn',
25
+ 'tailwind/enforce-consistent-important-position': 'error',
26
+ 'tailwind/enforce-shorthand-classes': 'warn',
21
27
  'tailwind/no-duplicate-classes': 'error',
22
- 'tailwind/enforce-consistent-variable-syntax': 'error',
23
- // correctness
24
- 'tailwind/no-unregistered-classes': 'off', // FIXME
28
+ 'tailwind/no-deprecated-classes': 'error',
29
+ 'tailwind/no-unnecessary-whitespace': 'warn',
30
+ // Correctness rules
31
+ 'tailwind/no-unregistered-classes': ['error', {
32
+ ignore: [],
33
+ detectComponentClasses: true,
34
+ }],
25
35
  'tailwind/no-conflicting-classes': 'error',
26
- 'tailwind/no-restricted-classes': 'off',
36
+ 'tailwind/no-restricted-classes': 'off', // arbitrary valuesの制限を今後検討
27
37
  },
28
38
  settings: {
29
- tailwind: {
30
- entryPoint: meta?.entryPoint,
39
+ 'better-tailwindcss': {
40
+ entryPoint: meta.entryPoint,
31
41
  },
32
42
  },
33
43
  }
@@ -0,0 +1,20 @@
1
+ import { GLOB_TS } from '@antfu/eslint-config'
2
+ import { createConfigs } from '../lib/factory.js'
3
+
4
+ export default createConfigs({
5
+ name: 'typescript',
6
+ baseWithOption: 'typescript',
7
+ configs: [
8
+ (meta) => {
9
+ if (meta && 'tsconfigPath' in meta && meta.tsconfigPath) {
10
+ return {
11
+ name: 'type-aware',
12
+ files: [GLOB_TS],
13
+ rules: {
14
+ 'ts/no-deprecated': 'error',
15
+ },
16
+ }
17
+ }
18
+ },
19
+ ],
20
+ })
package/src/index.d.ts CHANGED
@@ -1,15 +1,28 @@
1
- import type antfu from '@antfu/eslint-config'
1
+ import type {
2
+ TypedFlatConfigItem as AntfuTypedFlatConfigItem,
3
+ OptionsConfig,
4
+ Rules,
5
+ } from '@antfu/eslint-config'
6
+ import type { Linter } from 'eslint'
7
+ import type { FlatConfigComposer } from 'eslint-flat-config-utils'
8
+ import type { RuleOptions } from './lib/rules.gen'
2
9
 
3
- type AntfuParameters = Parameters<typeof antfu>
4
- type AntfuOptions = AntfuParameters['0']
5
- type AntfuUserConfigs = AntfuParameters['1'][]
6
-
7
- export type Options = AntfuOptions & {
8
- tailwind?: boolean | { entryPoint?: string }
10
+ type Awaitable<T> = T | Promise<T>
11
+ export interface TypedFlatConfigItem extends Omit<AntfuTypedFlatConfigItem, 'rules'> {
12
+ rules?: Rules & RuleOptions
13
+ }
14
+ type Config = Awaitable<
15
+ TypedFlatConfigItem
16
+ | TypedFlatConfigItem[]
17
+ | FlatConfigComposer<any, any>
18
+ | Linter.Config[]
19
+ >
20
+ export interface Options extends OptionsConfig, Omit<TypedFlatConfigItem, 'files'> {
21
+ tailwind?: false | { entryPoint: string }
9
22
  }
10
23
 
11
24
  export declare function mouse(
12
25
  options?: Options,
13
- ...configs: AntfuUserConfigs
26
+ ...configs: Config[]
14
27
  ): ReturnType<typeof antfu>
15
28
  export default mouse
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import perfectionist from './configs/perfectionist.js'
5
5
  import stylistic from './configs/stylistic.js'
6
6
  import svelte from './configs/svelte.js'
7
7
  import tailwind from './configs/tailwind.js'
8
+ import typescript from './configs/typescript.js'
8
9
  import unicorn from './configs/unicorn.js'
9
10
 
10
11
  /** @type {import('.').mouse} */
@@ -25,6 +26,7 @@ async function mouse(options, ...userConfigs) {
25
26
  ...unicorn(options),
26
27
  ...perfectionist(options),
27
28
  // Language specific
29
+ ...typescript(options),
28
30
  ...astro(options),
29
31
  ...svelte(options),
30
32
  // Tools
@@ -1,16 +1,16 @@
1
- import type { Rules, TypedFlatConfigItem } from '@antfu/eslint-config'
2
- import type { Options } from '..'
3
- import type { RuleOptions } from './rules.gen'
1
+ import type { Options, TypedFlatConfigItem } from '..'
4
2
 
5
3
  interface ConfigItem extends TypedFlatConfigItem {
6
4
  withOptions?: (keyof Options)[]
7
5
  name: string
8
- rules?: Rules & RuleOptions
9
6
  }
10
7
 
11
8
  type OnlyObject<T> = T extends object ? T : never
12
9
  export declare function createConfigs<T extends keyof Options = undefined>(parameters: {
13
10
  name: string
14
11
  baseWithOption?: T
15
- configs: (ConfigItem | ((meta?: OnlyObject<Options[T]>) => ConfigItem))[]
12
+ configs: (
13
+ ConfigItem
14
+ | ((meta?: OnlyObject<Options[T]>) => ConfigItem)
15
+ )[]
16
16
  }): (options: Options) => TypedFlatConfigItem[]
@@ -30,7 +30,10 @@ export function createConfigs({ name, baseWithOption, configs }) {
30
30
  }
31
31
  const meta = options[baseWithOption]
32
32
  // @ts-ignore
33
- configItem = configItem(typeof meta === 'object' ? meta : undefined)
33
+ configItem = configItem(typeof meta === 'object' ? meta : undefined) ?? {}
34
+ }
35
+ if (!configItem) {
36
+ return []
34
37
  }
35
38
  const { name: configName, withOptions = [], ...restConfig } = configItem
36
39
  return createConfig(