release: v1.1.0 for tsconfig + prettier
This commit is contained in:
parent
51631b65b8
commit
e3f228ad5f
|
@ -32,8 +32,8 @@ jobs:
|
|||
with:
|
||||
version: pnpm ci:version
|
||||
publish: pnpm ci:publish
|
||||
commit: 'chore(release): publish packages'
|
||||
title: 'chore(release): publish packages'
|
||||
commit: "chore(release): publish packages"
|
||||
title: "chore(release): publish packages"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
|
@ -2,8 +2,8 @@ name: Sync Renovate changeset
|
|||
on:
|
||||
pull_request_target:
|
||||
paths:
|
||||
- '.github/workflows/sync_renovate-changesets.yml'
|
||||
- 'pnpm-lock.yaml'
|
||||
- ".github/workflows/sync_renovate-changesets.yml"
|
||||
- "pnpm-lock.yaml"
|
||||
|
||||
jobs:
|
||||
generate-changeset:
|
||||
|
|
|
@ -58,7 +58,7 @@ Add the following code to your `.eslintrc.js` or `.eslintrc.json` file:
|
|||
|
||||
```js
|
||||
module.exports = {
|
||||
extends: ['@bravo68web'],
|
||||
extends: ["@bravo68web"],
|
||||
// extends: ['@bravo68web/eslint-config/default'], // if you want to use named config
|
||||
};
|
||||
```
|
||||
|
@ -67,7 +67,7 @@ module.exports = {
|
|||
|
||||
```js
|
||||
module.exports = {
|
||||
extends: ['@bravo68web/eslint-config/code-style'],
|
||||
extends: ["@bravo68web/eslint-config/code-style"],
|
||||
};
|
||||
```
|
||||
|
||||
|
@ -75,10 +75,10 @@ module.exports = {
|
|||
|
||||
```js
|
||||
module.exports = {
|
||||
extends: ['@bravo68web/eslint-config/typescript-strict'],
|
||||
extends: ["@bravo68web/eslint-config/typescript-strict"],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
project: './tsconfig.json',
|
||||
ecmaVersion: "latest",
|
||||
project: "./tsconfig.json",
|
||||
// tsconfigRootDir: __dirname, // if you use tsconfig.json in a different directory
|
||||
},
|
||||
};
|
||||
|
@ -88,10 +88,10 @@ module.exports = {
|
|||
|
||||
```js
|
||||
module.exports = {
|
||||
extends: ['@bravo68web/eslint-config/ultimate'],
|
||||
extends: ["@bravo68web/eslint-config/ultimate"],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
project: './tsconfig.json',
|
||||
ecmaVersion: "latest",
|
||||
project: "./tsconfig.json",
|
||||
// tsconfigRootDir: __dirname, // if you use tsconfig.json in a different directory
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import rollupPluginCommonjs from '@rollup/plugin-commonjs';
|
||||
import rollupPluginNodeResolve from '@rollup/plugin-node-resolve';
|
||||
import rollupPluginTypescript from '@rollup/plugin-typescript';
|
||||
import rollupPluginAutoExternal from 'rollup-plugin-auto-external';
|
||||
import rollupPluginCommonjs from "@rollup/plugin-commonjs";
|
||||
import rollupPluginNodeResolve from "@rollup/plugin-node-resolve";
|
||||
import rollupPluginTypescript from "@rollup/plugin-typescript";
|
||||
import rollupPluginAutoExternal from "rollup-plugin-auto-external";
|
||||
|
||||
// Read the files in the src directory
|
||||
const dir = './src/';
|
||||
const dir = "./src/";
|
||||
// Filter the .ts files
|
||||
const files = fs.readdirSync(dir).filter(file => file.endsWith('.ts'));
|
||||
const files = fs.readdirSync(dir).filter(file => file.endsWith(".ts"));
|
||||
|
||||
const plugins = [
|
||||
// Automatically mark all dependencies as external
|
||||
|
@ -20,7 +20,7 @@ const plugins = [
|
|||
rollupPluginCommonjs(),
|
||||
// Compile TypeScript files
|
||||
rollupPluginTypescript({
|
||||
tsconfig: 'tsconfig.json',
|
||||
tsconfig: "tsconfig.json",
|
||||
}),
|
||||
];
|
||||
|
||||
|
@ -47,10 +47,10 @@ function getCjsConfig(filename) {
|
|||
return {
|
||||
input: `${dir}${filename}`,
|
||||
output: {
|
||||
dir: './dist',
|
||||
exports: 'default',
|
||||
entryFileNames: `${path.basename(filename, '.ts')}.cjs`,
|
||||
format: 'cjs',
|
||||
dir: "./dist",
|
||||
exports: "default",
|
||||
entryFileNames: `${path.basename(filename, ".ts")}.cjs`,
|
||||
format: "cjs",
|
||||
},
|
||||
plugins,
|
||||
};
|
||||
|
@ -66,10 +66,10 @@ function getEsmConfig(filename) {
|
|||
return {
|
||||
input: `${dir}${filename}`,
|
||||
output: {
|
||||
dir: './dist',
|
||||
exports: 'default',
|
||||
entryFileNames: `${path.basename(filename, '.ts')}.mjs`,
|
||||
format: 'esm',
|
||||
dir: "./dist",
|
||||
exports: "default",
|
||||
entryFileNames: `${path.basename(filename, ".ts")}.mjs`,
|
||||
format: "esm",
|
||||
},
|
||||
plugins,
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import merge from 'deepmerge';
|
||||
import merge from "deepmerge";
|
||||
|
||||
import defaultConfig from './default';
|
||||
import strictCodeStyleConfig from './sub-rules/prettier';
|
||||
import defaultConfig from "./default";
|
||||
import strictCodeStyleConfig from "./sub-rules/prettier";
|
||||
|
||||
export default merge(defaultConfig, strictCodeStyleConfig);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { Linter } from 'eslint';
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
const config: Linter.Config = {
|
||||
env: {
|
||||
|
@ -7,93 +7,93 @@ const config: Linter.Config = {
|
|||
node: true,
|
||||
},
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:react/recommended',
|
||||
'plugin:regexp/recommended',
|
||||
'plugin:unicorn/recommended',
|
||||
'plugin:sonarjs/recommended',
|
||||
'plugin:security/recommended',
|
||||
'plugin:tailwindcss/recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/eslint-recommended',
|
||||
"eslint:recommended",
|
||||
"plugin:react/recommended",
|
||||
"plugin:regexp/recommended",
|
||||
"plugin:unicorn/recommended",
|
||||
"plugin:sonarjs/recommended",
|
||||
"plugin:security/recommended",
|
||||
"plugin:tailwindcss/recommended",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/eslint-recommended",
|
||||
],
|
||||
parser: '@typescript-eslint/parser',
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
ecmaFeatures: {
|
||||
jsx: true,
|
||||
},
|
||||
ecmaVersion: 'latest',
|
||||
ecmaVersion: "latest",
|
||||
},
|
||||
plugins: [
|
||||
'regexp',
|
||||
'jsx-a11y',
|
||||
'autofix',
|
||||
'react',
|
||||
'sonarjs',
|
||||
'unicorn',
|
||||
'@typescript-eslint',
|
||||
'simple-import-sort',
|
||||
"regexp",
|
||||
"jsx-a11y",
|
||||
"autofix",
|
||||
"react",
|
||||
"sonarjs",
|
||||
"unicorn",
|
||||
"@typescript-eslint",
|
||||
"simple-import-sort",
|
||||
],
|
||||
rules: {
|
||||
quotes: [
|
||||
2,
|
||||
'single',
|
||||
"single",
|
||||
{
|
||||
avoidEscape: true,
|
||||
},
|
||||
],
|
||||
// Eslint
|
||||
'prefer-arrow-callback': 2,
|
||||
semi: [2, 'always'],
|
||||
"prefer-arrow-callback": 2,
|
||||
semi: [2, "always"],
|
||||
// Import sorting
|
||||
'simple-import-sort/imports': 2,
|
||||
'simple-import-sort/exports': 2,
|
||||
"simple-import-sort/imports": 2,
|
||||
"simple-import-sort/exports": 2,
|
||||
// React
|
||||
'react/react-in-jsx-scope': 0,
|
||||
'react/button-has-type': 2,
|
||||
'react/prop-types': 0,
|
||||
'react/no-array-index-key': 2,
|
||||
"react/react-in-jsx-scope": 0,
|
||||
"react/button-has-type": 2,
|
||||
"react/prop-types": 0,
|
||||
"react/no-array-index-key": 2,
|
||||
// SonarJS
|
||||
'sonarjs/no-duplicate-string': 0,
|
||||
"sonarjs/no-duplicate-string": 0,
|
||||
// Unicorn
|
||||
'unicorn/no-null': 0,
|
||||
'unicorn/prefer-module': 0,
|
||||
'unicorn/no-useless-undefined': 0,
|
||||
'unicorn/prevent-abbreviations': 0,
|
||||
'unicorn/no-await-expression-member': 0,
|
||||
"unicorn/no-null": 0,
|
||||
"unicorn/prefer-module": 0,
|
||||
"unicorn/no-useless-undefined": 0,
|
||||
"unicorn/prevent-abbreviations": 0,
|
||||
"unicorn/no-await-expression-member": 0,
|
||||
// Typescript
|
||||
'@typescript-eslint/no-namespace': 0,
|
||||
'@typescript-eslint/no-misused-promises': 0,
|
||||
'@typescript-eslint/no-unused-vars': [2],
|
||||
'@typescript-eslint/no-unsafe-call': 0,
|
||||
'@typescript-eslint/no-unsafe-assignment': 0,
|
||||
'@typescript-eslint/no-unsafe-member-access': 0,
|
||||
"@typescript-eslint/no-namespace": 0,
|
||||
"@typescript-eslint/no-misused-promises": 0,
|
||||
"@typescript-eslint/no-unused-vars": [2],
|
||||
"@typescript-eslint/no-unsafe-call": 0,
|
||||
"@typescript-eslint/no-unsafe-assignment": 0,
|
||||
"@typescript-eslint/no-unsafe-member-access": 0,
|
||||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: 'detect',
|
||||
version: "detect",
|
||||
},
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.js', '*.jsx', '*.cjs'],
|
||||
files: ["*.js", "*.jsx", "*.cjs"],
|
||||
rules: {
|
||||
'@typescript-eslint/no-var-requires': 0,
|
||||
"@typescript-eslint/no-var-requires": 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.js', '*.jsx', '*.ts', '*.tsx', '*.cjs', '*.mjs', '*.mts', '*.cts'],
|
||||
files: ["*.js", "*.jsx", "*.ts", "*.tsx", "*.cjs", "*.mjs", "*.mts", "*.cts"],
|
||||
rules: {
|
||||
'simple-import-sort/imports': [
|
||||
'error',
|
||||
"simple-import-sort/imports": [
|
||||
"error",
|
||||
{
|
||||
groups: [
|
||||
['dotenv/config'],
|
||||
['^node:', '^react$', '^react-dom$', '^next?/|^next$'],
|
||||
['^@?\\w'],
|
||||
['^[\\w]'],
|
||||
['^'],
|
||||
['^\\.'],
|
||||
["dotenv/config"],
|
||||
["^node:", "^react$", "^react-dom$", "^next?/|^next$"],
|
||||
["^@?\\w"],
|
||||
["^[\\w]"],
|
||||
["^"],
|
||||
["^\\."],
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Linter } from 'eslint';
|
||||
import { Linter } from "eslint";
|
||||
|
||||
const strictCodeStyleConfig: Linter.Config = {
|
||||
// Create a strictCodeStyleConfig object of type Linter.Config.
|
||||
extends: ['prettier'], // Add the prettier package to the extends array.
|
||||
plugins: ['prettier'], // Add the prettier package to the plugins array.
|
||||
extends: ["prettier"], // Add the prettier package to the extends array.
|
||||
plugins: ["prettier"], // Add the prettier package to the plugins array.
|
||||
rules: {
|
||||
'prettier/prettier': 2, // Add a rule to enforce the prettier plugin.
|
||||
"prettier/prettier": 2, // Add a rule to enforce the prettier plugin.
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
import { Linter } from 'eslint';
|
||||
import { Linter } from "eslint";
|
||||
|
||||
const strictTypescriptConfig: Linter.Config = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parser: "@typescript-eslint/parser",
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/strict',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||
"plugin:@typescript-eslint/strict",
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
||||
],
|
||||
plugins: ['deprecation', '@typescript-eslint'],
|
||||
plugins: ["deprecation", "@typescript-eslint"],
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
// Enforce using the @deprecated tag in JSDoc comments
|
||||
'deprecation/deprecation': 1,
|
||||
"deprecation/deprecation": 1,
|
||||
// Typescript
|
||||
// Disallow await on a non-promise
|
||||
'@typescript-eslint/no-misused-promises': 0,
|
||||
"@typescript-eslint/no-misused-promises": 0,
|
||||
// Enforce consistent use of type imports
|
||||
'@typescript-eslint/consistent-type-imports': 2,
|
||||
"@typescript-eslint/consistent-type-imports": 2,
|
||||
// Enforce consistent type exports
|
||||
'@typescript-eslint/consistent-type-exports': 2,
|
||||
"@typescript-eslint/consistent-type-exports": 2,
|
||||
// Enforce that type arguments will use if not required
|
||||
'@typescript-eslint/no-redundant-type-constituents': 2,
|
||||
"@typescript-eslint/no-redundant-type-constituents": 2,
|
||||
// Disallow calling an any type value
|
||||
'@typescript-eslint/no-unsafe-call': 0,
|
||||
"@typescript-eslint/no-unsafe-call": 0,
|
||||
// Disallow assigning any to variables and properties
|
||||
'@typescript-eslint/no-unsafe-assignment': 0,
|
||||
"@typescript-eslint/no-unsafe-assignment": 0,
|
||||
// Disallow member access on any typed variables
|
||||
'@typescript-eslint/no-unsafe-member-access': 0,
|
||||
"@typescript-eslint/no-unsafe-member-access": 0,
|
||||
// Disallow the use of custom TypeScript modules and namespaces
|
||||
'@typescript-eslint/no-namespace': 0,
|
||||
"@typescript-eslint/no-namespace": 0,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import merge from 'deepmerge';
|
||||
import merge from "deepmerge";
|
||||
|
||||
import defaultConfig from './default';
|
||||
import strictTypescriptConfig from './sub-rules/strict-typescript';
|
||||
import defaultConfig from "./default";
|
||||
import strictTypescriptConfig from "./sub-rules/strict-typescript";
|
||||
|
||||
export default merge(defaultConfig, strictTypescriptConfig);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import merge from 'deepmerge';
|
||||
import merge from "deepmerge";
|
||||
|
||||
import defaultConfig from './default';
|
||||
import strictCodeStyleConfig from './sub-rules/prettier';
|
||||
import strictTypescriptConfig from './sub-rules/strict-typescript';
|
||||
import defaultConfig from "./default";
|
||||
import strictCodeStyleConfig from "./sub-rules/prettier";
|
||||
import strictTypescriptConfig from "./sub-rules/strict-typescript";
|
||||
|
||||
const config = merge(strictCodeStyleConfig, strictTypescriptConfig);
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { describe } from 'vitest';
|
||||
import { describe } from "vitest";
|
||||
|
||||
import config from '../src/code-style';
|
||||
import { checkLintingErrors, checkValidity, createEngine } from './utils';
|
||||
import config from "../src/code-style";
|
||||
import { checkLintingErrors, checkValidity, createEngine } from "./utils";
|
||||
|
||||
describe('Code Style Configuration', () => {
|
||||
describe("Code Style Configuration", () => {
|
||||
const engine = createEngine(config);
|
||||
|
||||
// Check the validity of the engine.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { describe } from 'vitest';
|
||||
import { describe } from "vitest";
|
||||
|
||||
import config from '../src/default';
|
||||
import { checkLintingErrors, checkValidity, createEngine } from './utils';
|
||||
import config from "../src/default";
|
||||
import { checkLintingErrors, checkValidity, createEngine } from "./utils";
|
||||
|
||||
describe('Default Configuration', () => {
|
||||
describe("Default Configuration", () => {
|
||||
const engine = createEngine(config);
|
||||
|
||||
// Check if the script is valid
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const config = {
|
||||
apple: 'red',
|
||||
banana: 'yellow',
|
||||
apple: "red",
|
||||
banana: "yellow",
|
||||
};
|
||||
|
||||
export default config;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { describe } from 'vitest';
|
||||
import { describe } from "vitest";
|
||||
|
||||
import config from '../src/typescript-strict';
|
||||
import { checkLintingErrorsFromFile, checkValidity, createEngine } from './utils';
|
||||
import config from "../src/typescript-strict";
|
||||
import { checkLintingErrorsFromFile, checkValidity, createEngine } from "./utils";
|
||||
|
||||
describe('Typescript Strict Configuration', () => {
|
||||
describe("Typescript Strict Configuration", () => {
|
||||
const engine = createEngine({
|
||||
...config,
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -15,5 +15,5 @@ describe('Typescript Strict Configuration', () => {
|
|||
checkValidity(engine);
|
||||
|
||||
// check that there are no linting errors in the file
|
||||
checkLintingErrorsFromFile(engine, './tests/examples/example-1.ts');
|
||||
checkLintingErrorsFromFile(engine, "./tests/examples/example-1.ts");
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { describe } from 'vitest';
|
||||
import { describe } from "vitest";
|
||||
|
||||
import config from '../src/ultimate';
|
||||
import { checkLintingErrorsFromFile, checkValidity, createEngine } from './utils';
|
||||
import config from "../src/ultimate";
|
||||
import { checkLintingErrorsFromFile, checkValidity, createEngine } from "./utils";
|
||||
|
||||
describe('Ultimate Configuration', () => {
|
||||
describe("Ultimate Configuration", () => {
|
||||
const engine = createEngine({
|
||||
...config,
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -15,5 +15,5 @@ describe('Ultimate Configuration', () => {
|
|||
checkValidity(engine);
|
||||
|
||||
// Check the engine's linting errors.
|
||||
checkLintingErrorsFromFile(engine, './tests/examples/example-1.ts');
|
||||
checkLintingErrorsFromFile(engine, "./tests/examples/example-1.ts");
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { ESLint, Linter } from 'eslint';
|
||||
import { expect, it } from 'vitest';
|
||||
import { ESLint, Linter } from "eslint";
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
// Create an ESLint engine, based on a base config.
|
||||
export const createEngine = (baseConfig: Linter.Config) => {
|
||||
|
@ -10,17 +10,17 @@ export const createEngine = (baseConfig: Linter.Config) => {
|
|||
};
|
||||
|
||||
export const checkValidity = (engine: ESLint) => {
|
||||
it('is valid configuration', async () => {
|
||||
it("is valid configuration", async () => {
|
||||
// Linting an empty string is invalid, so we expect it to throw
|
||||
await expect(engine.lintText('')).resolves.not.toThrow();
|
||||
await expect(engine.lintText("")).resolves.not.toThrow();
|
||||
});
|
||||
};
|
||||
|
||||
// This test ensures that the linting engine is properly configured.
|
||||
export const checkLintingErrors = (engine: ESLint) => {
|
||||
it('does not produce linting errors', async () => {
|
||||
it("does not produce linting errors", async () => {
|
||||
// Run linting on an empty string.
|
||||
const lintResults = await engine.lintText('');
|
||||
const lintResults = await engine.lintText("");
|
||||
|
||||
// Expect that the linting engine does not produce any errors.
|
||||
expect(lintResults[0].errorCount).toBe(0);
|
||||
|
@ -28,7 +28,7 @@ export const checkLintingErrors = (engine: ESLint) => {
|
|||
};
|
||||
|
||||
export const checkLintingErrorsFromFile = (engine: ESLint, file: string) => {
|
||||
it('does not produce linting errors', async () => {
|
||||
it("does not produce linting errors", async () => {
|
||||
// Lint the file using the ESLint engine
|
||||
const lintResults = await engine.lintFiles(file);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
],
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@bravo68web/prettier-config",
|
||||
"version": "1.0.3",
|
||||
"version": "1.1.0",
|
||||
"description": "The official Prettier configuration for bravo68web projects",
|
||||
"author": "Bravo68web <hi@b68.dev> (https://github.com/bravo68web/)",
|
||||
"homepage": "https://github.com/bravo68web/nodejs-config#readme",
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
import prettier from 'prettier';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import prettier from "prettier";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import config from '../index.json';
|
||||
import config from "../index.json";
|
||||
|
||||
describe('Prettier Config', () => {
|
||||
it('is valid configuration', () => {
|
||||
describe("Prettier Config", () => {
|
||||
it("is valid configuration", () => {
|
||||
// Format the code with Prettier
|
||||
const code = prettier.format(
|
||||
'const foo=1',
|
||||
"const foo=1",
|
||||
Object.assign(config as prettier.Options, {
|
||||
parser: 'typescript',
|
||||
parser: "typescript",
|
||||
}) as prettier.Options,
|
||||
);
|
||||
|
||||
// Ensure it matches the expected formatting
|
||||
expect(code).toBe(`const foo = 1;
|
||||
`);
|
||||
expect(code).toBe(`const foo = 1;\n`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
|
||||
"noEmit": true,
|
||||
"noEmit": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitOverride": true,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"alwaysStrict": false,
|
||||
"declaration": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"esModuleInterop": true,
|
||||
"experimentalDecorators": true,
|
||||
"lib": ["es2018", "es5", "dom"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"noEmit": true,
|
||||
"outDir": "build",
|
||||
"resolveJsonModule": true,
|
||||
"strict": true,
|
||||
"target": "ES2017"
|
||||
},
|
||||
"display": "NoBuild tsconfig.json",
|
||||
"exclude": ["node_modules"],
|
||||
"extends": "./base.json",
|
||||
"files": ["types/index.d.ts"],
|
||||
"ts-node": {
|
||||
"swc": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"noEmit": true
|
||||
},
|
||||
"display": "NoBuild tsconfig.json",
|
||||
"exclude": ["node_modules"],
|
||||
"extends": "./base.json"
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
|
||||
"allowUnreachableCode": true,
|
||||
"allowUnusedLabels": true,
|
||||
"alwaysStrict": false,
|
||||
"checkJs": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
||||
"isolatedModules": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
|
||||
"noEmit": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": false,
|
||||
"noImplicitThis": false,
|
||||
"noUncheckedIndexedAccess": false,
|
||||
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": false,
|
||||
"strictFunctionTypes": false,
|
||||
"strictNullChecks": false,
|
||||
"strictPropertyInitialization": false,
|
||||
"target": "esnext"
|
||||
},
|
||||
"display": "Default tsconfig.json",
|
||||
"exclude": ["node_modules"]
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@bravo68web/tsconfig",
|
||||
"version": "1.0.3",
|
||||
"version": "1.1.0",
|
||||
"description": "Typescript config for bravo68web, ensure the consistency of code quality.",
|
||||
"license": "MIT",
|
||||
"author": "Bravo68web <hi@b68.dev> (https://github.com/bravo68web/)",
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
#!/usr/bin/env node
|
||||
/* eslint-disable security/detect-non-literal-fs-filename */
|
||||
|
||||
import { exec as _exec } from 'node:child_process';
|
||||
import { promises as fs } from 'node:fs';
|
||||
import { promisify } from 'node:util';
|
||||
import { exec as _exec } from "node:child_process";
|
||||
import { promises as fs } from "node:fs";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const exec = promisify(_exec);
|
||||
|
||||
const branch = await exec('git branch --show-current');
|
||||
if (!branch.stdout.startsWith('renovate/')) {
|
||||
console.log('Not a renovate branch, skipping');
|
||||
const branch = await exec("git branch --show-current");
|
||||
if (!branch.stdout.startsWith("renovate/")) {
|
||||
console.log("Not a renovate branch, skipping");
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const diffOutput = await exec('git diff --name-only HEAD~1');
|
||||
const diffOutput = await exec("git diff --name-only HEAD~1");
|
||||
const diffFiles = diffOutput.stdout
|
||||
.split('\n')
|
||||
.filter(file => file !== 'package.json')
|
||||
.filter(file => file.includes('package.json'));
|
||||
if (diffFiles.some(f => f.startsWith('.changeset'))) {
|
||||
console.log('Changeset already exists, skipping');
|
||||
.split("\n")
|
||||
.filter(file => file !== "package.json")
|
||||
.filter(file => file.includes("package.json"));
|
||||
if (diffFiles.some(f => f.startsWith(".changeset"))) {
|
||||
console.log("Changeset already exists, skipping");
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// If changed file does not include package.json in monorepo, skip
|
||||
if (!diffFiles.some(file => file.includes('package.json'))) {
|
||||
console.log('No package.json changes to published packages, skipping');
|
||||
if (!diffFiles.some(file => file.includes("package.json"))) {
|
||||
console.log("No package.json changes to published packages, skipping");
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ if (!diffFiles.some(file => file.includes('package.json'))) {
|
|||
*/
|
||||
// Find all changed package.json files and extract their dependencies
|
||||
const packageJsonFiles = await Promise.all(
|
||||
diffFiles.map(file => fs.readFile(file, 'utf8').then(data => ({ file, data }))),
|
||||
diffFiles.map(file => fs.readFile(file, "utf8").then(data => ({ file, data }))),
|
||||
);
|
||||
|
||||
const dependencies: {
|
||||
|
@ -62,7 +62,7 @@ const getChangedDependencies = (
|
|||
oldDepsObj: Record<string, string>,
|
||||
) => {
|
||||
for (const [depName, newVersion] of Object.entries(newDepsObj)) {
|
||||
if (typeof newVersion !== 'string') continue;
|
||||
if (typeof newVersion !== "string") continue;
|
||||
|
||||
const oldVersion: string = oldDepsObj[String(depName)];
|
||||
|
||||
|
@ -99,7 +99,8 @@ for (const { file } of packageJsonFiles) {
|
|||
dependencies: oldDeps = {},
|
||||
devDependencies: oldDevDeps = {},
|
||||
} = JSON.parse(oldDepsJson);
|
||||
const { dependencies: newDeps = {}, devDependencies: newDevDeps = {} } = JSON.parse(newDepsJson);
|
||||
const { dependencies: newDeps = {}, devDependencies: newDevDeps = {} } =
|
||||
JSON.parse(newDepsJson);
|
||||
|
||||
getChangedDependencies(projectName, newDeps, oldDeps);
|
||||
getChangedDependencies(projectName, newDevDeps, oldDevDeps);
|
||||
|
@ -107,12 +108,12 @@ for (const { file } of packageJsonFiles) {
|
|||
|
||||
// Create changeset
|
||||
async function createChangeset(fileName: string, packageBumps: string[][], packages: string[]) {
|
||||
let message = '';
|
||||
let message = "";
|
||||
for (const [pkg, bump] of packageBumps) {
|
||||
message = message + `Updated dependency \`${pkg}\` to \`${bump}\`.\n`;
|
||||
}
|
||||
|
||||
const pkgs = packages.map((pkg: string) => `'${pkg}': patch`).join('\n');
|
||||
const pkgs = packages.map((pkg: string) => `'${pkg}': patch`).join("\n");
|
||||
const body = `---\n${pkgs}\n---\n\n${message.trim()}\n`;
|
||||
|
||||
await fs.writeFile(fileName, body);
|
||||
|
@ -122,7 +123,7 @@ const addedFiles: string[] = [];
|
|||
|
||||
// Create changeset for each changed dependency
|
||||
for (const { name, newVersion, projects } of dependencies) {
|
||||
const safeName = name.replaceAll(/[^\w-]/g, '_').toLowerCase();
|
||||
const safeName = name.replaceAll(/[^\w-]/g, "_").toLowerCase();
|
||||
const fileName = `.changeset/${safeName}-${newVersion}.md`;
|
||||
|
||||
if (addedFiles.includes(fileName)) continue;
|
||||
|
@ -136,10 +137,10 @@ for (const { name, newVersion, projects } of dependencies) {
|
|||
}
|
||||
|
||||
// Add changeset files to git
|
||||
for (const fileName of addedFiles) await exec('git add ' + fileName);
|
||||
for (const fileName of addedFiles) await exec("git add " + fileName);
|
||||
|
||||
// Commit changeset
|
||||
await exec('git commit -C HEAD --amend --no-edit');
|
||||
await exec("git commit -C HEAD --amend --no-edit");
|
||||
|
||||
// Push changeset
|
||||
await exec('git push --force');
|
||||
await exec("git push --force");
|
||||
|
|
Loading…
Reference in New Issue