From 88c9b40a09b271b25e4521371ef899120da20b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 19 Jul 2024 07:48:29 +0200 Subject: [PATCH] chore: run Prettier as part of tests --- .github/workflows/nodejs.yml | 2 ++ __tests__/molecule.js | 34 ++++++++++++------------ __tests__/molecule.queryFeatures.test.js | 4 +-- benchmark/.eslintrc.yml | 4 +-- package.json | 4 ++- scripts/build.js | 4 ++- scripts/extend/core.js | 2 +- 7 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 4499748b..7a9aa9f0 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -18,6 +18,8 @@ jobs: run: npm ci - name: Run ESLint run: npm run eslint + - name: Run Prettier + run: npm run prettier test: runs-on: ubuntu-latest strategy: diff --git a/__tests__/molecule.js b/__tests__/molecule.js index a53833f1..da08f109 100644 --- a/__tests__/molecule.js +++ b/__tests__/molecule.js @@ -42,21 +42,25 @@ describe('from and to SMILES', () => { expect(mol.toIsomericSmiles({ kekulizedOutput: true })).toBe('C1=CC=CC=C1'); expect(mol.toIsomericSmiles({ createSmarts: true })).toBe('c1ccccc1'); mol.setAtomMapNo(0, 1); - expect(mol.toIsomericSmiles({ includeMapping: true })).toBe('c1cc[cH:1]cc1'); + expect(mol.toIsomericSmiles({ includeMapping: true })).toBe( + 'c1cc[cH:1]cc1', + ); const fragment = Molecule.fromSmiles('C1=CC=CC=C1C'); fragment.setFragment(true); - fragment.setAtomicNo(6, 1) - expect(fragment.toIsomericSmiles({ createSmarts: true })).toBe('c1cc[c;!H0]cc1'); - }) + fragment.setAtomicNo(6, 1); + expect(fragment.toIsomericSmiles({ createSmarts: true })).toBe( + 'c1cc[c;!H0]cc1', + ); + }); }); it('smarts options', () => { const fragment = Molecule.fromSmiles('C1=CC=CC=C1C'); fragment.setFragment(true); - fragment.setAtomicNo(6, 1) + fragment.setAtomicNo(6, 1); expect(fragment.toSmarts()).toBe('c1cc[c;!H0]cc1'); -}) +}); describe('Molecule', () => { it('medley', () => { @@ -178,22 +182,22 @@ describe('Molecule', () => { it('getFinalRanks', () => { const molecule = Molecule.fromSmiles('CCC'); - molecule.setAtomicNo(0, 8) + molecule.setAtomicNo(0, 8); const atoms = []; const ranks = [...molecule.getFinalRanks()]; for (let i = 0; i < molecule.getAllAtoms(); i++) { atoms.push(molecule.getAtomLabel(i), ranks[i]); } - expect(atoms).toStrictEqual(['O', 3, 'C', 2, 'C', 1]) + expect(atoms).toStrictEqual(['O', 3, 'C', 2, 'C', 1]); const molecule2 = Molecule.fromSmiles('CCC'); - molecule2.setAtomicNo(2, 8) + molecule2.setAtomicNo(2, 8); const atoms2 = []; const ranks2 = [...molecule2.getFinalRanks()]; for (let i = 0; i < molecule2.getAllAtoms(); i++) { atoms2.push(molecule2.getAtomLabel(i), ranks2[i]); } - expect(atoms2).toStrictEqual(['C', 1, 'C', 2, 'O', 3]) - }) + expect(atoms2).toStrictEqual(['C', 1, 'C', 2, 'O', 3]); + }); it('getFinalRanks of xMolecule', () => { const molecule = Molecule.fromSmiles('CCCO'); @@ -210,12 +214,8 @@ describe('Molecule', () => { } const ranks = [...molecule.getFinalRanks()]; - expect(ranks).toStrictEqual([ - 3, 1, 2, 4, 11, - 10, 9, 5, 6, 7, - 8, 12 - ]) - }) + expect(ranks).toStrictEqual([3, 1, 2, 4, 11, 10, 9, 5, 6, 7, 8, 12]); + }); it('should have a method that returns the OCL object', () => { const molecule = Molecule.fromSmiles('C'); diff --git a/__tests__/molecule.queryFeatures.test.js b/__tests__/molecule.queryFeatures.test.js index dacd4a4e..6becf3cb 100644 --- a/__tests__/molecule.queryFeatures.test.js +++ b/__tests__/molecule.queryFeatures.test.js @@ -47,7 +47,7 @@ test('bond query features cycle of 4 atoms with aromatic bond', () => { expect(firstBondQueryFeatures.ringSize).toBe(4); expect(firstBondQueryFeatures.aromatic).toBe(true); expect(firstBondQueryFeatures.nonAromatic).toBe(false); -}) +}); test('bond query features atom bridge 2 to 7', () => { const molecule = Molecule.fromIDCode('eM@HzCNDh'); @@ -55,4 +55,4 @@ test('bond query features atom bridge 2 to 7', () => { expect(firstBondQueryFeatures.brigdeMin).toBe(2); expect(firstBondQueryFeatures.brigdeSpan).toBe(5); expect(firstBondQueryFeatures.nonAromatic).toBe(false); -}) \ No newline at end of file +}); diff --git a/benchmark/.eslintrc.yml b/benchmark/.eslintrc.yml index 4e8c81c4..30d99f6d 100644 --- a/benchmark/.eslintrc.yml +++ b/benchmark/.eslintrc.yml @@ -1,3 +1,3 @@ rules: - import/no-unresolved: [error, { ignore: ['./distold']}] - no-console: off \ No newline at end of file + import/no-unresolved: [error, { ignore: ['./distold'] }] + no-console: off diff --git a/package.json b/package.json index 9d0f2af3..86040ab3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "build-full-pretty": "npm run build:pretty -- -m full", "eslint": "eslint __tests__ scripts benchmark", "eslint-fix": "npm run eslint -- --fix", - "test": "npm run build && npm run test-only && npm run eslint", + "prettier": "prettier --check __tests__ scripts benchmark", + "prettier-write": "prettier --write __tests__ scripts benchmark", + "test": "npm run build && npm run test-only && npm run eslint && npm run prettier", "test-only": "jest" }, "main": "./core.js", diff --git a/scripts/build.js b/scripts/build.js index c986a0fc..03073466 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -235,7 +235,9 @@ async function build() { log('Creating ESM-compatible entry points'); for (const mod of modules) { log(`Creating ESM-compatible entry point for module ${mod.name}${suffix}`); - const moduleInstance = require(`../dist/openchemlib-${mod.name}${suffix}.js`); + const moduleInstance = require( + `../dist/openchemlib-${mod.name}${suffix}.js`, + ); const moduleExports = Object.keys(moduleInstance).map( (moduleExport) => `exports.${moduleExport} = OCL.${moduleExport};`, ); diff --git a/scripts/extend/core.js b/scripts/extend/core.js index 32bbe782..7a6ea0b8 100644 --- a/scripts/extend/core.js +++ b/scripts/extend/core.js @@ -16,7 +16,7 @@ module.exports = function extendCore(exports) { funcTol: 1e-6, }; ForceFieldMMFF94.prototype.minimise = function minimise(options) { - options = { ...defaultMinimiseOptions, ...options}; + options = { ...defaultMinimiseOptions, ...options }; return this._minimise(options.maxIts, options.gradTol, options.funcTol); }; };