Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

11 changes: 0 additions & 11 deletions .eslintrc.js

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/auto-approve-trusted-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Auto approve trusted PR

on:
pull_request_target:
branches:
branches:
- master
- main
- develop
Expand All @@ -17,6 +17,6 @@ jobs:
# if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' # this is optional
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # required, feel free to use another PAT
trusted-committers: dependabot[bot], github-actions[bot] # optional, default to "dependabot[bot],dependabot-preview[bot]"
manage-approvals-for-reviewers: github-actions[bot] # optional, default to "github-actions[bot]"
trusted-committers: dependabot[bot], github-actions[bot] # optional, default to "dependabot[bot],dependabot-preview[bot]"
manage-approvals-for-reviewers: github-actions[bot] # optional, default to "github-actions[bot]"
enable-auto-merge: true # optional, default to false
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI
on:
push:
branches: [ '**' ]
branches: ['**']

jobs:
setup:
Expand All @@ -24,8 +24,8 @@ jobs:

strategy:
matrix:
project: [ common, dummy, mocha, jest ]
project: [common, dummy, mocha, jest]

steps:
- uses: handy-common-utils/automation/github/actions/prepare-node@main
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Release if needed
on:
workflow_run:
workflows: ["CI"]
workflows: ['CI']
branches: [main, master]
types:
types:
- completed

jobs:
Expand Down
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
8 changes: 8 additions & 0 deletions .mocharc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
spec:
- 'test/**/*.spec.ts'
- 'test/**/*.spec.mts'
- 'test/**/*.spec.cts'
- 'test/**/*.spec.int.ts'
- 'test/**/*.spec.int.mts'
- 'test/**/*.spec.int.cts'
- 'test/**/*.test.ts'
- 'test/**/*.test.mts'
- 'test/**/*.test.cts'
- 'test/**/*.test.int.ts'
- 'test/**/*.test.int.mts'
- 'test/**/*.test.int.cts'
exclude:
- '**/node_modules/**'
require:
Expand Down
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ reports/

api-docs/
**/api-docs/

# These are just example ignore patterns, feel free to remove or modify
mocha/test/fixtures/
jest/test/fixtures/

# Feel free to add your own ignore patterns below and/or customize existing ones above
5 changes: 0 additions & 5 deletions .prettierrc.js

This file was deleted.

8 changes: 1 addition & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
"editor.tabSize": 2,
"cSpell.words": [
"nvmrc",
"nycrc",
"readmemd",
"rushstack",
"semrel"
]
"cSpell.words": ["ESBK", "mocharc", "nvmrc", "nycrc", "preversion", "qiwi", "readmemd", "rushstack", "semrel"]
}
12 changes: 7 additions & 5 deletions common/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.eslint*
.mocharc*
.nycrc*
.prettier*
tsconfig.*
/.eslint*
/eslint.config.*
/.mocharc*
/.nycrc*
/.prettier*
/prettier.config.*
/tsconfig.*
1 change: 0 additions & 1 deletion common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ It can be used to accelerate the scaffolding of Typescript projects.
[![Version](https://img.shields.io/npm/v/@handy-common-utils/dev-dependencies-common.svg)](https://npmjs.org/package/@handy-common-utils/dev-dependencies-common)
[![Downloads/week](https://img.shields.io/npm/dw/@handy-common-utils/dev-dependencies-common.svg)](https://npmjs.org/package/@handy-common-utils/dev-dependencies-common)


Usually, you don't use this package directly, you use one of these instead:

- [@handy-common-utils/dev-dependencies-mocha](../mocha) - Common dev dependencies, including @handy-common-utils/dev-dependencies-common, mocha, chai, nyc, etc.
Expand Down
21 changes: 10 additions & 11 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"description": "This package contains dependencies that are common between @handy-common-utils/dev-dependencies-common-jest and @handy-common-utils/dev-dependencies-common-mocha",
"bin": {},
"scripts": {
"test": "",
"prepare": "shx cp ../LICENSE ../tsconfig.* ../.eslintrc.* ../.eslintignore ../.prettier* ."
"test": "eslint .",
"prepare": "shx cp ../LICENSE ../tsconfig.* ../eslint.config.* ../prettier.config.* ../.prettierignore . && replace-in-file .prettierignore '# These are just example[\\x00-\\x7F]*?\\n\\n' ''"
},
"files": [
"tsconfig.*",
".eslintrc.*",
".eslintignore",
".prettier*"
"eslint.config.*",
".prettierignore",
"prettier.config.*"
],
"publishConfig": {
"access": "public"
Expand All @@ -33,17 +33,16 @@
"homepage": "https://github.com/handy-common-utils/dev-dependencies/common/tree/master/common#readme",
"dependencies": {
"@handy-common-utils/dev-utils": "^1.8.0",
"es-check": "^9.1.4",
"eslint": "^9.32.0",
"eslint-config-sensible-prettier-typescript": "^1.3.0",
"es-check": "^9.3.1",
"eslint": "^9.34.0",
"eslint-config-sensible-prettier-typescript": "^1.7.1",
"husky": "^9.1.7",
"lint-staged": "^16.1.2",
"lint-staged": "^16.1.5",
"npm-run-all": "^4.1.5",
"prettier": "^3.6.2",
"shx": "^0.4.0",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"typescript": "^5.9.2",
"wait-on": "^8.0.4"
}
}
18 changes: 18 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { buildESLintConfig } = require('eslint-config-sensible-prettier-typescript');
const { defineConfig } = require('eslint/config');

const config = buildESLintConfig({ defaultSourceType: 'commonjs' });

module.exports = defineConfig([
// These global ignore patterns are just examples, feel free to remove or modify
{
ignores: ['mocha/test/fixtures/**/*', 'jest/test/fixtures/**/*'],
},
...config,
// Add your customizations here
{
rules: {
'unicorn/prefer-module': 'off',
},
},
]);
2 changes: 2 additions & 0 deletions jest/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/.eslint*
/eslint.config.*
/.mocharc*
/.nycrc*
/.prettier*
/prettier.config.*
/tsconfig.*
1 change: 0 additions & 1 deletion jest/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ const config: JestConfigWithTsJest = {
testEnvironment: 'node',
};

// eslint-disable-next-line unicorn/prefer-module
module.exports = config;
15 changes: 8 additions & 7 deletions jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"description": "This package contains dependencies that are common, including jest",
"bin": {},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --config test/jest.config.js --runInBand",
"prepare": "shx cp ../LICENSE ../tsconfig.* ../.eslintrc.* ../.eslintignore ../.prettier* ."
"pretest": "eslint .",
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --config test/jest.config.cjs --runInBand",
"prepare": "shx cp ../LICENSE ../tsconfig.* ../eslint.config.* ../prettier.config.* ../.prettierignore . && replace-in-file .prettierignore 'jest/test/' 'test/' && replace-in-file .prettierignore 'mocha/test/.*?\\n' '' && replace-in-file eslint.config.cjs 'jest/test/' 'test/'"
},
"files": [
"tsconfig.*",
"jest.config.*",
".eslintrc.*",
".eslintignore",
".prettier*"
"eslint.config.*",
".prettierignore",
"prettier.config.*"
],
"publishConfig": {
"access": "public"
Expand All @@ -39,7 +40,7 @@
"ts-jest": "^29.1.5"
},
"devDependencies": {
"tsx": "^3.12.7",
"zx": "^7.2.2"
"tsx": "^4.20.5",
"zx": "^8.8.1"
}
}
1 change: 0 additions & 1 deletion jest/test/fixtures/fs-utils/.eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions jest/test/fixtures/fs-utils/.eslintrc.yml

This file was deleted.

10 changes: 5 additions & 5 deletions jest/test/fixtures/fs-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Add surrounding content to the matching sections in the text file.
| `matchPattern` | `RegExp` | `undefined` | RegExp for deciding which section of the file would be processed. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
| `addBefore` | `string` | `undefined` | the string to be added before the capturing group, no need to escape anything |
| `addAfter` | `string` | `undefined` | the string to be added before the capturing group, no need to escape anything |
| `fileEncoding` | `undefined` \| `string` | `'utf-8'` | encoding of the file |
| `fileEncoding` | `undefined` \| `BufferEncoding` | `'utf-8'` | encoding of the file |

###### Returns

Expand All @@ -137,7 +137,7 @@ If the new content and original content are the same, the file won't be touched.
| ------ | ------ | ------ | ------ |
| `filePath` | `string` | `undefined` | path to the file |
| `transformContent` | (`originalContent`, `filePath`) => `string` \| `PromiseLike`\<`string`\> | `undefined` | function for getting the new file content |
| `fileEncoding` | `undefined` \| `string` | `'utf-8'` | encoding of the file |
| `fileEncoding` | `undefined` \| `BufferEncoding` | `'utf-8'` | encoding of the file |

###### Returns

Expand Down Expand Up @@ -186,7 +186,7 @@ Replace the matching sections in the text file.
| `filePath` | `string` | `undefined` | path to the file |
| `matchPattern` | `RegExp` | `undefined` | RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
| `replacementOrBuilder` | [`ReplacementOrBuilder`](#type-aliasesreplacementorbuildermd) | `undefined` | The replacement string or a function for building the replacement string. Please note that you can use special replacement patterns but also you need to take care of the escaping. For details of special replacement patterns see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace |
| `fileEncoding` | `undefined` \| `string` | `'utf-8'` | encoding of the file |
| `fileEncoding` | `undefined` \| `BufferEncoding` | `'utf-8'` | encoding of the file |

###### Returns

Expand Down Expand Up @@ -236,7 +236,7 @@ The replacing operations on those files happen in parallel.
| ------ | ------ | ------ |
| `matchPattern` | `RegExp` | RegExp for deciding which section of the file would be replaced. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
| `replacementOrBuilder` | [`ReplacementOrBuilder`](#type-aliasesreplacementorbuildermd) | The replacement string or a function for building the replacement string. Please note that you can use special replacement patterns but also you need to take care of the escaping. For details of special replacement patterns see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace |
| `fileEncoding` | `undefined` \| `string` | encoding of the file, in most of the cases 'utf-8' should be used |
| `fileEncoding` | `undefined` \| `BufferEncoding` | encoding of the file, in most of the cases 'utf-8' should be used |
| ...`filePaths` | `string`[] | path to the files |

###### Returns
Expand All @@ -262,7 +262,7 @@ Replace the matching sections in the text file with content from another file.
| `filePath` | `string` | `undefined` | path of the file |
| `matchPattern` | `RegExp` | `undefined` | RegExp for deciding which section of the file would be replaced. You must have a capturing group in the pattern. You may want to use these tricks: `m` flag, `g` flag, `s` flag, `[\s\S]*`, `.*?` |
| `contentFilePath` | `string` | `undefined` | path of the file for getting the replacement content |
| `fileEncoding` | `undefined` \| `string` | `'utf-8'` | encoding of the files |
| `fileEncoding` | `undefined` \| `BufferEncoding` | `'utf-8'` | encoding of the files |

###### Returns

Expand Down
24 changes: 24 additions & 0 deletions jest/test/fixtures/fs-utils/eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const { buildESLintConfig, customiseESLintConfig } = require('eslint-config-sensible-prettier-typescript');
const { defineConfig } = require('eslint/config');
const globals = require('globals');

const config = buildESLintConfig({ defaultSourceType: 'commonjs' });

customiseESLintConfig(
config,
(cfg) => [cfg.files].flat().some((f) => typeof f === 'string' && f.endsWith('.ts')),
(cfg) => {
cfg.languageOptions.globals = {
...globals.node,
};
},
);

module.exports = defineConfig([
// These global ignore patterns are just examples, feel free to remove or modify
{
ignores: ['dist', 'coverage', 'api-docs'],
},
...config,
// Add your customizations here
]);
1 change: 1 addition & 0 deletions jest/test/fixtures/fs-utils/src/fs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export abstract class FsUtils {
* @returns a new string with all '$' in the original string being replaced by '$$'
*/
static escapeRegExpReplacement(input: string): string {
// eslint-disable-next-line unicorn/prefer-string-replace-all
return input.replace(/\$/g, '$$');
}

Expand Down
3 changes: 2 additions & 1 deletion jest/test/fixtures/fs-utils/test/fs-utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable unicorn/prefer-node-protocol */
/* eslint-disable unicorn/prefer-node-protocol, unicorn/prefer-string-replace-all */
import { describe, expect, it } from '@jest/globals';
import * as fs from 'fs';
import { promisify } from 'util';
const fsWriteFile = promisify(fs.writeFile);
import * as tmp from 'tmp';

import { FsUtils } from '../src/fs-utils';

const originalFileContent = `This is the fist line.
Expand Down
Loading