diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 9b8a9a70f..bf13e264a 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -106,17 +106,6 @@ jobs: - name: setup project run: | npm install --ignore-scripts --loglevel=silly - - name: setup examples - run: | - echo "::group::install example javascript" - npm run -- dev-setup:examples:js --ignore-scripts --loglevel=silly - echo "::endgroup::" - echo "::group::install example typescript cjs" - npm run -- dev-setup:examples:ts-cjs --ignore-scripts --loglevel=silly - echo "::endgroup::" - echo "::group::install examples typescript mjs" - npm run -- dev-setup:examples:ts-mjs --ignore-scripts --loglevel=silly - echo "::endgroup::" - name: setup tools run: | echo "::group::install docs-gen deps" @@ -332,7 +321,6 @@ jobs: project-token: ${{ env.CODACY_PROJECT_TOKEN }} coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*/* - examples-JS: needs: [ 'build' ] name: example JS ${{ matrix.js-type }} diff --git a/eslint.config.mjs b/eslint.config.mjs index c5ce0999d..dacf19f22 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -69,44 +69,6 @@ export default [ }, }, }, - { - files: ['examples/**/*.{js,mjs,cjs,ts}'], - rules: { - 'no-console': 'off' - }, - }, - { - files: ['examples/node/**/*.{js,mjs,cjs,ts}'], - rules: { - '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off' - }, - languageOptions: { - globals: globals.node - } - }, - { - files: ['examples/web/*/src/**'], - languageOptions: { - globals: globals.browser - } - }, - { - files: ['examples/node/typescript/example.cjs/src/*.ts'], - languageOptions: { - parserOptions: { - project: path.join(__dirname, 'examples', 'node', 'typescript', 'example.cjs', 'tsconfig.json') - }, - }, - }, - { - files: ['examples/node/typescript/example.mjs/src/*.ts'], - languageOptions: { - parserOptions: { - project: path.join(__dirname, 'examples', 'node', 'typescript', 'example.mjs', 'tsconfig.json' - ) - }, - }, - }, { // global ignores must have nothing but a "ignores" property! // see https://github.com/eslint/eslint/discussions/17429#discussioncomment-6579229 @@ -116,7 +78,7 @@ export default [ 'docs/api/', 'docs/_build/', 'docs/.venv/', - 'examples/**/dist/', + 'examples/', 'res/schema/', 'tools/', ], diff --git a/examples/eslint.config.mjs b/examples/eslint.config.mjs new file mode 100644 index 000000000..931a0b717 --- /dev/null +++ b/examples/eslint.config.mjs @@ -0,0 +1,81 @@ +/*! +This file is part of CycloneDX JavaScript Library. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +SPDX-License-Identifier: Apache-2.0 +Copyright (c) OWASP Foundation. All Rights Reserved. +*/ + +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +import baseCfg, { globals } from '../tools/code-style/eslint.config.mjs' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + +/* eslint-disable jsdoc/valid-types -- type-import not supported yet */ + +/** + * @type {import('../tools/code-style/node_modules/eslint').Linter.Config[]} + * @see https://eslint.org/ + */ +export default [ + ...baseCfg, , + { + files: ['./**/*.{js,mjs,cjs,ts}'], + rules: { + 'no-console': 'off' + }, + }, + { + files: ['./node/**/*.{js,mjs,cjs,ts}'], + rules: { + '@typescript-eslint/use-unknown-in-catch-callback-variable': 'off' + }, + languageOptions: { + globals: globals.node + } + }, + { + files: ['./web/*/src/**'], + languageOptions: { + globals: globals.browser + } + }, + { + files: ['./node/typescript/example.cjs/src/*.ts'], + languageOptions: { + parserOptions: { + project: path.join(__dirname, 'node', 'typescript', 'example.cjs', 'tsconfig.json') + }, + }, + }, + { + files: ['./node/typescript/example.mjs/src/*.ts'], + languageOptions: { + parserOptions: { + project: path.join(__dirname, 'node', 'typescript', 'example.mjs', 'tsconfig.json' + ) + }, + }, + }, + { + // global ignores must have nothing but a "ignores" property! + // see https://github.com/eslint/eslint/discussions/17429#discussioncomment-6579229 + ignores: [ + '**/dist/', + ], + }, +] diff --git a/package.json b/package.json index 8a3a01809..446d0f6eb 100644 --- a/package.json +++ b/package.json @@ -213,7 +213,6 @@ "test:node": "c8 mocha -p", "test:web": "node -e 'console.log(\"TODO: write web test\")'", "test:lint": "tsc --noEmit", - "pretest:standard": "npm run dev-setup:examples", "test:standard": "npm --prefix tools/code-style exec -- eslint .", "test:dependencies": "npm --prefix tools/test-dependencies exec -- knip --include dependencies,unlisted,unresolved --production", "cs-fix": "npm --prefix tools/code-style exec -- eslint --fix .",