Skip to content

Commit ec19cbe

Browse files
authored
Dependency and eslint upgrades (#6486)
* match ts-inspec-objects and heimdall monorepo with having a test:ci script endpoint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * upgrade some deps Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * upgrade target to es2024 Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * upgrade and swap out typescript and eslint related deps Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * redo eslint by initially making it match ts-inspec-objects Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * use eslint config to specify what the linter targets should be. also we do not need a custom formatter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * applied autofix eslint rules Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * saf cli is a cli app that needs to be able to call process.exit Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * vitest runs test files in parallel by default but runs the actual tests sequentially. we can speed things up by running those tests in parallel by default too Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * filename changes Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * split out the cleaning part from the compiling part in the scripts so that incremental could be used effectively Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * tsconfig improvements most important being the incremental flag being enabled; tried setting up the bundler moduleresolution option but was running into a lot of blockers and didn't want to pivot focus entirely to making this module ESM Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * added more rules primarily for imports Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * reworked ckl2poam so that we swapped out the dependency on xml2js for fast-xml-parser (now we only have the one xml parsing library), made it fully async await, and reworked tests accordingly plus added some more Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * indentation was wrong for some reason Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * enabled typedchecks for typescript and disabled some rules Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * mostly autofixes Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * bring in improvements from ts-inspec-objects. we need to more consistently use winston for our logging and also work on getting rid of colors here Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * use enum instead of raw strings when checking against enum Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * resolved some more lint findings Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * any is unfortunately used frequently throughout our types as a shortcut around dealing with parsing json for the most part. it'll take time to rework things to make our types safer. for now just move on Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * more lints Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * added prefer-object-has-own Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * prefer for..of over for..in Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * these functions aren't used Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * always use braces Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * only one importing lodash like that Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * make emasser.get tests not reliant on shared mutable state Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * put sequence.concurrent under test and then adjust tests that rely on global state like stdout - tests now run tremendously faster Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * lint against the new test that got written Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * fix linting issues in emasser + do some code style improvements (multiple pushes into an array to instead be a map, etc) + make things more consistently use async await instead of promises with callbacks Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter and try to convert some thens to async awaits Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * linter Signed-off-by: Amndeep Singh Mann <amann@mitre.org> * merge main and update deps Signed-off-by: Amndeep Singh Mann <amann@mitre.org> --------- Signed-off-by: Amndeep Singh Mann <amann@mitre.org>
1 parent 03a2d9f commit ec19cbe

196 files changed

Lines changed: 12842 additions & 14422 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
run: |
4545
npm ci
4646
npm run prepack
47-
npm run test
47+
npm run test:ci
4848
4949
- name: Sanity check that the SAF CLI works with no dev dependencies on windows
5050
if: ${{ matrix.platform == 'windows' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ out
2121
saf-cli.log
2222
CliProcessOutput.log
2323
deltaProcessReport.md
24+
tsconfig.tsbuildinfo

eslint.config.cjs

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

eslint.config.js

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import { defineConfig } from 'eslint/config';
2+
import js from '@eslint/js';
3+
import stylistic from '@stylistic/eslint-plugin';
4+
import tseslint from 'typescript-eslint';
5+
import unicorn from 'eslint-plugin-unicorn';
6+
import n from 'eslint-plugin-n';
7+
8+
export default defineConfig([
9+
{
10+
ignores: ['node_modules/**', 'lib/**', 'dist/**', 'test/sample_data/**'],
11+
},
12+
js.configs.recommended,
13+
tseslint.configs.recommendedTypeChecked,
14+
unicorn.configs.recommended,
15+
stylistic.configs.customize({
16+
braceStyle: '1tbs',
17+
indent: [2, { SwitchCase: 1 }],
18+
semi: true,
19+
quoteProps: 'as-needed',
20+
quotes: 'single',
21+
}),
22+
tseslint.configs.stylisticTypeChecked,
23+
{
24+
languageOptions: {
25+
parser: tseslint.parser,
26+
parserOptions: {
27+
projectService: {
28+
allowDefaultProject: ['eslint.config.js', 'vitest.config.ts'],
29+
},
30+
},
31+
ecmaVersion: 'latest',
32+
sourceType: 'module',
33+
},
34+
plugins: {
35+
'@typescript-eslint': tseslint.plugin,
36+
unicorn,
37+
n,
38+
},
39+
rules: {
40+
// any is unfortunately used frequently throughout our types as a shortcut around dealing with parsing json for the most part. it'll take time to rework things to make our types safer
41+
curly: 'error',
42+
'prefer-object-has-own': 'error',
43+
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
44+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
45+
'@typescript-eslint/consistent-type-exports': 'error',
46+
'@typescript-eslint/consistent-type-imports': 'error',
47+
'@typescript-eslint/no-explicit-any': 'off',
48+
'@typescript-eslint/no-redundant-type-constituents': 'off',
49+
'@typescript-eslint/no-unsafe-argument': 'off',
50+
'@typescript-eslint/no-unsafe-assignment': 'off',
51+
'@typescript-eslint/no-unsafe-call': 'off',
52+
'@typescript-eslint/no-unsafe-member-access': 'off',
53+
'@typescript-eslint/no-unsafe-return': 'off',
54+
'@typescript-eslint/prefer-nullish-coalescing': 'off',
55+
'unicorn/filename-case': ['error', { case: 'snakeCase' }],
56+
'unicorn/no-null': 'off',
57+
'unicorn/no-process-exit': 'off',
58+
'unicorn/prefer-node-protocol': 'off',
59+
'unicorn/prevent-abbreviations': 'off',
60+
},
61+
},
62+
]);
63+
64+
// module.exports = [
65+
// rules: {
66+
// '@typescript-eslint/no-explicit-any': 'error', // Disallow 'any'
67+
// '@typescript-eslint/no-unused-vars': 'warn',
68+
// '@typescript-eslint/typedef': 'error',
69+
//
70+
// // eslint rules
71+
// 'camelcase': 'off',
72+
// 'complexity': ['warn', 30],
73+
// 'max-nested-callbacks': 'warn',
74+
//
75+
// 'no-control-regex': 'warn',
76+
// 'no-console': 'off',
77+
// 'no-constant-condition': 'warn',
78+
// 'no-undef': 'off',
79+
// 'no-unused-expressions': 'error',
80+
// 'no-await-in-loop': 'off',
81+
// 'no-unused-vars': ['warn', { 'argsIgnorePattern': '^_' }],
82+
//
83+
// // eslint-plugin-n rules (these were moved from eslint-plugin-node)
84+
// 'n/exports-style': [
85+
// 'error',
86+
// 'exports',
87+
// {
88+
// 'allowBatchAssign': false,
89+
// },
90+
// ],
91+
// 'n/no-missing-import': 'off',
92+
// 'n/no-process-exit': 'off',
93+
// 'n/no-unpublished-import': [
94+
// 'error', {
95+
// 'ignoreTypeImport': true,
96+
// 'ignorePrivate': true,
97+
// },
98+
// ],
99+
// },
100+
// },
101+
//
102+
// // Unicorn (eslint-plugin-unicorn) and Stylistic (@stylistic/eslint-plugin)
103+
// // are ESM-only module, need to import them dynamically inside an async
104+
// // function. This causes node to display this warning:
105+
// // (node:11996) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
106+
// // This is cause by: const unicorn = await import("eslint-plugin-unicorn")
107+
//
108+
// // Load unicorn and @stylistic plugin dynamically
109+
// (async () => {
110+
// const unicorn = await import('eslint-plugin-unicorn')
111+
// const stylisticPlugin = await import('@stylistic/eslint-plugin')
112+
//
113+
// return {
114+
// plugins: {
115+
// unicorn: unicorn.default, // Use `.default` because it's an ESM module
116+
// '@stylistic': stylisticPlugin.default,
117+
// },
118+
// rules: {
119+
// // Ensure that recommended rules exist before accessing them
120+
// ...(unicorn.default.configs?.recommended?.rules || {}),
121+
// 'unicorn/better-regex': 'off',
122+
// 'unicorn/consistent-function-scoping': 'off',
123+
// 'unicorn/explicit-length-check': 'off',
124+
// 'unicorn/filename-case': 'off',
125+
// 'unicorn/import-style': 'off',
126+
// 'unicorn/numeric-separators-style': 'off',
127+
// 'unicorn/prefer-node-protocol': 'off',
128+
// 'unicorn/prefer-module': 'off',
129+
// 'unicorn/prefer-code-point': 'off',
130+
// 'unicorn/prefer-json-parse-buffer': 'off',
131+
// 'unicorn/prefer-top-level-await': 'off',
132+
// 'unicorn/prefer-number-properties': 'off',
133+
// 'unicorn/prevent-abbreviations': 'off',
134+
// 'unicorn/no-null': 'off',
135+
// 'unicorn/no-hex-escape': 'off',
136+
// 'unicorn/no-zero-fractions': 'off',
137+
// 'unicorn/no-array-for-each': 'off',
138+
// 'unicorn/no-process-exit': 'off',
139+
// 'unicorn/no-nested-ternary': 'off',
140+
// 'unicorn/no-named-default': 'off',
141+
//
142+
// // stylistic rules
143+
// ...(stylisticPlugin.default.configs?.recommended?.rules || {}),
144+
// '@stylistic/array-bracket-spacing': ['error', 'never'],
145+
// '@stylistic/array-bracket-newline': ['warn', {'multiline': true}],
146+
// '@stylistic/brace-style': ['error', '1tbs', {'allowSingleLine': true}],
147+
// '@stylistic/indent': ['warn', 2, {'SwitchCase': 1}],
148+
// '@stylistic/block-spacing': 'off',
149+
// '@stylistic/quote-props': 'off',
150+
// '@stylistic/multiline-ternary': 'off',
151+
// '@stylistic/max-statements-per-line': ['warn', {'max': 1, 'ignoredNodes': ['BreakStatement']}],
152+
// '@stylistic/no-multi-spaces': 'warn', // Disallow multiple spaces except for alignment
153+
// '@stylistic/no-trailing-spaces': 'warn',
154+
// '@stylistic/object-curly-spacing': ['warn', 'never'],
155+
// '@stylistic/quotes': ['error', 'single', {'avoidEscape': true}], // Allows double quotes (") when escaping single quotes
156+
// '@stylistic/semi': ['warn', 'never'],
157+
// },
158+
// }
159+
// })(),
160+
// ]

0 commit comments

Comments
 (0)