Skip to content

Commit

Permalink
chore: rework the project to be cross-platform friendly (#485)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkillerud authored Jul 11, 2024
1 parent 9a22b59 commit af9e20f
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 72 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

20 changes: 0 additions & 20 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
21 changes: 2 additions & 19 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 20

- name: npm install
run: npm install
Expand All @@ -31,24 +32,6 @@ jobs:
- name: npm test
run: npm test

release:
name: Release
runs-on: ubuntu-latest
needs: [test]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: npm install
run: npm install

- name: npm types
run: npm run types

- name: npx semantic-release
run: npx semantic-release
env:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
name: Run Lint and Tests

on: push
on:
push:
branches-ignore:
- main
- alpha
- beta
- next

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
node-version: [18.x, 20.x]
node-version: [18, 20]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

Expand All @@ -24,6 +31,7 @@ jobs:
run: npm run lint

- name: npm types
if: runner.os != 'Windows' # because of ./fixup.sh
run: npm run types

- name: npm test
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc → .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"tabWidth": 4,
"overrides": [
{
"files": [".prettierrc", "*.json", "*.yml", ".travis.yml", ".eslintrc"],
"files": ["*.json", "*.yml"],
"options": {
"tabWidth": 2
}
Expand Down
22 changes: 22 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import prettierConfig from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import js from '@eslint/js';

export default [
js.configs.recommended,
prettierConfig,
prettierPlugin,
{
languageOptions: {
globals: {
...globals.node,
...globals.browser,
global: true,
},
},
},
{
ignores: ['coverage/*', 'dist/*', 'tap-snapshots/*'],
},
];
2 changes: 1 addition & 1 deletion example/extending/custom-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const CustomContextParser = class CustomContextParser {
}

parse() {
return new Promise(resolve => {
return new Promise((resolve) => {
resolve('custom-context-value');
});
}
Expand Down
4 changes: 1 addition & 3 deletions example/server/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-extraneous-dependencies */
/* eslint-disable no-console */
import express from 'express';
import Layout from '../../lib/layout.js';
import template from './views/template.js';
Expand Down Expand Up @@ -41,7 +39,7 @@ const app = express();

app.use(layout.pathname(), layout.middleware());

app.get(`${layout.pathname()}/:bar?`,async (req, res, next) => {
app.get(`${layout.pathname()}/:bar?`, async (req, res) => {
const incoming = res.locals.podium;
const podlets = await Promise.all([
header.fetch(incoming),
Expand Down
4 changes: 2 additions & 2 deletions example/server/views/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ const template = (podlets = []) => {
</div>
</div>
</div>`;
}
export default template;
};
export default template;
5 changes: 0 additions & 5 deletions lib/layout.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/* eslint-disable consistent-return */
/* eslint-disable no-underscore-dangle */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-param-reassign */

import {
HttpIncoming,
template,
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
"scripts": {
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "tap --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json",
"test": "run-s test:*",
"test:unit": "tap --disable-coverage --allow-empty-coverage",
"test:types": "tsc --project tsconfig.test.json",
"test:snapshots": "tap --snapshot --disable-coverage --allow-empty-coverage",
"types": "tsc --declaration --emitDeclarationOnly && ./fixup.sh"
},
Expand All @@ -49,7 +51,6 @@
"objobj": "1.0.0"
},
"devDependencies": {
"@babel/eslint-parser": "7.23.3",
"@podium/podlet": "5.1.8",
"@podium/test-utils": "2.5.2",
"@semantic-release/changelog": "6.0.3",
Expand All @@ -58,20 +59,20 @@
"@semantic-release/github": "9.2.6",
"@semantic-release/npm": "11.0.3",
"@semantic-release/release-notes-generator": "12.1.0",
"@types/node": "^20.10.5",
"@types/readable-stream": "^4.0.10",
"eslint": "8.54.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-prettier": "5.0.1",
"@types/node": "20.14.10",
"@types/readable-stream": "4.0.15",
"eslint": "9.6.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.3",
"express": "4.19.2",
"globals": "15.8.0",
"hbs": "4.2.0",
"npm-run-all": "4.1.5",
"prettier": "3.1.0",
"semantic-release": "22.0.12",
"stoppable": "1.1.0",
"supertest": "6.3.4",
"tap": "18.8.0",
"typescript": "^5.3.3"
"typescript": "5.5.3"
}
}
4 changes: 1 addition & 3 deletions tests/layout.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable no-param-reassign */

import tap from 'tap';
import { destinationObjectStream } from '@podium/test-utils';
import { HttpIncoming, AssetJs, AssetCss } from '@podium/utils';
Expand Down Expand Up @@ -91,7 +89,7 @@ tap.test('Layout() - should collect metric with version info', (t) => {
const dest = destinationObjectStream((arr) => {
t.equal(arr[0].name, 'podium_layout_version_info');
t.equal(arr[0].labels[0].name, 'version');
// eslint-disable-next-line global-require

t.equal(arr[0].labels[0].value, pkg.version);
t.equal(arr[0].labels[1].name, 'major');
t.equal(arr[0].labels[2].name, 'minor');
Expand Down

0 comments on commit af9e20f

Please sign in to comment.