Skip to content

Commit

Permalink
feat: replace mocha with node test-runner, update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokaiser committed Aug 13, 2024
1 parent cfb9d9f commit d7c8b73
Show file tree
Hide file tree
Showing 33 changed files with 67 additions and 87 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc

This file was deleted.

6 changes: 0 additions & 6 deletions .prettierrc

This file was deleted.

2 changes: 0 additions & 2 deletions beautify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ const assert = require('../error/assert');
const ArgumentError = require('../error/ArgumentError');

/**
*
* @param {Config} cfg
* @returns {beautify}
*/

module.exports = function factory(cfg) {
/**
* Take an internal Query object and generate a two-dimensional
Expand Down
1 change: 0 additions & 1 deletion clearSquare/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const lookAheadF = require('../simplify/lookAhead');
const lookBehindF = require('../simplify/lookBehind');

/**
*
* @param {Config} cfg
* @returns {clearSquare}
*/
Expand Down
1 change: 0 additions & 1 deletion clearSquare/relation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const validateConfig = require('../validate/config');
const simplifyF = require('../simplify');

/**
*
* @param {Config} cfg
* @returns {relation}
*/
Expand Down
3 changes: 0 additions & 3 deletions clearSquare/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ const validateConfig = require('../validate/config');
const escape = require('../lib/escape');

/**
*
* @param {Config} cfg
* @returns {resolve}
*/

module.exports = function factory(cfg) {
validateConfig(cfg);

Expand All @@ -19,7 +17,6 @@ module.exports = function factory(cfg) {
* @param {Query} query
* @returns {Query}
*/

function resolve(query) {
validateQuery(query);

Expand Down
2 changes: 1 addition & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function config(config) {
if (typeof config === 'string') {
try {
cfg = require('./' + config);
} catch (e) {
} catch {
cfg = defaults;
}
} else {
Expand Down
17 changes: 17 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const js = require('@eslint/js');
const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const globals = require('globals');

module.exports = [
js.configs.recommended,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node
},
ecmaVersion: 2020,
sourceType: 'commonjs'
}
}
];
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"pretest": "npm run lint",
"test": "mocha \"test/**/*.spec.js\"",
"test": "node --test",
"lint": "eslint ."
},
"files": [
Expand Down Expand Up @@ -44,12 +44,11 @@
"node": ">=18"
},
"devDependencies": {
"chai": "^4.3.7",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^5.0.0",
"mocha": "^10.2.0",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.9.0",
"pre-commit": "^1.2.2",
"prettier": "^3.0.1"
"prettier": "^3.3.3"
}
}
6 changes: 6 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
tabWidth: 4,
singleQuote: true,
printWidth: 120,
trailingComma: 'none'
};
1 change: 0 additions & 1 deletion simplify/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = function factory(cfg) {
* @param {boolean} isBackwards
* @returns {string}
*/

function expand(exp, bracket, isBackwards) {
if (!exp) {
return bracket;
Expand Down
2 changes: 0 additions & 2 deletions simplify/lookBehind.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const validateConfig = require('../validate/config');
* @param {Config} cfg
* @returns {lookBehind}
*/

module.exports = function factory(cfg) {
validateConfig(cfg);

Expand All @@ -22,7 +21,6 @@ module.exports = function factory(cfg) {
* @param {number} pos
* @returns {[string, Array]}
*/

function lookBehind(str, pos) {
let isDelimiter;
let firstOpFound = false;
Expand Down
4 changes: 2 additions & 2 deletions test/beautify.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const contains = require('../lib/contains');
const config = require('../config');
const fn = require('../beautify');
Expand Down
4 changes: 2 additions & 2 deletions test/clearSquare-relation.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../clearSquare/relation');

Expand Down
4 changes: 2 additions & 2 deletions test/clearSquare-resolve.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const contains = require('../lib/contains');
const config = require('../config');
const Stmnt = require('../tokenizer/Stmnt')(config());
Expand Down
4 changes: 2 additions & 2 deletions test/clearSquare.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../clearSquare');

Expand Down
4 changes: 2 additions & 2 deletions test/config-extend.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const fn = require('../config/extend')();

describe('config/extend()', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/config.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const fn = require('../config');

describe('config()', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/lib-contains.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const fn = require('../lib/contains');

describe('lib/contains()', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/lib-escape.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const fn = require('../lib/escape');

describe('lib/escape()', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/operators-replace.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../operators/replace');

Expand Down
4 changes: 2 additions & 2 deletions test/parse.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const contains = require('../lib/contains');
const config = require('../config');
const floraQL = require('..');
Expand Down
4 changes: 2 additions & 2 deletions test/simplify-expand.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../simplify/expand');

Expand Down
4 changes: 2 additions & 2 deletions test/simplify-identify.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../simplify/identify');

Expand Down
4 changes: 2 additions & 2 deletions test/simplify-lookAhead.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const contains = require('../lib/contains');
const config = require('../config');
const fn = require('../simplify/lookAhead');
Expand Down
4 changes: 2 additions & 2 deletions test/simplify-lookBehind.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const contains = require('../lib/contains');
const config = require('../config');
const fn = require('../simplify/lookBehind');
Expand Down
4 changes: 2 additions & 2 deletions test/simplify-replace.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const fn = require('../simplify/replace')();

describe('simplify/replace()', function () {
Expand Down
4 changes: 2 additions & 2 deletions test/simplify.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../simplify');

Expand Down
4 changes: 2 additions & 2 deletions test/tokenizer-Stmnt.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const Stmnt = require('../tokenizer/Stmnt')(config());

Expand Down
4 changes: 2 additions & 2 deletions test/tokenizer.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const assert = require('assert');

const { describe, it } = require('node:test');
const assert = require('node:assert');
const config = require('../config');
const fn = require('../tokenizer');

Expand Down
4 changes: 1 addition & 3 deletions tokenizer/Stmnt.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ const validateConfig = require('../validate/config');
const ArgumentError = require('../error/ArgumentError');

/**
*
* @param {Config} cfg
* @returns {Stmnt}
*/

module.exports = function factory(cfg) {
validateConfig(cfg);

Expand All @@ -20,7 +18,7 @@ module.exports = function factory(cfg) {
if (value[0] === cfg.string || value === 'true' || value === 'false' || value === 'null') {
try {
return JSON.parse(value);
} catch (e) {
} catch {
return null;
}
}
Expand Down
4 changes: 0 additions & 4 deletions tokenizer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ const ArgumentError = require('../error/ArgumentError');
const assert = require('../error/assert');

/**
*
* @param {Config} cfg
* @returns {tokenizer}
*/

module.exports = function factory(cfg) {
validateConfig(cfg);

let Stmnt = StmntF(cfg);

/**
*
* @param str1
* @param pos
* @param str2
Expand All @@ -27,7 +24,6 @@ module.exports = function factory(cfg) {
}

/**
*
* @param str1
* @param pos
* @param str2
Expand Down

0 comments on commit d7c8b73

Please sign in to comment.