Skip to content

Commit 81e5b38

Browse files
committed
fix: update eslint and other deps
1 parent 1298dd7 commit 81e5b38

File tree

6 files changed

+108
-40
lines changed

6 files changed

+108
-40
lines changed

lib/generators/app/templates/_root/_eslintignore

-3
This file was deleted.

lib/generators/app/templates/_root/_eslintrc.js

-13
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import js from '@eslint/js';
2+
import prettier from 'eslint-config-prettier';
3+
import globals from 'globals';
4+
import ts from 'typescript-eslint';
5+
6+
/** @type {import('eslint').Linter.Config[]} */
7+
export default [
8+
js.configs.recommended,
9+
...ts.configs.recommended,
10+
prettier,
11+
{
12+
languageOptions: {
13+
globals: {
14+
...globals.browser,
15+
...globals.node,
16+
},
17+
},
18+
},
19+
{
20+
ignores: ['dist/'],
21+
},
22+
];

lib/generators/app/templates/_root/package.json

+39-15
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"prepare": "husky",
1313
"dev": "rollup -wc",
1414
"clean": "del-cli dist",
15-
"lint": "eslint --ext .ts,.tsx . && prettier --ignore-path .eslintignore --check .",
16-
"lint:fix": "eslint --ext .ts,.tsx --fix . && prettier --ignore-path .eslintignore --write .",
15+
"lint": "eslint",
16+
"lint:fix": "eslint --fix",
1717
"ci": "run-s lint",
1818
"build:js": "rollup -c",
1919
"build": "cross-env NODE_ENV=production run-s ci clean build:js"
@@ -25,24 +25,48 @@
2525
"solid-js": "^1.8.16"
2626
},
2727
"devDependencies": {
28-
"@babel/plugin-transform-react-jsx": "^7.23.4",
29-
"@gera2ld/plaid": "~2.7.0",
30-
"@gera2ld/plaid-rollup": "~2.7.0",
31-
"@unocss/postcss": "^0.58.6",
32-
"@violentmonkey/types": "^0.1.7",
33-
"babel-preset-solid": "^1.8.16",
28+
"@babel/core": "^7.26.0",
29+
"@babel/plugin-transform-react-jsx": "^7.25.9",
30+
"@babel/plugin-transform-runtime": "^7.25.9",
31+
"@babel/preset-env": "^7.26.0",
32+
"@babel/preset-typescript": "^7.26.0",
33+
"@rollup/plugin-alias": "^5.1.1",
34+
"@rollup/plugin-babel": "^6.0.4",
35+
"@rollup/plugin-commonjs": "^28.0.2",
36+
"@rollup/plugin-json": "^6.1.0",
37+
"@rollup/plugin-node-resolve": "^16.0.0",
38+
"@rollup/plugin-replace": "^6.0.2",
39+
"@rollup/plugin-terser": "^0.4.4",
40+
"@types/eslint": "^9.6.1",
41+
"@typescript-eslint/eslint-plugin": "^8.18.1",
42+
"@typescript-eslint/parser": "^8.18.1",
43+
"@unocss/postcss": "^0.65.2",
44+
"@violentmonkey/types": "^0.2.0",
45+
"autoprefixer": "^10.4.20",
46+
"babel-preset-solid": "^1.9.3",
47+
"commander": "^12.1.0",
3448
"cross-env": "^7.0.3",
35-
"del-cli": "^5.1.0",
49+
"del-cli": "^6.0.0",
50+
"eslint": "^9.17.0",
3651
"eslint-config-prettier": "^9.1.0",
37-
"husky": "^9.0.11",
38-
"lint-staged": "^15.2.2",
39-
"prettier": "^3.2.5",
52+
"globals": "^15.14.0",
53+
"husky": "^9.1.7",
54+
"lint-staged": "^15.2.11",
55+
"npm-run-all": "^4.1.5",
56+
"postcss": "^8.4.49",
57+
"postcss-calc": "^10.0.2",
58+
"postcss-nested": "^7.0.2",
59+
"prettier": "^3.4.2",
4060
"read-package-up": "^11.0.0",
41-
"rollup-plugin-userscript": "^0.3.2",
42-
"unocss": "^0.58.6"
61+
"rollup": "^4.29.1",
62+
"rollup-plugin-postcss": "^4.0.2",
63+
"rollup-plugin-userscript": "^0.3.5",
64+
"typescript": "^5.7.2",
65+
"typescript-eslint": "^8.18.1",
66+
"unocss": "^0.65.2"
4367
},
4468
"lint-staged": {
45-
"*.ts": [
69+
"*.{ts,tsx}": [
4670
"eslint --fix",
4771
"prettier --write"
4872
],

lib/generators/app/templates/_root/rollup.config.mjs

+46-8
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,51 @@
1-
import { defineExternal, definePlugins } from '@gera2ld/plaid-rollup';
1+
import babelPlugin from '@rollup/plugin-babel';
2+
import commonjsPlugin from '@rollup/plugin-commonjs';
3+
import jsonPlugin from '@rollup/plugin-json';
4+
import resolvePlugin from '@rollup/plugin-node-resolve';
5+
import replacePlugin from '@rollup/plugin-replace';
6+
import { isAbsolute, relative, resolve } from 'path';
27
import { readPackageUp } from 'read-package-up';
38
import { defineConfig } from 'rollup';
9+
import postcssPlugin from 'rollup-plugin-postcss';
410
import userscript from 'rollup-plugin-userscript';
511

612
const { packageJson } = await readPackageUp();
13+
const extensions = ['.ts', '.tsx', '.mjs', '.js', '.jsx'];
714

815
export default defineConfig(
916
Object.entries({
1017
'awesome-script': 'src/awesome-script/index.ts',
1118
}).map(([name, entry]) => ({
1219
input: entry,
1320
plugins: [
14-
...definePlugins({
15-
esm: true,
16-
minimize: false,
17-
postcss: {
18-
inject: false,
19-
minimize: true,
21+
postcssPlugin({
22+
inject: false,
23+
minimize: true,
24+
}),
25+
babelPlugin({
26+
// import helpers from '@babel/runtime'
27+
babelHelpers: 'runtime',
28+
plugins: [
29+
[
30+
import.meta.resolve('@babel/plugin-transform-runtime'),
31+
{
32+
useESModules: true,
33+
version: '^7.5.0', // see https://github.com/babel/babel/issues/10261#issuecomment-514687857
34+
},
35+
],
36+
],
37+
exclude: 'node_modules/**',
38+
extensions,
39+
}),
40+
replacePlugin({
41+
values: {
42+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
2043
},
21-
extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx'],
44+
preventAssignment: true,
2245
}),
46+
resolvePlugin({ browser: false, extensions }),
47+
commonjsPlugin(),
48+
jsonPlugin(),
2349
userscript((meta) =>
2450
meta.replace('process.env.AUTHOR', packageJson.author.name),
2551
),
@@ -46,3 +72,15 @@ export default defineConfig(
4672
},
4773
})),
4874
);
75+
76+
function defineExternal(externals) {
77+
return (id) =>
78+
externals.some((pattern) => {
79+
if (typeof pattern === 'function') return pattern(id);
80+
if (pattern && typeof pattern.test === 'function')
81+
return pattern.test(id);
82+
if (isAbsolute(pattern))
83+
return !relative(pattern, resolve(id)).startsWith('..');
84+
return id === pattern || id.startsWith(pattern + '/');
85+
});
86+
}

lib/generators/app/templates/src/awesome-script/meta.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
*
1717
* - The `@grant`s used in your source code will be added automatically by `rollup-plugin-userscript`.
1818
* However you have to add explicitly those used in required resources.
19-
* - `process.env.VERSION` and `process.env.AUTHOR` will be loaded from `package.json`.
19+
* - `process.env.AUTHOR` will be loaded from `package.json`.
2020
*/

0 commit comments

Comments
 (0)