Skip to content

Commit

Permalink
improve TS checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezystem committed Dec 3, 2023
1 parent 6efbe62 commit 6f7618b
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 91 deletions.
29 changes: 0 additions & 29 deletions .editorconfig

This file was deleted.

9 changes: 0 additions & 9 deletions .eslintrc

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node and NPM
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: 20
registry-url: "https://registry.npmjs.org"
- name: Install and Build
run: npm ci
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup Node and NPM
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: 20
cache: "npm"
- name: Install and Build
run: npm ci
- name: Test
run: npm test
- name: Prettier
run: npm run prettier
- name: Generate Changelog
run: git log --oneline $(git describe --tags --abbrev=0)..HEAD >> CHANGELOG.txt
- name: Release
Expand All @@ -26,6 +28,3 @@ jobs:
with:
body_path: CHANGELOG.txt
draft: true
files: |
lib/index.js
LICENSE
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Then add the package to your `.mjmlconfig` file:
Or import it and manually register the plugin.

with **ESM**:

```ecmascript 6
import { registerComponent } from "mjml-core";
import MjBarChart from "@freezystem/mjml-bar-chart";
Expand All @@ -27,6 +28,7 @@ registerComponent(MjBarChart);
```

with **CJS**:

```ecmascript 6
const { registerComponent } = require("mjml-core");
const MjBarChart = require("@freezystem/mjml-bar-chart");
Expand All @@ -38,18 +40,19 @@ You can now use the `mjml-bar-chart` component in your MJML templates:

```mjml
<mjml>
<mj-body>
<mj-section>
<mj-column>
<mj-bar-chart
title="Sum of Requests by Department"
dataset-labels="January,February,March"
datasets="[[33,14,27],[18,66,42],[7,15,21]]"
groups="support,sales,tech"
colors="#d8f3dc,#95d5b2,#52b788"/>
</mj-column>
</mj-section>
</mj-body>
<mj-body>
<mj-section>
<mj-column>
<mj-bar-chart
title="Sum of Requests by Department"
dataset-labels="January,February,March"
datasets="[[33,14,27],[18,66,42],[7,15,21]]"
groups="support,sales,tech"
colors="#d8f3dc,#95d5b2,#52b788"
/>
</mj-column>
</mj-section>
</mj-body>
</mjml>
```

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
},
"version": "1.1.1",
"description": "A simple MJML component to make static bar charts",
"main": "./build/index.js",
"module": "./build/esm/index.js",
"types": "./build/types/index.d.ts",
"main": "./build/index.js",
"module": "./build/esm/index.js",
"types": "./build/types/index.d.ts",
"exports": {
".": {
"types": "./build/types/index.d.ts",
Expand Down Expand Up @@ -41,7 +41,7 @@
"@types/mjml": "^4.7.4",
"@types/mjml-core": "^4.7.4",
"@types/mjml-validator": "^4.13.4",
"@types/node": "^20.10.2",
"@types/node": "^20.10.3",
"jest": "^29.7.0",
"npm-check": "^6.0.1",
"prettier": "^3.1.0",
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BodyComponent } from "mjml-core";
import { registerDependencies } from "mjml-validator";

type dataset = {
interface dataset {
label: string;
data: number[];
};
}

export default class MjBarChart extends BodyComponent {
readonly #title: string;
Expand Down Expand Up @@ -59,7 +59,7 @@ export default class MjBarChart extends BodyComponent {

static endingTag = true;

static dependencies = {
static dependencies: Record<string, string[]> = {
"mj-column": ["mj-bar-chart"],
"mj-bar-chart": [],
};
Expand All @@ -78,7 +78,7 @@ export default class MjBarChart extends BodyComponent {
"show-values": "boolean",
};

static defaultAttributes = {
static override defaultAttributes = {
"axis-color": "d4d4d4",
height: "200",
"bar-width": "30",
Expand Down Expand Up @@ -263,7 +263,7 @@ export default class MjBarChart extends BodyComponent {
`;
}

getStyles(): object {
override getStyles(): object {
return {
chartTitleWrapper: {
width: "100%",
Expand Down Expand Up @@ -346,4 +346,4 @@ export default class MjBarChart extends BodyComponent {
}
}

registerDependencies(MjBarChart.dependencies);
registerDependencies(MjBarChart.dependencies);
12 changes: 6 additions & 6 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "build/esm",
"module": "ESNext"
}
}
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "build/esm",
"module": "ESNext"
}
}
11 changes: 9 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
"moduleResolution": "node",
"esModuleInterop": true,
"inlineSourceMap": true,
"alwaysStrict": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true
},
"include": ["src/**/*.ts"],
"exclude": ["node_modules", "dist", "build", "coverage", "src/**/*.spec.ts"]
"exclude": ["node_modules", "build", "coverage", "src/**/*.spec.ts"],
}
15 changes: 8 additions & 7 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "build/types",
"declaration": true,
"emitDeclarationOnly": true
}
}
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "build/types",
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,
}
}

0 comments on commit 6f7618b

Please sign in to comment.