diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 91e6ca73..00000000 --- a/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -tap-snapshots/ -coverage/ -benchmark/ -example/ -dist/ \ No newline at end of file diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 069d89b6..00000000 --- a/.eslintrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": ["airbnb-base", "prettier"], - "plugins": ["prettier"], - "parser": "@babel/eslint-parser", - "parserOptions": { - "requireConfigFile": false, - "ecmaVersion": 2020, - "sourceType": "module" - }, -"rules": { - "default-param-last": [0], - "import/prefer-default-export": "off", - "class-methods-use-this": [0], - "lines-between-class-members": [0], - "import/extensions": ["error", { - "js": "ignorePackages" - } - ] - } -} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..6313b56c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5d37850b..716afd97 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e57582c3..bc998463 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 @@ -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 diff --git a/.prettierrc b/.prettierrc.json similarity index 65% rename from .prettierrc rename to .prettierrc.json index e7be028d..649f132a 100644 --- a/.prettierrc +++ b/.prettierrc.json @@ -4,7 +4,7 @@ "tabWidth": 4, "overrides": [ { - "files": [".prettierrc", "*.json", "*.yml", ".travis.yml", ".eslintrc"], + "files": ["*.json", "*.yml"], "options": { "tabWidth": 2 } diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..0a6ab4d1 --- /dev/null +++ b/eslint.config.js @@ -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/*'], + }, +]; diff --git a/example/extending/custom-context.js b/example/extending/custom-context.js index a52e9cef..5c2c9b23 100644 --- a/example/extending/custom-context.js +++ b/example/extending/custom-context.js @@ -4,7 +4,7 @@ const CustomContextParser = class CustomContextParser { } parse() { - return new Promise(resolve => { + return new Promise((resolve) => { resolve('custom-context-value'); }); } diff --git a/example/server/server.js b/example/server/server.js index aa61fb56..012abddd 100644 --- a/example/server/server.js +++ b/example/server/server.js @@ -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'; @@ -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), diff --git a/example/server/views/template.js b/example/server/views/template.js index bd23fd2e..23d8de16 100644 --- a/example/server/views/template.js +++ b/example/server/views/template.js @@ -20,5 +20,5 @@ const template = (podlets = []) => { `; -} -export default template; \ No newline at end of file +}; +export default template; diff --git a/lib/layout.js b/lib/layout.js index eb34f3bb..6e486eab 100644 --- a/lib/layout.js +++ b/lib/layout.js @@ -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, diff --git a/package.json b/package.json index f7888d7c..46f2d922 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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", @@ -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" } } diff --git a/tests/layout.test.js b/tests/layout.test.js index 5af5d571..ceb09c93 100644 --- a/tests/layout.test.js +++ b/tests/layout.test.js @@ -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'; @@ -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');