Skip to content

Commit

Permalink
Refactor all files to be consistent with deepsource, sonarcloud, code…
Browse files Browse the repository at this point in the history
…beat and codeclimate
  • Loading branch information
nktnet committed Oct 11, 2023
1 parent 2704be5 commit 5950131
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const { privateFunction } = jewire(
### 2.1. relativePath

Path to the module relative to the current file, similar to CommonJS [require](https://nodejs.org/api/modules.html#requireid).
- e.g. `'../animals/cats.js'`
- e.g. `'../animals/cats.js'`

### 2.2. options

Expand Down Expand Up @@ -150,7 +150,7 @@ process.cwd()
</td>
<td>
<pre>
(o) => JSON.parse(
o => JSON.parse(
JSON.stringify(
o
)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "git",
"url": "https://github.com/nktnet1/jewire"
},
"version": "0.0.2",
"version": "0.0.3",
"files": [
"dist"
],
Expand Down
5 changes: 3 additions & 2 deletions src/clone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ const functionClone = <T extends (...args: any[]) => any>(fn: T, clone: CloneFn)
* @param target object instance to decorate methods around
*/
function decorateClassMethodClone<T extends { new (...args: any[]): Record<string, any> }>(target: T): T {
function decorateClassMethodClone(target: any) {
const decorateMethod = (obj: Record<string, any>, key: string | symbol) => {
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
if (!descriptor || !descriptor.configurable) {
/* istanbul ignore next */
if (!descriptor?.configurable) {
return;
}
const { value } = descriptor;
Expand Down
6 changes: 3 additions & 3 deletions src/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ for errors: ${error}`
const classes: string[] = [];

ast.body.forEach((node) => {
if (node.type === 'FunctionDeclaration') {
functions.push(node.id!.name);
if (node.type === 'FunctionDeclaration' && node.id !== null) {
functions.push(node.id.name);
} else if (node.type === 'VariableDeclaration') {
node.declarations.forEach((declaration) => {
if (declaration.id.type === 'Identifier') {
variables.push(declaration.id.name);
}
});
} else if (node.type === 'ClassDeclaration' && node.id) {
} else if (node.type === 'ClassDeclaration' && node.id !== null) {
classes.push(node.id.name);
}
});
Expand Down
6 changes: 3 additions & 3 deletions tests/classes/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class TestClass {
}

static getObject() {
return {
key1: 'value1', key2: 2,
};
return { key1: 'value1', key2: 2 };
}

static getArrayOfObjects() {
Expand All @@ -63,3 +61,5 @@ class TestClass {
Object.defineProperty(TestClass.prototype, 'makeThisNonConfigurable', {
configurable: false,
});

Object.defineProperty(TestClass.prototype, 'null', {});
3 changes: 1 addition & 2 deletions tests/classes/classes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import jewire from '../../src';
const { TestClass } = jewire('./classes');

describe('Instance methods', () => {
let instance;

let instance = null;
beforeEach(() => {
instance = new TestClass('Tam', ['Ham', 'Spam']);
});
Expand Down
8 changes: 2 additions & 6 deletions tests/functions/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ const getDeeplyNestedObject = () => {
};

const getArrayOfObjects = () => [
{
name: 'Tam',
},
{
name: 'Ham',
},
{ name: 'Tam' },
{ name: 'Ham' },
];

0 comments on commit 5950131

Please sign in to comment.