diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index b7dab5e..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -build \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index b5ff5d6..0000000 --- a/.eslintrc +++ /dev/null @@ -1,18 +0,0 @@ -{ - "extends": ["eslint:recommended", "plugin:prettier/recommended"], - "env": { - "node": true, - "es6": true - }, - "parserOptions": { - "ecmaVersion": 2018 - }, - "overrides": [ - { - "files": ["test/**/*.js"], - "env": { - "mocha": true - } - } - ] -} diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index aebfc29..0000000 --- a/.prettierrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "printWidth": 120, - "tabWidth": 4, - "singleQuote": true, - "trailingComma": "none" -} diff --git a/beautify/index.js b/beautify/index.js index c0f08b6..dbf879c 100644 --- a/beautify/index.js +++ b/beautify/index.js @@ -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 diff --git a/clearSquare/index.js b/clearSquare/index.js index 9560aae..1fd1507 100644 --- a/clearSquare/index.js +++ b/clearSquare/index.js @@ -11,7 +11,6 @@ const lookAheadF = require('../simplify/lookAhead'); const lookBehindF = require('../simplify/lookBehind'); /** - * * @param {Config} cfg * @returns {clearSquare} */ diff --git a/clearSquare/relation.js b/clearSquare/relation.js index 4cce707..6a78d6f 100644 --- a/clearSquare/relation.js +++ b/clearSquare/relation.js @@ -5,7 +5,6 @@ const validateConfig = require('../validate/config'); const simplifyF = require('../simplify'); /** - * * @param {Config} cfg * @returns {relation} */ diff --git a/clearSquare/resolve.js b/clearSquare/resolve.js index 5ed9384..2108cf4 100644 --- a/clearSquare/resolve.js +++ b/clearSquare/resolve.js @@ -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); @@ -19,7 +17,6 @@ module.exports = function factory(cfg) { * @param {Query} query * @returns {Query} */ - function resolve(query) { validateQuery(query); diff --git a/config/index.js b/config/index.js index b12d500..5cb80f9 100644 --- a/config/index.js +++ b/config/index.js @@ -31,7 +31,7 @@ function config(config) { if (typeof config === 'string') { try { cfg = require('./' + config); - } catch (e) { + } catch { cfg = defaults; } } else { diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..f8b76d6 --- /dev/null +++ b/eslint.config.js @@ -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' + } + } +]; diff --git a/package.json b/package.json index 308d4e6..0818d3a 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "pretest": "npm run lint", - "test": "mocha \"test/**/*.spec.js\"", + "test": "node --test", "lint": "eslint ." }, "files": [ @@ -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" } } diff --git a/prettier.config.js b/prettier.config.js new file mode 100644 index 0000000..017caec --- /dev/null +++ b/prettier.config.js @@ -0,0 +1,6 @@ +module.exports = { + tabWidth: 4, + singleQuote: true, + printWidth: 120, + trailingComma: 'none' +}; diff --git a/simplify/expand.js b/simplify/expand.js index 31edf10..1ee52cb 100644 --- a/simplify/expand.js +++ b/simplify/expand.js @@ -20,7 +20,6 @@ module.exports = function factory(cfg) { * @param {boolean} isBackwards * @returns {string} */ - function expand(exp, bracket, isBackwards) { if (!exp) { return bracket; diff --git a/simplify/lookBehind.js b/simplify/lookBehind.js index 87d14a7..3182021 100644 --- a/simplify/lookBehind.js +++ b/simplify/lookBehind.js @@ -7,7 +7,6 @@ const validateConfig = require('../validate/config'); * @param {Config} cfg * @returns {lookBehind} */ - module.exports = function factory(cfg) { validateConfig(cfg); @@ -22,7 +21,6 @@ module.exports = function factory(cfg) { * @param {number} pos * @returns {[string, Array]} */ - function lookBehind(str, pos) { let isDelimiter; let firstOpFound = false; diff --git a/test/beautify.spec.js b/test/beautify.spec.js index 563f53d..949e665 100644 --- a/test/beautify.spec.js +++ b/test/beautify.spec.js @@ -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'); diff --git a/test/clearSquare-relation.spec.js b/test/clearSquare-relation.spec.js index 29fa34b..d3a67ab 100644 --- a/test/clearSquare-relation.spec.js +++ b/test/clearSquare-relation.spec.js @@ -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'); diff --git a/test/clearSquare-resolve.spec.js b/test/clearSquare-resolve.spec.js index 1232d1c..77c5e85 100644 --- a/test/clearSquare-resolve.spec.js +++ b/test/clearSquare-resolve.spec.js @@ -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()); diff --git a/test/clearSquare.spec.js b/test/clearSquare.spec.js index 9261172..d805437 100644 --- a/test/clearSquare.spec.js +++ b/test/clearSquare.spec.js @@ -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'); diff --git a/test/config-extend.spec.js b/test/config-extend.spec.js index c0761d3..9973fb2 100644 --- a/test/config-extend.spec.js +++ b/test/config-extend.spec.js @@ -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 () { diff --git a/test/config.spec.js b/test/config.spec.js index 14b558d..8eb6c53 100644 --- a/test/config.spec.js +++ b/test/config.spec.js @@ -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 () { diff --git a/test/lib-contains.spec.js b/test/lib-contains.spec.js index ab123ef..895a7ba 100644 --- a/test/lib-contains.spec.js +++ b/test/lib-contains.spec.js @@ -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 () { diff --git a/test/lib-escape.spec.js b/test/lib-escape.spec.js index c486226..6ba215d 100644 --- a/test/lib-escape.spec.js +++ b/test/lib-escape.spec.js @@ -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 () { diff --git a/test/operators-replace.spec.js b/test/operators-replace.spec.js index 57e85af..66330ff 100644 --- a/test/operators-replace.spec.js +++ b/test/operators-replace.spec.js @@ -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'); diff --git a/test/parse.spec.js b/test/parse.spec.js index ed75f0d..8b0099e 100644 --- a/test/parse.spec.js +++ b/test/parse.spec.js @@ -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('..'); diff --git a/test/simplify-expand.spec.js b/test/simplify-expand.spec.js index 2b3538b..5fac854 100644 --- a/test/simplify-expand.spec.js +++ b/test/simplify-expand.spec.js @@ -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'); diff --git a/test/simplify-identify.spec.js b/test/simplify-identify.spec.js index 43c22d0..a957709 100644 --- a/test/simplify-identify.spec.js +++ b/test/simplify-identify.spec.js @@ -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'); diff --git a/test/simplify-lookAhead.spec.js b/test/simplify-lookAhead.spec.js index 63983b8..103c8f9 100644 --- a/test/simplify-lookAhead.spec.js +++ b/test/simplify-lookAhead.spec.js @@ -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'); diff --git a/test/simplify-lookBehind.spec.js b/test/simplify-lookBehind.spec.js index 2dc8d42..9e9770c 100644 --- a/test/simplify-lookBehind.spec.js +++ b/test/simplify-lookBehind.spec.js @@ -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'); diff --git a/test/simplify-replace.spec.js b/test/simplify-replace.spec.js index 3852804..ef3fd5a 100644 --- a/test/simplify-replace.spec.js +++ b/test/simplify-replace.spec.js @@ -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 () { diff --git a/test/simplify.spec.js b/test/simplify.spec.js index 71a5ba7..6ccffb5 100644 --- a/test/simplify.spec.js +++ b/test/simplify.spec.js @@ -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'); diff --git a/test/tokenizer-Stmnt.spec.js b/test/tokenizer-Stmnt.spec.js index 92d4cfe..a461b80 100644 --- a/test/tokenizer-Stmnt.spec.js +++ b/test/tokenizer-Stmnt.spec.js @@ -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()); diff --git a/test/tokenizer.spec.js b/test/tokenizer.spec.js index 7cdfb02..8ac1a35 100644 --- a/test/tokenizer.spec.js +++ b/test/tokenizer.spec.js @@ -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'); diff --git a/tokenizer/Stmnt.js b/tokenizer/Stmnt.js index cfee096..1c3aa80 100644 --- a/tokenizer/Stmnt.js +++ b/tokenizer/Stmnt.js @@ -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); @@ -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; } } diff --git a/tokenizer/index.js b/tokenizer/index.js index b738924..0770fd0 100644 --- a/tokenizer/index.js +++ b/tokenizer/index.js @@ -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 @@ -27,7 +24,6 @@ module.exports = function factory(cfg) { } /** - * * @param str1 * @param pos * @param str2