diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index eebb3fa..0000000 --- a/.editorconfig +++ /dev/null @@ -1,29 +0,0 @@ -# http://editorconfig.org - -# A special property that should be specified at the top of the file outside of -# any sections. Set to true to stop .editor config file search on current file -root = true - -# Indentation style -# Possible values - tab, space -indent_style = space - -# Indentation size in single-spaced characters -# Possible values - an integer, tab -indent_size = 2 - -# Line ending file format -# Possible values - lf, crlf, cr -end_of_line = lf - -# File character encoding -# Possible values - latin1, utf-8, utf-16be, utf-16le -charset = utf-8 - -# Denotes whether to trim whitespace at the end of lines -# Possible values - true, false -trim_trailing_whitespace = true - -# Denotes whether file should end with a newline -# Possible values - true, false -insert_final_newline = true diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 4286e4a..0000000 --- a/.eslintrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": ["airbnb-base"], - "parser": "babel-eslint", - "rules": { - "padded-blocks": 0, - "space-before-function-paren": 0, - "semi": 0 - } -} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e04534a..45a454d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0060fc..e8cc403 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -26,6 +28,3 @@ jobs: with: body_path: CHANGELOG.txt draft: true - files: | - lib/index.js - LICENSE diff --git a/README.md b/README.md index 30bd808..5b7946b 100644 --- a/README.md +++ b/README.md @@ -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"; @@ -27,6 +28,7 @@ registerComponent(MjBarChart); ``` with **CJS**: + ```ecmascript 6 const { registerComponent } = require("mjml-core"); const MjBarChart = require("@freezystem/mjml-bar-chart"); @@ -38,18 +40,19 @@ You can now use the `mjml-bar-chart` component in your MJML templates: ```mjml - - - - - - - + + + + + + + ``` diff --git a/package-lock.json b/package-lock.json index e506f77..e12c7eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,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", @@ -1408,9 +1408,9 @@ } }, "node_modules/@types/node": { - "version": "20.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.2.tgz", - "integrity": "sha512-37MXfxkb0vuIlRKHNxwCkb60PNBpR94u4efQuN4JgIAm66zfCDXGSAFCef9XUWFovX2R1ok6Z7MHhtdVXXkkIw==", + "version": "20.10.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.3.tgz", + "integrity": "sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==", "dev": true, "dependencies": { "undici-types": "~5.26.4" @@ -9489,9 +9489,9 @@ } }, "@types/node": { - "version": "20.10.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.2.tgz", - "integrity": "sha512-37MXfxkb0vuIlRKHNxwCkb60PNBpR94u4efQuN4JgIAm66zfCDXGSAFCef9XUWFovX2R1ok6Z7MHhtdVXXkkIw==", + "version": "20.10.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.3.tgz", + "integrity": "sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==", "dev": true, "requires": { "undici-types": "~5.26.4" diff --git a/package.json b/package.json index 9383b5b..a595a67 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/src/index.ts b/src/index.ts index bf256c5..d54d5b3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; @@ -59,7 +59,7 @@ export default class MjBarChart extends BodyComponent { static endingTag = true; - static dependencies = { + static dependencies: Record = { "mj-column": ["mj-bar-chart"], "mj-bar-chart": [], }; @@ -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", @@ -263,7 +263,7 @@ export default class MjBarChart extends BodyComponent { `; } - getStyles(): object { + override getStyles(): object { return { chartTitleWrapper: { width: "100%", @@ -346,4 +346,4 @@ export default class MjBarChart extends BodyComponent { } } -registerDependencies(MjBarChart.dependencies); \ No newline at end of file +registerDependencies(MjBarChart.dependencies); diff --git a/tsconfig.esm.json b/tsconfig.esm.json index 673e0cf..55f335b 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,7 +1,7 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "build/esm", - "module": "ESNext" - } -} \ No newline at end of file + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "build/esm", + "module": "ESNext" + } +} diff --git a/tsconfig.json b/tsconfig.json index 8351051..823fec4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -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"], } diff --git a/tsconfig.types.json b/tsconfig.types.json index 16bacea..ec35a7d 100644 --- a/tsconfig.types.json +++ b/tsconfig.types.json @@ -1,8 +1,9 @@ { - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "build/types", - "declaration": true, - "emitDeclarationOnly": true - } -} \ No newline at end of file + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "build/types", + "declaration": true, + "emitDeclarationOnly": true, + "declarationMap": true, + } +}