Skip to content

Commit 5dfe402

Browse files
authored
tests: examplesare not part of projects eslint checks (#1300)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent a4a5034 commit 5dfe402

File tree

4 files changed

+82
-52
lines changed

4 files changed

+82
-52
lines changed

.github/workflows/nodejs.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,6 @@ jobs:
106106
- name: setup project
107107
run: |
108108
npm install --ignore-scripts --loglevel=silly
109-
- name: setup examples
110-
run: |
111-
echo "::group::install example javascript"
112-
npm run -- dev-setup:examples:js --ignore-scripts --loglevel=silly
113-
echo "::endgroup::"
114-
echo "::group::install example typescript cjs"
115-
npm run -- dev-setup:examples:ts-cjs --ignore-scripts --loglevel=silly
116-
echo "::endgroup::"
117-
echo "::group::install examples typescript mjs"
118-
npm run -- dev-setup:examples:ts-mjs --ignore-scripts --loglevel=silly
119-
echo "::endgroup::"
120109
- name: setup tools
121110
run: |
122111
echo "::group::install docs-gen deps"
@@ -332,7 +321,6 @@ jobs:
332321
project-token: ${{ env.CODACY_PROJECT_TOKEN }}
333322
coverage-reports: ${{ env.REPORTS_DIR }}/coverage/*/*
334323

335-
336324
examples-JS:
337325
needs: [ 'build' ]
338326
name: example JS ${{ matrix.js-type }}

eslint.config.mjs

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -69,44 +69,6 @@ export default [
6969
},
7070
},
7171
},
72-
{
73-
files: ['examples/**/*.{js,mjs,cjs,ts}'],
74-
rules: {
75-
'no-console': 'off'
76-
},
77-
},
78-
{
79-
files: ['examples/node/**/*.{js,mjs,cjs,ts}'],
80-
rules: {
81-
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off'
82-
},
83-
languageOptions: {
84-
globals: globals.node
85-
}
86-
},
87-
{
88-
files: ['examples/web/*/src/**'],
89-
languageOptions: {
90-
globals: globals.browser
91-
}
92-
},
93-
{
94-
files: ['examples/node/typescript/example.cjs/src/*.ts'],
95-
languageOptions: {
96-
parserOptions: {
97-
project: path.join(__dirname, 'examples', 'node', 'typescript', 'example.cjs', 'tsconfig.json')
98-
},
99-
},
100-
},
101-
{
102-
files: ['examples/node/typescript/example.mjs/src/*.ts'],
103-
languageOptions: {
104-
parserOptions: {
105-
project: path.join(__dirname, 'examples', 'node', 'typescript', 'example.mjs', 'tsconfig.json'
106-
)
107-
},
108-
},
109-
},
11072
{
11173
// global ignores must have nothing but a "ignores" property!
11274
// see https://github.com/eslint/eslint/discussions/17429#discussioncomment-6579229
@@ -116,7 +78,7 @@ export default [
11678
'docs/api/',
11779
'docs/_build/',
11880
'docs/.venv/',
119-
'examples/**/dist/',
81+
'examples/',
12082
'res/schema/',
12183
'tools/',
12284
],

examples/eslint.config.mjs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*!
2+
This file is part of CycloneDX JavaScript Library.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
SPDX-License-Identifier: Apache-2.0
17+
Copyright (c) OWASP Foundation. All Rights Reserved.
18+
*/
19+
20+
import path from 'node:path'
21+
import { fileURLToPath } from 'node:url'
22+
23+
import baseCfg, { globals } from '../tools/code-style/eslint.config.mjs'
24+
25+
const __filename = fileURLToPath(import.meta.url)
26+
const __dirname = path.dirname(__filename)
27+
28+
/* eslint-disable jsdoc/valid-types -- type-import not supported yet */
29+
30+
/**
31+
* @type {import('../tools/code-style/node_modules/eslint').Linter.Config[]}
32+
* @see https://eslint.org/
33+
*/
34+
export default [
35+
...baseCfg, ,
36+
{
37+
files: ['./**/*.{js,mjs,cjs,ts}'],
38+
rules: {
39+
'no-console': 'off'
40+
},
41+
},
42+
{
43+
files: ['./node/**/*.{js,mjs,cjs,ts}'],
44+
rules: {
45+
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off'
46+
},
47+
languageOptions: {
48+
globals: globals.node
49+
}
50+
},
51+
{
52+
files: ['./web/*/src/**'],
53+
languageOptions: {
54+
globals: globals.browser
55+
}
56+
},
57+
{
58+
files: ['./node/typescript/example.cjs/src/*.ts'],
59+
languageOptions: {
60+
parserOptions: {
61+
project: path.join(__dirname, 'node', 'typescript', 'example.cjs', 'tsconfig.json')
62+
},
63+
},
64+
},
65+
{
66+
files: ['./node/typescript/example.mjs/src/*.ts'],
67+
languageOptions: {
68+
parserOptions: {
69+
project: path.join(__dirname, 'node', 'typescript', 'example.mjs', 'tsconfig.json'
70+
)
71+
},
72+
},
73+
},
74+
{
75+
// global ignores must have nothing but a "ignores" property!
76+
// see https://github.com/eslint/eslint/discussions/17429#discussioncomment-6579229
77+
ignores: [
78+
'**/dist/',
79+
],
80+
},
81+
]

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@
213213
"test:node": "c8 mocha -p",
214214
"test:web": "node -e 'console.log(\"TODO: write web test\")'",
215215
"test:lint": "tsc --noEmit",
216-
"pretest:standard": "npm run dev-setup:examples",
217216
"test:standard": "npm --prefix tools/code-style exec -- eslint .",
218217
"test:dependencies": "npm --prefix tools/test-dependencies exec -- knip --include dependencies,unlisted,unresolved --production",
219218
"cs-fix": "npm --prefix tools/code-style exec -- eslint --fix .",

0 commit comments

Comments
 (0)