Skip to content

Commit 98a8643

Browse files
authored
feat: modernize 20250228 (#1369)
- dependencies: use modern `eslint` and code-style tools - refactor: modernize imports - refactor: modernize code style - docs: fix tsdocs fixes #1347 --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 3463272 commit 98a8643

File tree

18 files changed

+498
-161
lines changed

18 files changed

+498
-161
lines changed

.eslintignore

Lines changed: 0 additions & 11 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
version: 2
44
updates:
55
- package-ecosystem: 'npm'
6-
directory: '/'
6+
directories:
7+
- '/.'
8+
- '/tools/code-style'
79
schedule:
810
interval: 'weekly'
911
day: 'saturday'
@@ -44,11 +46,13 @@ updates:
4446
patterns:
4547
- 'eslint'
4648
- '@eslint/*'
49+
- '*-eslint'
4750
- 'eslint-*'
48-
- '@eslint-community/*'
49-
- '@typescript-eslint/*'
5051
- '@types/eslint'
51-
- '@types/eslint*'
52+
- '@types/eslint-*'
53+
- '@types/*-eslint'
54+
- '@eslint-community/*'
55+
- '@typescript-eslint/*'z
5256
webpack:
5357
patterns:
5458
- 'webpack'

.github/workflows/nodejs.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
test-standard:
5555
name: test standard
5656
runs-on: ubuntu-latest
57-
timeout-minutes: 30
57+
timeout-minutes: 10
5858
steps:
5959
- name: Checkout
6060
# see https://github.com/actions/checkout
@@ -67,9 +67,34 @@ jobs:
6767
# cache: "npm"
6868
# cache-dependency-path: "**/package-lock.json"
6969
- name: setup project
70-
run: npm i --ignore-scripts
70+
run: |
71+
npm install --ignore-scripts --loglevel=silly
72+
- name: setup tools
73+
run: |
74+
echo "::group::install code-style deps"
75+
npm run -- dev-setup:code-style --ignore-scripts --loglevel=silly
76+
echo "::endgroup::"
77+
- name: make reports dir
78+
run: mkdir -p "$REPORTS_DIR"
7179
- name: test
72-
run: npm run test:standard
80+
run: >
81+
npm run -- test:standard
82+
--format json
83+
--output-file "$PWD/$REPORTS_DIR/eslint.json"
84+
- name: Annotate Code
85+
if: ${{ failure() || success() }}
86+
# see https://github.com/DerLev/eslint-annotations
87+
uses: DerLev/eslint-annotations@v2
88+
with:
89+
eslint-report: ${{ env.REPORTS_DIR }}/eslint.json
90+
- name: artifact eslint result
91+
# see https://github.com/actions/upload-artifact
92+
uses: actions/upload-artifact@v4
93+
if: ${{ failure() }}
94+
with:
95+
name: ${{ env.STANDARD_REPORTS_ARTIFACT }}
96+
path: ${{ env.REPORTS_DIR }}
97+
if-no-files-found: error
7398

7499
test-jest:
75100
needs: [ 'build' ]

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ But please read the
55
[CycloneDX contributing guidelines](https://github.com/CycloneDX/.github/blob/master/CONTRIBUTING.md)
66
first.
77

8-
## Setup
8+
## Set up the project
99

10-
To start developing simply run to install dev-dependencies and tools:
10+
Install dependencies:
1111

1212
```shell
13-
npm ci
13+
npm run dev-setup
1414
```
1515

1616
This will install process automatically build the project from source.

HISTORY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ All notable changes to this project will be documented in this file.
88

99
* BREAKING Changes
1010
* Dropped support for `node<20.18.0` ([#1362] via [#1365])
11+
* Documentation
12+
* Fixed docs of default values (via [#1369])
1113
* Dependencies
1214
* Upgraded runtime-dependency `@cyclonedx/cyclonedx-library@^8.0.0`, was `@^7.0.0` (via [#1367])
1315
* Upgraded runtime-dependency `normalize-package-data@^7.0.0`, was `@^3||^4||^5||^6` (via [#1368])
@@ -16,6 +18,7 @@ All notable changes to this project will be documented in this file.
1618
[#1365]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/1365
1719
[#1367]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/1367
1820
[#1368]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/1368
21+
[#1369]: https://github.com/CycloneDX/cyclonedx-webpack-plugin/pull/1369
1922

2023
## 4.0.1 - 2025-01-29
2124

eslint.config.mjs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*!
2+
This file is part of CycloneDX Webpack plugin.
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 { default as 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 */
29+
30+
/**
31+
* @type {import('@types/eslint').Linter.FlatConfig[]}
32+
* @see {@link https://eslint.org/}
33+
*/
34+
export default [
35+
...baseCfg,
36+
{
37+
name: 'project-specific',
38+
rules: {
39+
"complexity": ["error", { "max": 15 }]
40+
}
41+
},
42+
{
43+
name: 'project-specific',
44+
files: ['src/*.ts'],
45+
rules: {
46+
'@typescript-eslint/no-unsafe-assignment': 'warn',
47+
'@typescript-eslint/no-unsafe-member-access': 'warn',
48+
}
49+
},
50+
{
51+
files: ['**/*.js'],
52+
languageOptions: { sourceType: 'commonjs' }
53+
},
54+
{
55+
files: ['{src,tests}/**/*!(.{node,web}).{js,mjs,cjs.ts}'],
56+
languageOptions: {
57+
globals: {
58+
...globals.browser,
59+
...globals.node
60+
}
61+
}
62+
},
63+
{
64+
files: [
65+
'**/*.{test,spec}.{js,mjs,cjs,ts}',
66+
'tests/**.{js,mjs,cjs,ts}'
67+
],
68+
languageOptions: {
69+
globals: {
70+
...globals.node,
71+
...globals.jest,
72+
}
73+
}
74+
},
75+
{
76+
files: ['src/**/*.ts'],
77+
languageOptions: {
78+
parserOptions: {
79+
project: path.join(__dirname, 'tsconfig.json'),
80+
},
81+
},
82+
},
83+
{
84+
files: ['examples/**/*.{js,mjs,cjs,ts}'],
85+
rules: {
86+
'no-console': 'off'
87+
},
88+
languageOptions: {
89+
globals: globals.browser
90+
}
91+
},
92+
{
93+
// global ignores must have nothing but a "ignores" property!
94+
// see https://github.com/eslint/eslint/discussions/17429#discussioncomment-6579229
95+
ignores: [
96+
'reports/',
97+
'dist/',
98+
'docs/api/',
99+
'docs/_build/',
100+
'docs/.venv/',
101+
'examples/**/dist/',
102+
'tools/',
103+
'tests/integration/'
104+
],
105+
},
106+
]

examples/simple/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const { Tooltip, Toast, Popover } = require('bootstrap')
20+
const { Popover, Toast, Tooltip } = require('bootstrap')
2121

2222
// no real world use, but showcase
2323

examples/simple/webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const path = require('path')
20+
const path = require('node:path')
2121

2222
const { CycloneDxWebpackPlugin } = require('@cyclonedx/webpack-plugin')
2323

24+
/* eslint-disable jsdoc/valid-types */
25+
2426
/** @type {import('@cyclonedx/webpack-plugin').CycloneDxWebpackPluginOptions} */
2527
const cycloneDxWebpackPluginOptions = {
2628
specVersion: '1.6',

jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20+
/* eslint-disable jsdoc/valid-types */
21+
2022
/**
2123
* For a detailed explanation regarding each configuration property, visit:
2224
* {@link https://jestjs.io/docs/configuration}
23-
*
2425
* @type {import('jest').Config}
2526
*/
2627
module.exports = {

0 commit comments

Comments
 (0)