Skip to content

Commit

Permalink
Convert compiler & tests to ESM; update all packages
Browse files Browse the repository at this point in the history
  • Loading branch information
steeelydan committed Aug 27, 2024
1 parent e26daf9 commit 7edc8c5
Show file tree
Hide file tree
Showing 54 changed files with 3,817 additions and 1,102 deletions.
6 changes: 4 additions & 2 deletions compiler/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ module.exports = {
},
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
overrides: [],
ignorePatterns: ['/*', '!/src', "**/*.js"],
ignorePatterns: ['/*', '!/src', '**/*.js'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: '2021',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
plugins: ['@typescript-eslint', 'import'],
rules: {
'default-case': 'error',
'default-case-last': 'error',
'no-fallthrough': 'error',
'no-warning-comments': 'warn',
'prefer-const': 'warn',
'import/extensions': ['error', 'always'],
'@typescript-eslint/no-explicit-any': ['warn'],
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/ban-ts-comment': 1,
Expand Down
4,681 changes: 3,696 additions & 985 deletions compiler/package-lock.json

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"type": "module",
"types": "dist/types/index.d.ts",
"exports": {
".": {
Expand All @@ -21,8 +22,8 @@
"dist:esm": "tsc -p tsconfig.esm.json",
"dist:cjs": "tsc -p tsconfig.cjs.json",
"dist": "npm run parseTypeDocs && rm -rf ./dist/* && npm run dist:esm && npm run dist:cjs && node ./scripts/setVersionConstant.mjs",
"test": "npm run dist:cjs && c8 mocha './dist/cjs/**/*.spec.js' --reporter-option maxDiffSize=0",
"test:single": "mocha './dist/cjs/**/*.spec.js' --reporter-option maxDiffSize=0 --grep",
"test": "npm run dist:esm && c8 mocha './dist/esm/**/*.spec.js' --reporter-option maxDiffSize=0",
"test:single": "mocha './dist/esm/**/*.spec.js' --reporter-option maxDiffSize=0 --grep",
"check": "eslint ./src && tsc --noEmit",
"parseTypeDocs": "node ./scripts/parseTypeDocs.mjs"
},
Expand All @@ -43,22 +44,23 @@
"author": "steeelydan",
"license": "GPL-3.0",
"dependencies": {
"acorn": "8.9.0",
"joi": "17.9.2"
"acorn": "8.12.1",
"joi": "17.13.3"
},
"devDependencies": {
"@types/chai": "4.3.5",
"@types/estree": "1.0.1",
"@types/mocha": "10.0.1",
"@types/node": "20.3.3",
"@typescript-eslint/eslint-plugin": "5.60.1",
"@typescript-eslint/parser": "5.60.1",
"c8": "8.0.0",
"chai": "4.3.7",
"concurrently": "8.2.0",
"eslint": "8.44.0",
"mocha": "10.2.0",
"tsc-watch": "6.0.4",
"typescript": "5.1.6"
"@types/chai": "4.3.18",
"@types/estree": "1.0.5",
"@types/mocha": "10.0.7",
"@types/node": "22.5.0",
"@typescript-eslint/eslint-plugin": "8.3.0",
"@typescript-eslint/parser": "8.3.0",
"c8": "10.1.2",
"chai": "5.1.1",
"concurrently": "8.2.2",
"eslint": "8.57.0",
"eslint-plugin-import": "2.29.1",
"mocha": "10.7.3",
"tsc-watch": "6.2.0",
"typescript": "5.5.4"
}
}
4 changes: 2 additions & 2 deletions compiler/src/js2eel/compiler/Js2EelCompiler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from './Js2EelCompiler';
import { testEelSrc } from '../test/helpers';
import { Js2EelCompiler } from './Js2EelCompiler.js';
import { testEelSrc } from '../test/helpers.js';

describe('Js2EelCompiler', () => {
it('setReturn(). getReturn()', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../compiler/Js2EelCompiler';
import { testEelSrc } from '../test/helpers';
import { Js2EelCompiler } from '../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../test/helpers.js';

describe('registerDeclarationParam()', () => {
it('Error if reserved lib symbol', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getLowerCasedDeclaredSymbol } from '../environment/getLowerCaseDeclaredSymbol';
import { ALL_RESERVED_SYMBOL_NAMES } from '../constants';
import { getLowerCasedDeclaredSymbol } from '../environment/getLowerCaseDeclaredSymbol.js';
import { ALL_RESERVED_SYMBOL_NAMES } from '../constants.js';

import type { Identifier } from 'estree';
import type { Js2EelCompiler } from '../compiler/Js2EelCompiler';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('arrayExpression()', () => {
it('content is objects: No spread expression', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('config()', () => {
it('Error if called in non-root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('eachChannel()', () => {
it("Error if called isn't called in onSample scope", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('fileSelector()', () => {
it('Error if called in non-root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';

describe('onInit()', () => {
it('Error if called elsewhere than root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';

describe('onSample()', () => {
it('Error if called elsewhere than root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';

describe('onSlider()', () => {
it('Error if called elsewhere than root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('selectBox()', () => {
it('Error if called in non-root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('slider()', () => {
it('Error if called in non-root scope', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('evaluateUserFunctionCall()', () => {
it('error if missing argument', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('conditionalExpression()', () => {
it('Test part is wrong node type', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { literal } from '../literal/literal';
import { identifier } from '../identifier/identifier';
import { unaryExpression } from '../unaryExpression/unaryExpression';
import { binaryExpression } from '../binaryExpression/binaryExpression';
import { memberExpression } from '../memberExpression/memberExpression';
import { literal } from '../literal/literal.js';
import { identifier } from '../identifier/identifier.js';
import { unaryExpression } from '../unaryExpression/unaryExpression.js';
import { binaryExpression } from '../binaryExpression/binaryExpression.js';
import { memberExpression } from '../memberExpression/memberExpression.js';

import type { ConditionalExpression } from 'estree';
import type { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';

describe('expressionStatement()', () => {
it('Error if expression statement node type not allowed', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('arrowFunctionDeclaration()', () => {
it('Error if arrow function body is not a block statement', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('functionDeclaration()', () => {
it('Prevents declaration if other symbol with the name, even in other casing, exists', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('functionExpression()', () => {
it('Wrong param type', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('identifier()', () => {
it('error if using EelArray or EelBuffer without accessors', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('ifStatement()', () => {
it('Error if test part is of wrong node type', () => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/js2eel/generatorNodes/literal/literal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('literal()', () => {
it('should compile a true boolean literal as 1', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from 'chai';

import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('logicalExpression()', () => {
it('logical expression containing identifiers', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { identifier } from '../identifier/identifier';
import { unaryExpression } from '../unaryExpression/unaryExpression';
import { binaryExpression } from '../binaryExpression/binaryExpression';
import { JSFX_DENY_COMPILATION } from '../../constants';
import { identifier } from '../identifier/identifier.js';
import { unaryExpression } from '../unaryExpression/unaryExpression.js';
import { binaryExpression } from '../binaryExpression/binaryExpression.js';
import { JSFX_DENY_COMPILATION } from '../../constants.js';

import type { LogicalExpression } from 'estree';
import type { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('console()', () => {
it('Creates a debug variable if we console.log', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

it('Error if member function does not exist', () => {
const compiler = new Js2EelCompiler();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('eelBufferMemberCall()', () => {
it(".dimensions() returns the buffer's dimensions", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('mathMemberCall()', () => {
it('pow(): Validation errors', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('memberExpressionCall()', () => {
it('Error if callee object not declared', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('memberExpressionComputed', () => {
it('1-dimensional: not allowed', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../test/helpers';
import { Js2EelCompiler } from '../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../test/helpers.js';

describe('memberExpressionStatic', () => {
it('object not found', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { suffixScopeByScopeSuffix } from '../../suffixersAndPrefixers/suffixScope';
import { prefixParam } from '../../suffixersAndPrefixers/prefixParam';
import { suffixScopeByScopeSuffix } from '../../suffixersAndPrefixers/suffixScope.js';
import { prefixParam } from '../../suffixersAndPrefixers/prefixParam.js';

import type { Identifier, MemberExpression } from 'estree';
import type { Js2EelCompiler } from '../../compiler/Js2EelCompiler';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('newEelArray()', () => {
it('gives error if no arguments', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Joi from 'joi';
import { evaluateLibraryFunctionCall } from '../../callExpression/utils/evaluateLibraryFunctionCall';
import { evaluateLibraryFunctionCall } from '../../callExpression/utils/evaluateLibraryFunctionCall.js';

import type { NewExpression } from 'estree';
import type { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler';
import { testEelSrc } from '../../../test/helpers';
import { Js2EelCompiler } from '../../../compiler/Js2EelCompiler.js';
import { testEelSrc } from '../../../test/helpers.js';

describe('newEelBuffer()', () => {
it('gives error if no arguments', () => {
Expand Down
Loading

0 comments on commit 7edc8c5

Please sign in to comment.