Skip to content

Commit

Permalink
feat: parse yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
sazanik committed Nov 20, 2024
1 parent ad25180 commit aa7c672
Show file tree
Hide file tree
Showing 23 changed files with 5,369 additions and 2,715 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '23.x'
node-version: '20.x'

- name: Install dependencies
run: make install
Expand Down
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node-options=--no-warnings --experimental-vm-modules
engine=jest
max_old_space_size=4096
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
gen-diff:
node bin/brain-games.js
node bin/gen-diff.js

publish:
npm publish --dry-run

install: deps-install
npx simple-git-hooks

gen-diff-demonstration:
gen-diff-demonstration-json:
node bin/gen-diff.js __fixtures__/file1.json __fixtures__/file2.json

gen-diff-demonstration-yaml:
node bin/gen-diff.js __fixtures__/file1.yml __fixtures__/file2.yml

deps-install:
npm ci --legacy-peer-deps

deps-update:
npx ncu -u

test:
npx jest
npm run test

test-coverage:
npx jest --coverage --coverageProvider=v8
npm run test:coverage

lint:
npx eslint .

link:
npm link

.PHONY: test
28 changes: 24 additions & 4 deletions __fixtures__/file1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
{
"host": "hexlet.io",
"timeout": 50,
"proxy": "123.234.53.22",
"follow": false
"common": {
"setting1": "Value 1",
"setting2": 200,
"setting3": true,
"setting6": {
"key": "value",
"doge": {
"wow": ""
}
}
},
"group1": {
"baz": "bas",
"foo": "bar",
"nest": {
"key": "value"
}
},
"group2": {
"abc": 12345,
"deep": {
"id": 45
}
}
}
17 changes: 17 additions & 0 deletions __fixtures__/file1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
common:
setting1: Value 1
setting2: 200
setting3: true
setting6:
key: value
doge:
wow: ''
group1:
baz: bas
foo: bar
nest:
key: value
group2:
abc: 12345
deep:
id: 45
32 changes: 29 additions & 3 deletions __fixtures__/file2.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
{
"timeout": 20,
"verbose": true,
"host": "hexlet.io"
"common": {
"follow": false,
"setting1": "Value 1",
"setting3": null,
"setting4": "blah blah",
"setting5": {
"key5": "value5"
},
"setting6": {
"key": "value",
"ops": "vops",
"doge": {
"wow": "so much"
}
}
},
"group1": {
"foo": "bar",
"baz": "bars",
"nest": "str"
},
"group3": {
"deep": {
"id": {
"number": 45
}
},
"fee": 100500
}
}
21 changes: 21 additions & 0 deletions __fixtures__/file2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
common:
follow: false
setting1: Value 1
setting3: null
setting4: blah blah
setting5:
key5: value5
setting6:
key: value
ops: vops
doge:
wow: so much
group1:
foo: bar
baz: bars
nest: str
group3:
deep:
id:
number: 45
fee: 100500
14 changes: 6 additions & 8 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import pluginJs from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import eslintConfigPrettier from 'eslint-config-prettier';

import { __dirname } from './globals.js';
import { __dirname } from './globalVariables.js';

const compat = new FlatCompat({
baseDirectory: __dirname,
Expand All @@ -16,20 +16,18 @@ export default [
settings: {
'import/resolver': {
node: {
extensions: ['.js'],
'extensions': ['.js', '.ts', '.json'],
moduleDirectory: ['node_modules', 'src'],
},
},
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
parserOptions: {
// Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
// This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
ecmaVersion: 2025,
ecmaVersion: 'latest',
sourceType: 'module',
},
},
Expand All @@ -51,12 +49,12 @@ export default [
],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'always',
},
],
// FIXME: getting error with ?? operator, when enabled
'import/named': ['off'],
'import/named': ['error'],
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-extraneous-dependencies': 'off',
Expand Down
File renamed without changes.
Loading

0 comments on commit aa7c672

Please sign in to comment.