Skip to content

Commit 34007f6

Browse files
authored
Merge pull request #325 from pascalre/feat/lint-use-before-define
refactor(adapter): define isEmptyMapping before its use
2 parents dcee4ce + c2dd378 commit 34007f6

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎.eslintrc.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = {
1616
"plugin:import/typescript",
1717
],
1818
rules: {
19+
// the base rule does not understand typescript, so use the typescript-eslint variant
20+
"no-use-before-define": "off",
21+
"@typescript-eslint/no-use-before-define": "error",
1922
"semi": ["error", "never"],
2023
"sort-imports": [
2124
"error",

‎src/adapter/js-yaml-adapter.ts‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import { Settings } from "../settings"
44
import { SortUtil } from "../util/sort-util"
55
import { removeTrailingCharacters, splitYaml } from "../util/yaml-text"
66

7+
/**
8+
* @param value Any loaded yaml value.
9+
* @returns True for a mapping without keys, e.g. an empty document.
10+
*/
11+
const isEmptyMapping = (value: unknown): boolean =>
12+
typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0
13+
714
export class JsYamlAdapter {
815
settings: Settings
916

@@ -88,12 +95,4 @@ export class JsYamlAdapter {
8895
}
8996
return sortKeys
9097
}
91-
9298
}
93-
94-
/**
95-
* @param value Any loaded yaml value.
96-
* @returns True for a mapping without keys, e.g. an empty document.
97-
*/
98-
const isEmptyMapping = (value: unknown): boolean =>
99-
typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 0

0 commit comments

Comments
 (0)