Skip to content

Commit 568f202

Browse files
authored
fix: refactor the codebase for readability and maintainability (#146)
1 parent f8cec58 commit 568f202

27 files changed

+1982
-4167
lines changed

.eslintrc

Lines changed: 18 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
{
22
"parser": "@typescript-eslint/parser",
3-
"plugins": [
4-
"@typescript-eslint",
5-
"sonarjs",
6-
"security",
7-
"github"
8-
],
3+
"plugins": ["@typescript-eslint", "sonarjs", "security", "github"],
94
"extends": [
105
"eslint:recommended",
116
"plugin:@typescript-eslint/recommended",
@@ -21,19 +16,18 @@
2116
"eol-last": ["error", "always"],
2217
"@typescript-eslint/no-explicit-any": 0,
2318
"require-await": "error",
24-
"@typescript-eslint/explicit-module-boundary-types": ["error", {"allowArgumentsExplicitlyTypedAsAny": true}],
19+
"@typescript-eslint/explicit-module-boundary-types": [
20+
"error",
21+
{ "allowArgumentsExplicitlyTypedAsAny": true }
22+
],
2523
"sonarjs/no-small-switch": "off",
2624
"no-underscore-dangle": "error",
2725
"no-process-exit": "error",
2826
"no-warning-comments": "error",
2927
"no-loop-func": "error",
30-
"curly": ["error"],
3128
"no-multi-spaces": "error",
3229
"consistent-return": 0,
33-
"consistent-this": [
34-
0,
35-
"self"
36-
],
30+
"consistent-this": [0, "self"],
3731
"func-style": 0,
3832
"max-nested-callbacks": ["error", 3],
3933
"camelcase": 0,
@@ -65,15 +59,9 @@
6559
"no-throw-literal": 2,
6660
"no-void": 2,
6761
"radix": 2,
68-
"wrap-iife": [
69-
2,
70-
"outside"
71-
],
62+
"wrap-iife": [2, "outside"],
7263
"no-shadow": 0,
73-
"no-use-before-define": [
74-
2,
75-
"nofunc"
76-
],
64+
"no-use-before-define": [2, "nofunc"],
7765
"no-path-concat": 2,
7866
"valid-jsdoc": [
7967
0,
@@ -85,21 +73,14 @@
8573
],
8674
"no-spaced-func": 2,
8775
"semi-spacing": 2,
88-
"quotes": [
89-
2,
90-
"single"
91-
],
76+
"quotes": [2, "single"],
9277
"key-spacing": [
9378
2,
9479
{
9580
"beforeColon": false,
9681
"afterColon": true
9782
}
9883
],
99-
"indent": [
100-
2,
101-
2
102-
],
10384
"no-lonely-if": 2,
10485
"no-floating-decimal": 2,
10586
"brace-style": [
@@ -109,29 +90,17 @@
10990
"allowSingleLine": true
11091
}
11192
],
112-
"comma-style": [
113-
2,
114-
"last"
115-
],
93+
"comma-style": [2, "last"],
11694
"no-multiple-empty-lines": [
11795
2,
11896
{
11997
"max": 1
12098
}
12199
],
122100
"no-nested-ternary": 2,
123-
"operator-assignment": [
124-
2,
125-
"always"
126-
],
127-
"padded-blocks": [
128-
2,
129-
"never"
130-
],
131-
"quote-props": [
132-
2,
133-
"as-needed"
134-
],
101+
"operator-assignment": [2, "always"],
102+
"padded-blocks": [2, "never"],
103+
"quote-props": [2, "as-needed"],
135104
"keyword-spacing": [
136105
2,
137106
{
@@ -140,22 +109,10 @@
140109
"overrides": {}
141110
}
142111
],
143-
"space-before-blocks": [
144-
2,
145-
"always"
146-
],
147-
"array-bracket-spacing": [
148-
2,
149-
"never"
150-
],
151-
"computed-property-spacing": [
152-
2,
153-
"never"
154-
],
155-
"space-in-parens": [
156-
2,
157-
"never"
158-
],
112+
"space-before-blocks": [2, "always"],
113+
"array-bracket-spacing": [2, "never"],
114+
"computed-property-spacing": [2, "never"],
115+
"space-in-parens": [2, "never"],
159116
"space-unary-ops": [
160117
2,
161118
{
@@ -167,10 +124,6 @@
167124
"wrap-regex": 2,
168125
//"linebreak-style": ["error", "unix"],
169126
"linebreak-style": 0,
170-
"semi": [
171-
2,
172-
"always"
173-
],
174127
"arrow-spacing": [
175128
2,
176129
{
@@ -182,10 +135,7 @@
182135
"no-const-assign": 2,
183136
"no-this-before-super": 2,
184137
"no-var": 2,
185-
"object-shorthand": [
186-
2,
187-
"always"
188-
],
138+
"object-shorthand": [2, "always"],
189139
"prefer-arrow-callback": 2,
190140
"prefer-const": 2,
191141
"prefer-spread": 2,

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 100
6+
}

examples/index.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// eslint-disable-next-line @typescript-eslint/no-var-requires
2-
const { Optimizer } = require('../lib/Optimizer');
2+
const { Optimizer } = require('../lib/Optimizer')
33

44
const yaml = `
55
asyncapi: 2.0.0
@@ -79,14 +79,16 @@ components:
7979
#this schema is ref-ed in one channel and used full form in another. library should be able to identify and ref the second channel as well.
8080
sentAt:
8181
type: string
82-
format: date-time`;
83-
const optimizer = new Optimizer(yaml);
84-
optimizer.getReport().then(report => {
85-
console.log(report);
86-
const optimizedDocument = optimizer.getOptimizedDocument({ rules: {
87-
reuseComponents: true,
88-
removeComponents: true,
89-
moveToComponents: true
90-
} });
91-
console.log(optimizedDocument);
92-
});
82+
format: date-time`
83+
const optimizer = new Optimizer(yaml)
84+
optimizer.getReport().then((report) => {
85+
//console.log(JSON.stringify(report))
86+
const optimizedDocument = optimizer.getOptimizedDocument({
87+
rules: {
88+
reuseComponents: true,
89+
removeComponents: true,
90+
moveToComponents: true,
91+
},
92+
})
93+
console.log(optimizedDocument)
94+
})

0 commit comments

Comments
 (0)