Skip to content

Commit

Permalink
fix: refactor the codebase for readability and maintainability (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
KhudaDad414 committed Mar 17, 2023
1 parent f8cec58 commit 568f202
Show file tree
Hide file tree
Showing 27 changed files with 1,982 additions and 4,167 deletions.
86 changes: 18 additions & 68 deletions .eslintrc
@@ -1,11 +1,6 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"sonarjs",
"security",
"github"
],
"plugins": ["@typescript-eslint", "sonarjs", "security", "github"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
Expand All @@ -21,19 +16,18 @@
"eol-last": ["error", "always"],
"@typescript-eslint/no-explicit-any": 0,
"require-await": "error",
"@typescript-eslint/explicit-module-boundary-types": ["error", {"allowArgumentsExplicitlyTypedAsAny": true}],
"@typescript-eslint/explicit-module-boundary-types": [
"error",
{ "allowArgumentsExplicitlyTypedAsAny": true }
],
"sonarjs/no-small-switch": "off",
"no-underscore-dangle": "error",
"no-process-exit": "error",
"no-warning-comments": "error",
"no-loop-func": "error",
"curly": ["error"],
"no-multi-spaces": "error",
"consistent-return": 0,
"consistent-this": [
0,
"self"
],
"consistent-this": [0, "self"],
"func-style": 0,
"max-nested-callbacks": ["error", 3],
"camelcase": 0,
Expand Down Expand Up @@ -65,15 +59,9 @@
"no-throw-literal": 2,
"no-void": 2,
"radix": 2,
"wrap-iife": [
2,
"outside"
],
"wrap-iife": [2, "outside"],
"no-shadow": 0,
"no-use-before-define": [
2,
"nofunc"
],
"no-use-before-define": [2, "nofunc"],
"no-path-concat": 2,
"valid-jsdoc": [
0,
Expand All @@ -85,21 +73,14 @@
],
"no-spaced-func": 2,
"semi-spacing": 2,
"quotes": [
2,
"single"
],
"quotes": [2, "single"],
"key-spacing": [
2,
{
"beforeColon": false,
"afterColon": true
}
],
"indent": [
2,
2
],
"no-lonely-if": 2,
"no-floating-decimal": 2,
"brace-style": [
Expand All @@ -109,29 +90,17 @@
"allowSingleLine": true
}
],
"comma-style": [
2,
"last"
],
"comma-style": [2, "last"],
"no-multiple-empty-lines": [
2,
{
"max": 1
}
],
"no-nested-ternary": 2,
"operator-assignment": [
2,
"always"
],
"padded-blocks": [
2,
"never"
],
"quote-props": [
2,
"as-needed"
],
"operator-assignment": [2, "always"],
"padded-blocks": [2, "never"],
"quote-props": [2, "as-needed"],
"keyword-spacing": [
2,
{
Expand All @@ -140,22 +109,10 @@
"overrides": {}
}
],
"space-before-blocks": [
2,
"always"
],
"array-bracket-spacing": [
2,
"never"
],
"computed-property-spacing": [
2,
"never"
],
"space-in-parens": [
2,
"never"
],
"space-before-blocks": [2, "always"],
"array-bracket-spacing": [2, "never"],
"computed-property-spacing": [2, "never"],
"space-in-parens": [2, "never"],
"space-unary-ops": [
2,
{
Expand All @@ -167,10 +124,6 @@
"wrap-regex": 2,
//"linebreak-style": ["error", "unix"],
"linebreak-style": 0,
"semi": [
2,
"always"
],
"arrow-spacing": [
2,
{
Expand All @@ -182,10 +135,7 @@
"no-const-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"object-shorthand": [
2,
"always"
],
"object-shorthand": [2, "always"],
"prefer-arrow-callback": 2,
"prefer-const": 2,
"prefer-spread": 2,
Expand Down
6 changes: 6 additions & 0 deletions .prettierrc
@@ -0,0 +1,6 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 100
}
26 changes: 14 additions & 12 deletions examples/index.js
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Optimizer } = require('../lib/Optimizer');
const { Optimizer } = require('../lib/Optimizer')

const yaml = `
asyncapi: 2.0.0
Expand Down Expand Up @@ -79,14 +79,16 @@ components:
#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.
sentAt:
type: string
format: date-time`;
const optimizer = new Optimizer(yaml);
optimizer.getReport().then(report => {
console.log(report);
const optimizedDocument = optimizer.getOptimizedDocument({ rules: {
reuseComponents: true,
removeComponents: true,
moveToComponents: true
} });
console.log(optimizedDocument);
});
format: date-time`
const optimizer = new Optimizer(yaml)
optimizer.getReport().then((report) => {
//console.log(JSON.stringify(report))
const optimizedDocument = optimizer.getOptimizedDocument({
rules: {
reuseComponents: true,
removeComponents: true,
moveToComponents: true,
},
})
console.log(optimizedDocument)
})

0 comments on commit 568f202

Please sign in to comment.