diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d63db133..00000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -benchmark/ -coverage/ -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 a83cae45..716afd97 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,54 +1,39 @@ name: Release and Publish on: - push: - branches: - - master - - alpha - - beta - - next + push: + branches: + - main + - alpha + - beta + - next jobs: - test: - runs-on: ubuntu-latest - 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 lint - run: npm run lint - - - name: npm test - run: npm test - - - name: Typecheck - run: npm run types - - 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: Generate type definitions - run: npm run types - - - name: npx semantic-release - run: npx semantic-release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: npm install + run: npm install + + - name: npm lint + run: npm run lint + + - name: npm types + run: npm run types + + - name: npm test + run: npm test + + - name: npx semantic-release + run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4dbc9ff..b161649c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,28 +1,37 @@ 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] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - name: npm install - run: npm install - - - name: npm lint - run: npm run lint - - - name: npm test - run: npm test - - - name: Typecheck - run: npm run types + build: + strategy: + matrix: + os: [ubuntu-latest, macOS-latest, windows-latest] + node-version: [18, 20] + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: npm install + run: npm install + + - name: npm lint + run: npm run lint + + - name: npm types + run: npm run types + + - name: npm test + run: npm test diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 75dee065..00000000 --- a/.npmignore +++ /dev/null @@ -1,10 +0,0 @@ -node_modules -coverage -package-lock.json -*.log -.gitignore -.npmignore -.editorconfig -.eslintignore -.eslintrc -.travis.yml diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 3fb27daf..00000000 --- a/.prettierrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "singleQuote": true, - "trailingComma": "all", - "tabWidth": 4 -} diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000..649f132a --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,13 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "tabWidth": 4, + "overrides": [ + { + "files": ["*.json", "*.yml"], + "options": { + "tabWidth": 2 + } + } + ] +} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 00000000..30aa7331 --- /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/*'], + }, +]; diff --git a/example/server.js b/example/server.js index eac62501..cae19455 100644 --- a/example/server.js +++ b/example/server.js @@ -24,6 +24,5 @@ const server = http.createServer(async (req, res) => { }); server.listen(8080, 'localhost', () => { - // eslint-disable-next-line no-console console.log('Server running at: http://localhost:8080'); }); diff --git a/lib/context.js b/lib/context.js index 54f93391..5ca7697f 100644 --- a/lib/context.js +++ b/lib/context.js @@ -173,7 +173,7 @@ export default class PodiumContext { ).then((result) => { result.forEach((item, index) => { const key = `${PREFIX}-${parsers[index][0]}`; - // eslint-disable-next-line no-param-reassign + incoming.context[decamelize(key, { separator: '-' })] = item; }); diff --git a/lib/get-device-type.js b/lib/get-device-type.js index 094f3000..4909ed09 100644 --- a/lib/get-device-type.js +++ b/lib/get-device-type.js @@ -65,7 +65,6 @@ export default class PodiumContextDeviceTypeParser { /* istanbul ignore next */ if (!type) { - // eslint-disable-next-line no-underscore-dangle const capabilities = Bowser.getParser(userAgent); const platformType = capabilities.getPlatformType(); type = this[symCapabilitiesToType](platformType); diff --git a/package.json b/package.json index 34963f3b..774dc25b 100644 --- a/package.json +++ b/package.json @@ -1,68 +1,69 @@ { - "name": "@podium/context", - "version": "5.0.23", - "description": "Module to generate the context which is passed on requests from a Podium Layout server to a Podium Podlet server", - "type": "module", - "license": "MIT", - "keywords": [ - "micro services", - "micro frontend", - "components", - "podium" - ], - "repository": { - "type": "git", - "url": "git@github.com:podium-lib/context.git" - }, - "bugs": { - "url": "https://github.com/podium-lib/issues" - }, - "homepage": "https://podium-lib.io/", - "files": [ - "package.json", - "CHANGELOG.md", - "README.md", - "LICENSE", - "dist", - "lib", - "types" - ], - "main": "./lib/context.js", - "types": "./types/context.d.ts", - "scripts": { - "lint": "eslint .", - "lint:fix": "eslint --fix .", - "test": "tap --disable-coverage --allow-empty-coverage && tsc --project tsconfig.test.json", - "types": "tsc --declaration --emitDeclarationOnly" - }, - "author": "", - "dependencies": { - "@metrics/client": "2.5.2", - "@podium/schemas": "5.0.5", - "@podium/utils": "5.0.7", - "abslog": "2.4.4", - "bcp47-validate": "^1.0.0", - "bowser": "^2.7.0", - "decamelize": "^6.0.0", - "lru-cache": "10.4.3" - }, - "devDependencies": { - "@babel/eslint-parser": "7.24.7", - "@semantic-release/changelog": "6.0.3", - "@semantic-release/commit-analyzer": "11.1.0", - "@semantic-release/git": "10.0.1", - "@semantic-release/github": "9.2.6", - "@semantic-release/npm": "11.0.3", - "@semantic-release/release-notes-generator": "12.1.0", - "@types/readable-stream": "4.0.14", - "eslint": "8.57.0", - "eslint-config-airbnb-base": "15.0.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-import": "2.29.1", - "eslint-plugin-prettier": "5.1.3", - "prettier": "3.3.2", - "semantic-release": "23.1.1", - "tap": "18.7.2", - "typescript": "5.4.5" - } + "name": "@podium/context", + "version": "5.0.23", + "description": "Module to generate the context which is passed on requests from a Podium Layout server to a Podium Podlet server", + "type": "module", + "license": "MIT", + "keywords": [ + "micro services", + "micro frontend", + "components", + "podium" + ], + "repository": { + "type": "git", + "url": "git@github.com:podium-lib/context.git" + }, + "bugs": { + "url": "https://github.com/podium-lib/issues" + }, + "homepage": "https://podium-lib.io/", + "files": [ + "package.json", + "CHANGELOG.md", + "README.md", + "LICENSE", + "dist", + "lib", + "types" + ], + "main": "./lib/context.js", + "types": "./types/context.d.ts", + "scripts": { + "lint": "eslint .", + "lint:fix": "eslint --fix .", + "test": "run-s test:*", + "test:unit": "tap --disable-coverage --allow-empty-coverage", + "test:types": "tsc --project tsconfig.test.json", + "types": "tsc --declaration --emitDeclarationOnly" + }, + "author": "", + "dependencies": { + "@metrics/client": "2.5.2", + "@podium/schemas": "5.0.5", + "@podium/utils": "5.0.7", + "abslog": "2.4.4", + "bcp47-validate": "^1.0.0", + "bowser": "^2.7.0", + "decamelize": "^6.0.0", + "lru-cache": "10.4.3" + }, + "devDependencies": { + "@semantic-release/changelog": "6.0.3", + "@semantic-release/commit-analyzer": "11.1.0", + "@semantic-release/git": "10.0.1", + "@semantic-release/github": "9.2.6", + "@semantic-release/npm": "11.0.3", + "@semantic-release/release-notes-generator": "12.1.0", + "@types/readable-stream": "4.0.14", + "eslint": "9.6.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.1.3", + "globals": "15.8.0", + "npm-run-all": "4.1.5", + "prettier": "3.3.2", + "semantic-release": "23.1.1", + "tap": "18.7.2", + "typescript": "5.4.5" + } } diff --git a/tests/get-locale.test.js b/tests/get-locale.test.js index 0041ab12..1e703e64 100644 --- a/tests/get-locale.test.js +++ b/tests/get-locale.test.js @@ -2,7 +2,6 @@ import tap from 'tap'; import { HttpIncoming } from '@podium/utils'; import Locale from '../lib/get-locale.js'; - tap.test( 'PodiumContextLocaleParser() - instantiate new object - should create an object', (t) => {