Skip to content

Commit

Permalink
chore(monorepo): 🔧 upgrade dependencies and improve eslint conig sett…
Browse files Browse the repository at this point in the history
…ings
  • Loading branch information
a-luna committed Jan 29, 2024
1 parent fb2c00f commit 16d263e
Show file tree
Hide file tree
Showing 7 changed files with 1,536 additions and 1,412 deletions.
10 changes: 0 additions & 10 deletions .eslintrc.cjs

This file was deleted.

83 changes: 40 additions & 43 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,56 @@ const DEPENDENCY_TYPES = ['dependencies', 'devDependencies', 'optionalDependenci
const REMOVE_DEPENDENCIES = ['playwright', 'safaridriver', 'webdriverio'];

function readPackage(pkg, context) {
if (process.env.NODE_ENV === 'production') {
const searchResults = searchAllDependencies(pkg);
if (searchResults.hasDep) {
searchResults.results.forEach((pkgDeps, depType) => {
pkgDeps.forEach(([depName, _]) => (pkg[depType] = removeDepFromPackage(pkg, depName, depType)));
});
}
}
return pkg;
if (process.env.NODE_ENV === 'production') {
const searchResults = searchAllDependencies(pkg);
if (searchResults.hasDep) {
searchResults.results.forEach((pkgDeps, depType) => {
pkgDeps.forEach(([depName, _]) => (pkg[depType] = removeDepFromPackage(pkg, depName, depType)));
});
}
}
return pkg;
}

function searchAllDependencies(pkg, depName) {
const pkgDepTypeMap = {
dependencies: pkg.dependencies,
devDependencies: pkg.devDependencies,
optionalDependencies: pkg.optionalDependencies,
peerDependencies: pkg.peerDependencies,
};

let hasDep = false;
const results = new Map();
DEPENDENCY_TYPES.forEach((type) => {
REMOVE_DEPENDENCIES.forEach((depName) => {
const resultsForDepType = searchDependencies(depName, pkgDepTypeMap[type], type);
if (resultsForDepType.length > 0) {
hasDep = true;
results.set(type, resultsForDepType);
}
});
});

return { name: pkg.name, depName, hasDep, results };
const pkgDepTypeMap = {
dependencies: pkg.dependencies,
devDependencies: pkg.devDependencies,
optionalDependencies: pkg.optionalDependencies,
peerDependencies: pkg.peerDependencies,
};

let hasDep = false;
const results = new Map();
DEPENDENCY_TYPES.forEach((type) => {
REMOVE_DEPENDENCIES.forEach((depName) => {
const resultsForDepType = searchDependencies(depName, pkgDepTypeMap[type], type);
if (resultsForDepType.length > 0) {
hasDep = true;
results.set(type, resultsForDepType);
}
});
});

return { name: pkg.name, depName, hasDep, results };
}

function searchDependencies(searchDep, dependencies, type) {
return Object.keys(dependencies)
.filter((name) => name.includes(searchDep))
.map((name) => [name, type]);
return Object.keys(dependencies)
.filter((name) => name.includes(searchDep))
.map((name) => [name, type]);
}

function removeDepFromPackage(pkg, depName, depType) {
const dependencies = JSON.parse(JSON.stringify(pkg[depType]));
if (dependencies[depName]) {
delete dependencies[depName];
}
return dependencies;
const dependencies = JSON.parse(JSON.stringify(pkg[depType]));
if (dependencies[depName]) {
delete dependencies[depName];
}
return dependencies;
}

// const removeDepsFromPackage = (pkg, removeDeps, depType) =>
// pkg[depType].filter((dep) => !removeDeps.map(([removeDepName, _]) => removeDepName).includes(dep.name));

module.exports = {
hooks: {
readPackage,
},
hooks: {
readPackage,
},
};
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
"deploy:base64": "NODE_ENV=production && pnpm run iprod:ui && pnpm run build:ui && pnpm run iprod:base64 && pnpm run bprod:base64"
},
"dependencies": {
"svelte": "^3.59.2"
"svelte": "^4.2.7"
},
"devDependencies": {
"@changesets/cli": "^2.26.2",
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1"
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2"
},
"type": "module",
"private": true,
Expand Down
63 changes: 52 additions & 11 deletions packages/svelte-color-tools/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:svelte/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
plugins: ['svelte3', '@typescript-eslint'],
ignorePatterns: ['*.cjs'],
overrides: [{ files: ['*.svelte'], processor: 'svelte3/svelte3' }],
settings: {
'svelte3/typescript': () => require('typescript'),
},
plugins: ['@typescript-eslint'],
parserOptions: {
ecmaVersion: '2020',
sourceType: 'module',
ecmaVersion: 2020,
tsconfigRootDir: __dirname,
project: ['./tsconfig.eslint.json'],
extraFileExtensions: ['.svelte'],
},
env: {
browser: true,
es2017: true,
es2021: true,
node: true,
},
global: {
rules: {
// Note: you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
},
],
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
},
{
files: ['*.ts'],
rules: {
'no-mixed-spaces-and-tabs': 'off',
},
},
],
settings: {
svelte: {
ignoreWarnings: ['svelte/no-at-html-tags'],
compileOptions: {
postcss: {
configFilePath: './postcss.config.cjs',
},
},
kit: {
files: {
routes: 'src/routes',
},
},
},
},
globals: {
NodeJS: true,
},
ignorePatterns: ['*.cjs'],
};
41 changes: 20 additions & 21 deletions packages/svelte-color-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,44 +31,43 @@
"dependencies": {
"@a-luna/shared-ui": "workspace:*",
"@a-luna/svelte-simple-tables": "^0.0.29",
"@sveltejs/adapter-auto": "^2.1.1",
"@sveltejs/kit": "^1.30.3",
"@sveltejs/package": "^2.2.3",
"@sveltejs/adapter-auto": "^3.1.1",
"@sveltejs/kit": "^2.5.0",
"@sveltejs/package": "^2.2.6",
"@sveltejs/vite-plugin-svelte": "^3.0.1",
"cssnano": "^5.1.15",
"esm-env": "^1.0.0",
"highlight.js": "^11.9.0",
"svelte": "^3.59.2",
"vite": "^4.5.1"
"svelte": "^4.2.9",
"vite": "^5.0.12"
},
"devDependencies": {
"@playwright/test": "^1.40.1",
"@testing-library/dom": "^8.20.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/svelte": "^3.2.2",
"@testing-library/user-event": "^14.5.1",
"@testing-library/user-event": "^14.5.2",
"@tsconfig/svelte": "^3.0.0",
"@types/node": "^18.19.3",
"@types/node": "^18.19.10",
"@types/testing-library__jest-dom": "^5.14.9",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"@vitest/coverage-v8": "^0.33.0",
"@vitest/ui": "^0.33.0",
"autoprefixer": "^10.4.16",
"eslint": "^8.55.0",
"eslint-config-prettier": "^8.10.0",
"autoprefixer": "^10.4.17",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-svelte3": "^4.0.0",
"eslint-plugin-svelte": "^2.35.1",
"jsdom": "^21.1.2",
"playwright": "^1.40.1",
"postcss": "^8.4.32",
"postcss-html": "^1.5.0",
"postcss": "^8.4.33",
"postcss-html": "^1.6.0",
"postcss-load-config": "^4.0.2",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"svelte-check": "^3.6.2",
"prettier": "^3.2.4",
"prettier-plugin-svelte": "^3.1.2",
"svelte-check": "^3.6.3",
"svelte-highlight": "^6.2.1",
"svelte-icons": "^2.1.0",
"tailwindcss": "^3.3.6",
"tailwindcss": "^3.4.1",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vitest": "^0.33.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-color-tools/svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
Expand Down
Loading

0 comments on commit 16d263e

Please sign in to comment.