Skip to content

Commit

Permalink
Fix failing tests and bad dependency versions
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Jan 9, 2024
1 parent 27079ad commit 2fa2f32
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 41 deletions.
14 changes: 4 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ module.exports = {
},
plugins: [
'@typescript-eslint',
'no-only-tests',
'jsdoc'
'no-only-tests'
],
extends: [
'eslint:all',
'plugin:@typescript-eslint/all',
'plugin:jsdoc/recommended'
'plugin:@typescript-eslint/all'
],
rules: {
'@typescript-eslint/array-type': 'off',
Expand Down Expand Up @@ -91,12 +89,6 @@ module.exports = {
'@typescript-eslint/typedef': 'off',
'@typescript-eslint/unbound-method': 'off',
'@typescript-eslint/unified-signatures': 'off',
'jsdoc/require-param': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-param-type': 'off',
'jsdoc/newline-after-description': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-returns-type': 'off',
'array-bracket-newline': 'off',
'array-element-newline': 'off',
'array-type': 'off',
Expand All @@ -118,6 +110,8 @@ module.exports = {
'getter-return': 'off',
'guard-for-in': 'off',
'id-length': 'off',
'@typescript-eslint/indent': 'off',
'no-duplicate-imports': 'off',
'indent': 'off',
'init-declarations': 'off',
'line-comment-position': 'off',
Expand Down
18 changes: 4 additions & 14 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 @@ -21,7 +21,7 @@
},
"devDependencies": {
"@types/chai": "^4.1.2",
"@types/fs-extra": "^11.0.4",
"@types/fs-extra": "^8.0.0",
"@types/mocha": "^5.2.5",
"@types/node": "^11.9.0",
"@types/sinon": "^9.0.4",
Expand Down
12 changes: 6 additions & 6 deletions src/Plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Program, standardizePath as s } from "brighterscript";
import { Program, standardizePath as s } from 'brighterscript';
import * as fsExtra from 'fs-extra';
import { Plugin } from "./Plugin";
import { Plugin } from './Plugin';
import undent from 'undent';
import { expect } from "chai";
import { expect } from 'chai';

describe('Plugin', () => {
let program: Program;
Expand All @@ -11,13 +11,13 @@ describe('Plugin', () => {
const stagingDir = s`${tempDir}/stagingDir`;

beforeEach(() => {
fsExtra.emptydirSync(rootDir);
fsExtra.emptydirSync(stagingDir);
fsExtra.emptyDirSync(rootDir);
fsExtra.emptyDirSync(stagingDir);

program = new Program({
rootDir: rootDir,
stagingDir: stagingDir
})
});
program.plugins.add(new Plugin());
});

Expand Down
19 changes: 10 additions & 9 deletions src/Plugin.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BeforeFileTranspileEvent, BscFile, CompilerPlugin, Parser, WalkMode, createVisitor, isBrsFile, isXmlFile } from "brighterscript";
import SGParser from "brighterscript/dist/parser/SGParser";
import { SGChildren } from "brighterscript/dist/parser/SGTypes";
import type { BeforeFileTranspileEvent, CompilerPlugin } from 'brighterscript';
import { Parser, WalkMode, createVisitor, isBrsFile, isXmlFile } from 'brighterscript';
import SGParser from 'brighterscript/dist/parser/SGParser';
import { SGChildren } from 'brighterscript/dist/parser/SGTypes';

export class Plugin implements CompilerPlugin {
name = 'bsc-plugin-fubo';

beforeFileTranspile(event: BeforeFileTranspileEvent<BscFile>) {
beforeFileTranspile(event: BeforeFileTranspileEvent) {
if (isBrsFile(event.file)) {
event.file.ast.walk(createVisitor({
FunctionStatement: (functionStatement) => {
Expand All @@ -24,19 +25,19 @@ export class Plugin implements CompilerPlugin {
parser.parse('generated.xml', `
<component name="Generated">
<children>
<label text="Hello from ${event.file.ast.component.name}" />
<label text="Hello from ${event.file.ast.component!.name}" />
</children>
</component>
`);

const label = parser.ast.component.children.children[0];
const label = parser.ast.component!.children.children[0];

//ensure the <children> component exists
if (!event.file.ast.component.children) {
event.file.ast.component.children = new SGChildren();
if (!event.file.ast.component!.children) {
event.file.ast.component!.children = new SGChildren();
}
event.editor.arrayUnshift(
event.file.ast.component.children.children,
event.file.ast.component!.children.children,
label
);
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"outDir": "dist",
"declaration": true,
"strict": true,
"strictNullChecks": false,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"preserveConstEnums": true,
Expand Down

0 comments on commit 2fa2f32

Please sign in to comment.