Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Update to nodejs v22 #1975

Merged
merged 22 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fc7b42e
update node types and typescript
art-alexeyenko Nov 12, 2024
5650996
Merge branch 'dev' of https://github.com/Sitecore/jss into chore/upda…
art-alexeyenko Nov 12, 2024
c2f5928
downgrade angular packages typescript for compatibility
art-alexeyenko Nov 13, 2024
b042f82
adjust tsconfig files in samples
art-alexeyenko Nov 13, 2024
9926fbc
yarn lock
art-alexeyenko Nov 13, 2024
711bdca
update create-sitecore-jss to use compatible sinon
art-alexeyenko Nov 13, 2024
fb5cf7c
adjust sample angular's typescript
art-alexeyenko Nov 13, 2024
3ee0331
fix create-sitecore-jss tests
art-alexeyenko Nov 14, 2024
b63a410
update eslint deps, fix build and test issues
art-alexeyenko Nov 15, 2024
1505b04
finalize typescript update, update eslint
art-alexeyenko Nov 16, 2024
123ebd2
bump azure pipeline's node version
art-alexeyenko Nov 17, 2024
539ec67
adjust react, nextjs app to latest typescript, node types, eslint
art-alexeyenko Nov 17, 2024
4c1ed72
finalize updates
art-alexeyenko Nov 17, 2024
5b2b59b
Merge branch 'dev' of https://github.com/Sitecore/jss into chore/upda…
art-alexeyenko Nov 17, 2024
bb49158
remove non-ts stylistic
art-alexeyenko Nov 17, 2024
d019766
Changelog
art-alexeyenko Nov 17, 2024
847d6ff
ensure --since arg is correctly passed to lint-packages script
art-alexeyenko Nov 17, 2024
5b68e62
remove fix from lint-packages
art-alexeyenko Nov 17, 2024
b27308b
formatting, lint, minor adjustments
art-alexeyenko Nov 19, 2024
d36e5da
smol lint
art-alexeyenko Nov 19, 2024
2c8ef97
fix type issues in nextjs, react packages
art-alexeyenko Nov 19, 2024
fc8f457
adjust CONTRIBUTING
art-alexeyenko Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"plugins": [
"@typescript-eslint",
"@stylistic/ts",
"prettier",
"jsdoc"
],
Expand Down Expand Up @@ -63,6 +64,9 @@
"allowTernary": true
}
],
"no-unused-vars": [
"error"
],
"brace-style": "error",
"quotes": [
"error",
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ variables:
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
versionSpec: '22.x'
- script: |
yarn cache clean --all && yarn install --immutable
displayName: 'yarn install - initial'
Expand Down
8 changes: 5 additions & 3 deletions eslint-configs/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ module.exports = {
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/no-use-before-define': ['error', { functions: false, variables: false }],
'@typescript-eslint/typedef': 'error',
'@typescript-eslint/type-annotation-spacing': 'error',
'@typescript-eslint/semi': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@stylistic/ts/type-annotation-spacing': 'error',
'@stylistic/ts/semi': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
},
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"scripts": {
"reset": "lerna clean --yes && yarn dlx rimraf node_modules && yarn install && yarn build",
"build": "lerna run build",
"lint-packages": "lerna run lint",
"lint-packages": "lerna run lint -- --fix",
"scaffold-samples": "node ./scripts/scaffold-samples.js",
"lint-samples": "node ./scripts/lint-samples.js",
"coverage-packages": "lerna run coverage",
Expand All @@ -22,19 +22,21 @@
"url": "https://github.com/sitecore/jss/issues"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.10.0",
"@typescript-eslint/parser": "^4.10.0",
"eslint": "^7.16.0",
"@stylistic/eslint-plugin-ts": "^2.10.1",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jsdoc": "^30.7.9",
"eslint-plugin-jsdoc": "^50.5.0",
"eslint-plugin-prettier": "^3.3.0",
"lerna": "^5.6.2",
"prettier": "^1.14.3",
"typedoc": "^0.24.0",
"typedoc-plugin-markdown": "^3.11.3",
"typescript": "~4.7.4"
"typescript": "~5.6.3"
},
"resolutions": {
"cheerio": "1.0.0-rc.3",
"eslint-plugin-jsx-a11y": "6.7.1",
"@types/react-native/@types/react": "17.0.34",
"@types/react-native-htmlview/@types/react": "17.0.34"
Expand Down
14 changes: 7 additions & 7 deletions packages/create-sitecore-jss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"coverage": "nyc npm test"
},
"engines": {
"node": ">=20"
"node": ">=22"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -49,18 +49,18 @@
"@types/inquirer": "^9.0.3",
"@types/minimist": "^1.2.2",
"@types/mocha": "^10.0.1",
"@types/node": "^20.14.2",
"@types/sinon": "10.0.6",
"@types/sinon-chai": "^3.2.9",
"@types/node": "^22.9.0",
"@types/sinon": "17.0.3",
"@types/sinon-chai": "^4.0.0",
"chai": "^4.3.7",
"chokidar": "^3.5.3",
"del-cli": "^5.0.0",
"eslint": "^8.32.0",
"eslint": "^8.56.0",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"sinon": "^15.0.1",
"sinon": "^18.0.0",
"sinon-chai": "^3.7.0",
"ts-node": "^10.9.1",
"typescript": "~4.9.5"
"typescript": "~5.6.3"
}
}
1 change: 1 addition & 0 deletions packages/create-sitecore-jss/src/InitializerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class InitializerFactory {
path.resolve(this.rootPath, 'initializers', name, 'index')
);
return new Initializer();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/create-sitecore-jss/src/bin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ describe('bin', () => {
getBaseTemplatesStub.returns(['foo']);
fsExistsSyncStub.returns(false);
fsReaddirSyncStub.returns([]);
const error = 'nope';
const error = new Error('nope');
initRunnerStub.throws(error);
inquirerPromptStub.returns({
continue: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ describe('transform', () => {
const templatePath = path.resolve('templates/next');
const destinationPath = path.resolve('samples/next');
const file = 'file.ts';
const error = 'Nope!';
const error = new Error('Nope!');

globSyncStub = sinon.stub(glob, 'sync').returns([file]);
ejsRenderFileStub = sinon.stub(ejs, 'renderFile').throws(error);
Expand Down
12 changes: 6 additions & 6 deletions packages/create-sitecore-jss/src/common/processes/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,12 @@ type TransformOptions = {

/**
* Handles each template file and applies ejs renderer, also:
* * determines files for copy
* * determines files for skip
* * if some files already exist:
* * merges package.json files
* * concatenates .env files
* * compares diffs
* determines files for copy
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
* determines files for skip
* if some files already exist:
* merges package.json files
* concatenates .env files
* compares diffs
* @param {string} templatePath path to the template
* @param {BaseArgs} answers CLI arguments
* @param {TransformOptions} options custom options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"chalk": "^4.1.2"
},
"devDependencies": {
"@types/node": "^20.14.2",
"typescript": "~4.3.5"
"@types/node": "^22.9.0",
"typescript": "~5.6.3"
}
}
2 changes: 1 addition & 1 deletion packages/create-sitecore-jss/src/common/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const openJsonFile = (jsonFilePath: string) => {

/**
* Creates a .json file and inserts provided data
* @param {Object} data data to be written into the .json file
* @param {object} data data to be written into the .json file
* @param {string} jsonFilePath a path to a file.
*/
export const writeJsonFile = (data: { [key: string]: unknown }, jsonFilePath: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
"@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
"@types/jasmine": "~3.6.7",
"@types/jasminewd2": "~2.0.8",
"@types/node": "~20.14.10",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@types/node": "~22.9.0",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"chalk": "~4.1.0",
"chokidar": "^3.5.2",
"codelyzer": "~6.0.1",
Expand All @@ -110,6 +110,6 @@
"npm-run-all": "~4.1.5",
"protractor": "^7.0.0",
"ts-node": "~10.9.2",
"typescript": "~5.2.2"
"typescript": "~5.4.0"
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"compilerOptions": {
"outDir": "../out-tsc/app",
"baseUrl": "./",
"newLine": "LF",
"types": []
"newLine": "LF"
},
"lib": [
"esnext.asynciterable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"baseUrl": "./",
"target": "ES2022",
"module": "commonjs",
"newLine": "LF",
"types": []
"newLine": "LF"
},
"lib": [
"esnext.asynciterable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"noUnusedLocals": true,
"noUnusedParameters": true,
"newLine": "LF",
"types": ["node"],
"typeRoots": ["node_modules/@types"],
"lib": ["es2018", "dom", "esnext.asynciterable"],
"paths": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class MultisitePlugin implements MiddlewarePlugin {
}

async exec(req: NextRequest, res?: NextResponse): Promise<NextResponse> {
// @ts-expect-error A 'Property '[INTERNALS]' is missing' error can occur in monorepo setups with peerDeps.
art-alexeyenko marked this conversation as resolved.
Show resolved Hide resolved
return this.multisiteMiddleware.getHandler()(req, res);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DisconnectedSitemapServicePlugin implements SitemapFetcherPlugin {
if (process.env.JSS_MODE !== constants.JSS_MODE.DISCONNECTED) return null;

try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const manifest = require('sitecore/manifest/sitecore-import.json');

return manifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class RedirectsPlugin implements MiddlewarePlugin {
* @returns Promise<NextResponse>
*/
async exec(req: NextRequest, res?:NextResponse): Promise<NextResponse> {
// @ts-expect-error A 'Property '[INTERNALS]' is missing' error can occur in monorepo setups with peerDeps.
return this.redirectsMiddleware.getHandler()(req, res);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PersonalizePlugin implements MiddlewarePlugin {
}

async exec(req: NextRequest, res?: NextResponse): Promise<NextResponse> {
// @ts-expect-error A 'Property '[INTERNALS]' is missing' error can occur in monorepo setups with peerDeps.
return this.personalizeMiddleware.getHandler()(req, res);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ContentStylesPlugin implements Plugin {
config.sitecoreEdgeUrl
);

contentStyles && props.headLinks.push(contentStyles);
if (contentStyles) props.headLinks.push(contentStyles);

return props;
}
Expand Down
7 changes: 6 additions & 1 deletion packages/create-sitecore-jss/src/templates/nextjs/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
"@next/next/no-img-element": "off", // Don't force next/image
"jsx-a11y/alt-text": ["warn", { "elements": ["img"] }], // Don't force alt for <Image/> (sourced from Sitecore media)
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"caughtErrorsIgnorePattern": "."
}
],
"@typescript-eslint/no-explicit-any": "error",
"jsx-quotes": ["error", "prefer-double"]
}
Expand Down
16 changes: 8 additions & 8 deletions packages/create-sitecore-jss/src/templates/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
"@sitecore-jss/sitecore-jss-nextjs": "~22.3.0-canary",
"graphql": "~15.8.0",
"graphql-tag": "^2.12.6",
"next": "^14.2.7",
"next": "^14.2.18",
"next-localization": "^0.12.0",
"react": "^18.2.0",
"react": "~18.2.0",
"react-dom": "^18.2.0",
"sharp": "0.32.6"
},
Expand All @@ -45,17 +45,17 @@
"@graphql-typed-document-node/core": "^3.2.0",
"@sitecore-jss/sitecore-jss-cli": "~22.3.0-canary",
"@sitecore-jss/sitecore-jss-dev-tools": "~22.3.0-canary",
"@types/node": "^20.14.2",
"@types/react": "^18.2.22",
"@types/node": "^22.9.0",
"@types/react": "~18.2.22",
"@types/react-dom": "^18.0.5",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"chalk": "~4.1.2",
"chokidar": "~3.5.3",
"constant-case": "^3.0.4",
"cross-env": "~7.0.3",
"dotenv-flow": "^4.1.0",
"eslint": "^8.32.0",
"eslint": "^8.56.0",
"eslint-config-next": "^13.1.5",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-prettier": "^4.2.1",
Expand All @@ -66,7 +66,7 @@
"prettier": "^2.8.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.1.2",
"typescript": "~4.9.4",
"typescript": "~5.6.3",
"yaml-loader": "^0.8.0"
},
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const plugins = require('scripts/temp/config-plugins');
import { JssConfig } from 'lib/config';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ScJssConfigPlugin implements ConfigPlugin {
async exec(config: JssConfig) {
let scJssConfig;
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
scJssConfig = require('scjssconfig.json');
} catch (e) {
return config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const plugins = require('scripts/temp/generate-component-builder-plugins');
import { PackageDefinition, ComponentFile } from '@sitecore-jss/sitecore-jss-dev-tools';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ generatePlugins({
Edit this script if you wish to use your own conventions for component storage in your JSS app.
*/

// eslint-disable-next-line @typescript-eslint/no-var-requires
// eslint-disable-next-line @typescript-eslint/no-require-imports
const plugins = require('scripts/temp/scaffold-component-plugins');

export interface ScaffoldComponentPluginConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function getItems<Item>(settings: {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const name = item.name.match(fileFormat)![1];
items.push(resolveItem(path, name));
cb && cb(name);
if (cb) cb(name);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"react": ["node_modules/react"]
},
"target": "es5",
"types": ["node"],
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@types/compression": "^1.7.2",
"@types/express": "^4.17.17",
"ts-node": "^10.9.1",
"typescript": "~4.9.5"
"typescript": "~5.6.3"
},
"private": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
"@types/compression": "^1.7.2",
"@types/express": "^4.17.17",
"@types/memory-cache": "^0.2.2",
"@types/node": "^20.14.2",
"@types/node": "^22.9.0",
"ts-node": "^10.9.1",
"typescript": "~4.9.5"
"typescript": "~5.6.3"
},
"private": true
}
Loading
Loading