Skip to content

Commit

Permalink
Added YAML linter.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jun 6, 2024
1 parent 698266e commit ba16692
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 9 deletions.
41 changes: 32 additions & 9 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
import path from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'
import pluginJs from '@eslint/js'
import pluginTs from '@typescript-eslint/eslint-plugin'
import parserTs from '@typescript-eslint/parser'
import eslintPluginYml from 'eslint-plugin-yml'
import parserYml from "yaml-eslint-parser"
import globals from 'globals'
import licenseHeader from 'eslint-plugin-license-header'

// mimic CommonJS variables -- not needed if using CommonJS
const _filename = fileURLToPath(import.meta.url)
const _dirname = path.dirname(_filename)
const compat = new FlatCompat({ baseDirectory: _dirname, recommendedConfig: pluginJs.configs.recommended })

export default [
pluginJs.configs.recommended,
...compat.extends('standard-with-typescript'),
{
files: ['**/*.{js,ts}'],
languageOptions: {
parser: parserTs,
parserOptions: {
project: './tsconfig.json'
},
globals: {
...globals.jest,
...globals.node,
},
},
plugins: {
'@typescript-eslint': pluginTs,
'license-header': licenseHeader
},
rules: {
...pluginJs.configs.recommended.rules,
...pluginTs.configs["recommended-type-checked"].rules,
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/dot-notation': 'error',
Expand Down Expand Up @@ -72,5 +81,19 @@ export default [
]
]
}
},
...eslintPluginYml.configs['flat/standard'],
{
files: ["**/*.yaml", "**/*.yml"],
languageOptions: {
parser: parserYml
},
plugins: {
yml: eslintPluginYml
},
rules: {
'yml/no-empty-document': 'off',
'yml/quotes': ['error', { prefer: 'single' }]
}
}
]
40 changes: 40 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"eslint-plugin-license-header": "^0.6.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-yml": "^1.14.0",
"globals": "^15.0.0",
"jest": "^29.7.0",
"json-schema-to-typescript": "^14.0.4",
Expand Down

0 comments on commit ba16692

Please sign in to comment.