Skip to content

Commit

Permalink
feat!: set plugin alias of yml/ to yaml/
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 26, 2023
1 parent ffe00e1 commit 917dd48
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 62 deletions.
13 changes: 7 additions & 6 deletions README.md
Expand Up @@ -199,12 +199,13 @@ Check out the [configs](https://github.com/antfu/eslint-config/blob/main/src/con

Since flat config requires us to explicitly provide the plugin names (instead of mandatory convention from npm package name), we renamed some plugins to make overall scope more consistent and easier to write.

| Original Prefix | New Prefix | Source Plugin |
| --------------- | ---------- | ------------- |
| `i/*` | `import/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
| `n/*` | `node/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
| `@typescript-eslint/*` | `ts/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
| `@stylistic/*` | `style/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
| New Prefix | Original Prefix | Source Plugin |
| --- | --- | --- |
| `import/*` | `i/*` | [eslint-plugin-i](https://github.com/un-es/eslint-plugin-i) |
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |

When you want to overrides rules, or disable them inline, you need to update to the new prefix:

Expand Down
2 changes: 1 addition & 1 deletion src/configs/index.ts
Expand Up @@ -11,5 +11,5 @@ export * from './stylistic'
export * from './typescript'
export * from './unicorn'
export * from './vue'
export * from './yml'
export * from './yaml'
export * from './test'
51 changes: 51 additions & 0 deletions src/configs/yaml.ts
@@ -0,0 +1,51 @@
import type { FlatESLintConfigItem } from 'eslint-define-config'
import { GLOB_YAML } from '../globs'
import { parserYaml, pluginYaml } from '../plugins'
import { OFF } from '../flags'
import type { OptionsOverrides } from '../types'

export function yaml(options: OptionsOverrides = {}): FlatESLintConfigItem[] {
const {
overrides = {},
} = options

return [
{
plugins: {
yaml: pluginYaml as any,
},
},
{
files: [GLOB_YAML],
languageOptions: {
parser: parserYaml,
},
rules: {
'style/spaced-comment': OFF,

'yaml/block-mapping': 'error',
'yaml/block-mapping-question-indicator-newline': 'error',
'yaml/block-sequence': 'error',
'yaml/block-sequence-hyphen-indicator-newline': 'error',
'yaml/flow-mapping-curly-newline': 'error',
'yaml/flow-mapping-curly-spacing': 'error',
'yaml/flow-sequence-bracket-newline': 'error',
'yaml/flow-sequence-bracket-spacing': 'error',
'yaml/indent': ['error', 2],
'yaml/key-spacing': 'error',
'yaml/no-empty-key': 'error',
'yaml/no-empty-sequence-entry': 'error',
'yaml/no-irregular-whitespace': 'error',
'yaml/no-tab-indent': 'error',
'yaml/plain-scalar': 'error',

'yaml/quotes': ['error', { avoidEscape: false, prefer: 'single' }],
'yaml/spaced-comment': 'error',

'yaml/vue-custom-block/no-parsing-error': 'error',

...overrides,
},
},
]
}
51 changes: 0 additions & 51 deletions src/configs/yml.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/factory.ts
Expand Up @@ -20,7 +20,7 @@ import {
typescriptWithTypes,
unicorn,
vue,
yml,
yaml,
} from './configs'
import type { OptionsConfig } from './types'
import { combine } from './utils'
Expand Down Expand Up @@ -129,7 +129,7 @@ export function antfu(options: OptionsConfig & FlatESLintConfigItem = {}, ...use
}

if (options.yaml ?? true) {
configs.push(yml({
configs.push(yaml({
overrides: overrides.yaml,
}))
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins.ts
Expand Up @@ -13,10 +13,10 @@ export { default as pluginTs } from '@typescript-eslint/eslint-plugin'
export { default as pluginUnicorn } from 'eslint-plugin-unicorn'
export { default as pluginUnusedImports } from 'eslint-plugin-unused-imports'
export { default as pluginVue } from 'eslint-plugin-vue'
export { default as pluginYml } from 'eslint-plugin-yml'
export { default as pluginYaml } from 'eslint-plugin-yml'
export { default as pluginNoOnlyTests } from 'eslint-plugin-no-only-tests'

export { default as parserTs } from '@typescript-eslint/parser'
export { default as parserVue } from 'vue-eslint-parser'
export { default as parserYml } from 'yaml-eslint-parser'
export { default as parserYaml } from 'yaml-eslint-parser'
export { default as parserJsonc } from 'jsonc-eslint-parser'

0 comments on commit 917dd48

Please sign in to comment.