Skip to content

Commit

Permalink
refactor: use config packages
Browse files Browse the repository at this point in the history
  • Loading branch information
PinkChampagne17 committed Dec 19, 2023
1 parent 4d27480 commit 40dd539
Show file tree
Hide file tree
Showing 25 changed files with 2,000 additions and 386 deletions.
11 changes: 10 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.{css,html,js,jsx,cjs,mjs,ts,tsx,mts,cts,vue}]
indent_size = 2

[*.{json,json5,yaml,yml}]
indent_size = 2
indent_style = space
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules
.eslintcache
packages/ends-with-miao/dist
12 changes: 7 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"eslint.experimental.useFlatConfig": true,
"eslint.options": {
"overrideConfigFile": "eslint.config.mjs"
},
"eslint.workingDirectories": [{ "mode": "auto" }]
"cSpell.words": ["autofix", "greasemonkey", "miao", "pinkchampagne"],
"eslint.experimental.useFlatConfig": true,
"eslint.workingDirectories": [
{
"mode": "auto"
}
]
}
6 changes: 3 additions & 3 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "pnpm",
"version": "0.0.0"
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"npmClient": "pnpm",
"version": "0.0.0"
}
30 changes: 16 additions & 14 deletions nx.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default",
"options": {
"cacheableOperations": ["build", "test"]
}
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build", "lint", "test"],
"outputs": ["{projectRoot}/dist"]
}
}
"tasksRunnerOptions": {
"default": {
"runner": "nx/tasks-runners/default"
}
},
"targetDefaults": {
"build": {
"dependsOn": ["^build"]
},
"lint": {
"dependsOn": ["build"]
},
"test": {
"dependsOn": ["lint"]
}
}
}
41 changes: 25 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
{
"private": "true",
"workspaces": [
"packages/*"
],
"packageManager": "pnpm@8.6.2",
"scripts": {
"build": "lerna run build",
"check": "prettier . --check && lerna run lint,test",
"lint": "prettier . --check && lerna run lint",
"lint:fix": "prettier . --write && lerna run lint:fix",
"test": "lerna run test"
},
"devDependencies": {
"lerna": "^7.1.4",
"prettier": "^3.0.0"
}
"private": "true",
"workspaces": [
"packages/*"
],
"packageManager": "pnpm@8.6.2",
"scripts": {
"build": "lerna run build",
"check": "prettier . --check && lerna run lint,test",
"lint": "prettier . --check && lerna run lint",
"lint:fix": "prettier . --write && lerna run lint:fix",
"test": "lerna run test"
},
"devDependencies": {
"@pinkchampagne/prettier-config": "^1.0.0",
"@pinkchampagne/tsconfig": "^1.0.0",
"eslint-config-pcp": "^1.0.0",
"lerna": "^7.1.4",
"prettier": "^3.0.0"
},
"pnpm": {
"patchedDependencies": {},
"overrides": {
"has": "npm:@nolyfill/has@latest"
}
}
}
1 change: 1 addition & 0 deletions packages/ends-with-miao/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
12 changes: 12 additions & 0 deletions packages/ends-with-miao/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// @ts-check
const { buildConfig } = require("eslint-config-pcp");

/** @type {import("eslint").Linter.FlatConfig[]} */
module.exports = [
...buildConfig({
typescript: {
files: ["src/**/*.ts"],
},
perfectionist: false, // TODO: remove
}),
];
47 changes: 23 additions & 24 deletions packages/ends-with-miao/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"name": "ends-with-miao",
"version": "1.0.0",
"description": "",
"author": "pinkchampagne",
"license": "AGPL-3.0",
"private": true,
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "rimraf dist && tsc -p ./tsconfig.json",
"test": "jest",
"test:watch": "jest --watchAll"
},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@types/jest": "^29.5.1",
"babel-jest": "^29.5.0",
"jest": "^29.5.0",
"rimraf": "^5.0.1",
"typescript": "^5.0.4",
"tsconfig": "workspace:*"
}
"name": "ends-with-miao",
"version": "1.0.0",
"description": "",
"author": "pinkchampagne",
"license": "AGPL-3.0",
"private": true,
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "rimraf dist && tsc -p ./tsconfig.json",
"test": "jest",
"test:watch": "jest --watchAll"
},
"devDependencies": {
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@babel/preset-typescript": "^7.21.4",
"@types/jest": "^29.5.1",
"babel-jest": "^29.5.0",
"jest": "^29.5.0",
"rimraf": "^5.0.1",
"typescript": "^5.0.4"
}
}
14 changes: 7 additions & 7 deletions packages/ends-with-miao/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"extends": "tsconfig",
"include": ["src"],
"compilerOptions": {
"declarationMap": true,
"outDir": "dist",
"types": ["@types/jest"]
}
"extends": "@pinkchampagne/tsconfig",
"include": ["src"],
"compilerOptions": {
"declarationMap": true,
"outDir": "dist",
"types": ["@types/jest"]
}
}
12 changes: 0 additions & 12 deletions packages/eslint-config-ewm/base.js

This file was deleted.

14 changes: 0 additions & 14 deletions packages/eslint-config-ewm/browser.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/eslint-config-ewm/index.js

This file was deleted.

15 changes: 0 additions & 15 deletions packages/eslint-config-ewm/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions packages/prettier-config/index.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions packages/prettier-config/package.json

This file was deleted.

15 changes: 0 additions & 15 deletions packages/tsconfig/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions packages/tsconfig/tsconfig.json

This file was deleted.

16 changes: 16 additions & 0 deletions packages/userscript/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// @ts-check
const { buildConfig } = require("eslint-config-pcp");

/** @type {import("eslint").Linter.FlatConfig[]} */
module.exports = [
{
files: ["src/**/*.js"],
},
...buildConfig({
javascript: {
env: {
greasemonkey: true,
},
},
}),
];
11 changes: 0 additions & 11 deletions packages/userscript/eslint.config.mjs

This file was deleted.

57 changes: 28 additions & 29 deletions packages/userscript/package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
{
"name": "userscript",
"version": "0.2.0",
"description": "将网页中的每一个句子结尾都加上「喵」字作为结尾的篡改猴脚本喵。",
"license": "AGPL-3.0",
"private": "true",
"author": "pinkchampagne",
"repository": {
"type": "git",
"url": "git+https://github.com/p-toy-factory/ends-with-miao.git"
},
"bugs": {
"url": "https://github.com/p-toy-factory/ends-with-miao/issues"
},
"homepage": "https://github.com/p-toy-factory/ends-with-miao#readme",
"scripts": {
"build": "webpack",
"lint": "env ESLINT_USE_FLAT_CONFIG=true eslint . -c eslint.config.mjs --cache",
"lint:fix": "pnpm run lint --fix"
},
"dependencies": {
"ends-with-miao": "workspace:1.x"
},
"devDependencies": {
"eslint": "^8.43.0",
"eslint-config-ewm": "workspace:^",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.81.0",
"webpack-cli": "^5.0.2"
}
"name": "userscript",
"version": "0.2.0",
"private": "true",
"description": "将网页中的每一个句子结尾都加上「喵」字作为结尾的篡改猴脚本喵。",
"author": "pinkchampagne",
"license": "AGPL-3.0",
"homepage": "https://github.com/p-toy-factory/ends-with-miao#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/p-toy-factory/ends-with-miao.git"
},
"bugs": {
"url": "https://github.com/p-toy-factory/ends-with-miao/issues"
},
"scripts": {
"build": "webpack",
"lint": "env ESLINT_USE_FLAT_CONFIG=true eslint . --cache",
"lint:fix": "pnpm run lint --fix"
},
"dependencies": {
"ends-with-miao": "workspace:1.x"
},
"devDependencies": {
"eslint": "^8.43.0",
"terser-webpack-plugin": "^5.3.9",
"webpack": "^5.81.0",
"webpack-cli": "^5.0.2"
}
}
1 change: 0 additions & 1 deletion packages/userscript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ function miao() {
requestIdleCallback(miao);

// @ts-ignore
// eslint-disable-next-line no-undef
GM_registerMenuCommand("手动触发", miao);
2 changes: 1 addition & 1 deletion packages/userscript/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const packageJson = require("./package.json");
const path = require("path");
const path = require("node:path");
const TerserPlugin = require("terser-webpack-plugin");
const webpack = require("webpack");

Expand Down
Loading

0 comments on commit 40dd539

Please sign in to comment.