Skip to content

Commit

Permalink
Cleanup tools (#1756)
Browse files Browse the repository at this point in the history
* Use prettier own instead of eslint plugin

* Extend prettier config angular eslint

* Upgrade root prettier to 3

* Fix css syntax errors

* Change eslint ignore to prettier ignore

* Ignore formatting for outputs

* Fix lint-staged error when edited multiple files

* Bump pnpm version

* Remove unnecessary pnpm config

---------

Co-authored-by: Eric Fennis <[email protected]>
  • Loading branch information
nix6839 and ericfennis authored Jan 18, 2024
1 parent 042393a commit 675158d
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 99 deletions.
11 changes: 1 addition & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ module.exports = {
node: true,
},
extends: ['airbnb-base', 'prettier'],
plugins: ['import', 'prettier', '@html-eslint'],
plugins: ['import', '@html-eslint'],
rules: {
'no-console': 'off',
'no-param-reassign': 'off',
'no-shadow': 'off',
'no-use-before-define': 'off',
'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'all',
printWidth: 100
},
],
'import/no-extraneous-dependencies': [
'error',
{ devDependencies: ['**/*.test.js', '**/*.spec.js', './scripts/**'] },
Expand All @@ -46,7 +38,6 @@ module.exports = {
files: ['./icons/*.svg'],
parser: '@html-eslint/parser',
rules: {
'prettier/prettier': 'off',
'@html-eslint/require-doctype': 'off',
'@html-eslint/no-duplicate-attrs': 'error',
'@html-eslint/no-inline-styles': 'error',
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
name: Install pnpm
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/check-icons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ runs:
name: Install pnpm
id: pnpm-install
with:
version: 7
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
16 changes: 16 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pnpm-lock.yaml

# lucide-angular
packages/lucide-angular/.angular/cache

# lucide-static
packages/lucide-static/icons
packages/lucide-static/lib
packages/lucide-static/sprite.svg
packages/lucide-static/tags.json
packages/lucide-static/icon-nodes.json
packages/lucide-static/font

# lucide-svelte
packages/lucide-svelte/src/icons/*.svelte
packages/lucide-svelte/.svelte-kit
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
.app {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr
grid-template-rows: 1fr 1fr 1fr;
gap: 6px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
.app {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr
grid-template-rows: 1fr 1fr 1fr;
gap: 6px;
}
23 changes: 23 additions & 0 deletions lint-staged.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @param {string[]} filenames
* @returns {string}
*/
const filenamesToAjvOption = (filenames) => filenames.map((filename) => `-d ${filename}`).join(' ');

/** @satisfies {import('lint-staged').Config} */
const config = {
'icons/*.svg': [
'node ./scripts/optimizeStagedSvgs.mjs',
'node ./scripts/generateNextJSAliases.mjs',
],
'icons/*.json': (filenames) => [
`ajv --spec=draft2020 -s icon.schema.json ${filenamesToAjvOption(filenames)}`,
`prettier --write ${filenames.join(' ')}`,
],
'categories/*.json': (filenames) => [
`ajv --spec=draft2020 -s category.schema.json ${filenamesToAjvOption(filenames)}`,
`prettier --write ${filenames.join(' ')}`,
],
};

export default config;
28 changes: 4 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
"generate:nextJSAliases": "node ./scripts/generateNextJSAliases.mjs",
"postinstall": "husky install",
"lint:es": "eslint .",
"lint:format": "prettier \"**/*.{js,mjs,ts,jsx,tsx,html,css,scss,json,yml,yaml}\" --write",
"lint:json:icons": "ajv --spec=draft2020 -s icon.schema.json -d 'icons/*.json' > /dev/null",
"lint:json:categories": "ajv --spec=draft2020 -s category.schema.json -d 'categories/*.json' > /dev/null",
"lint:json": "pnpm run lint:json:icons && pnpm run lint:json:categories",
"lint": "pnpm lint:es && pnpm lint:json",
"lint": "pnpm lint:es && pnpm lint:format && pnpm lint:json",
"prepare": "husky install",
"gi": "node ./scripts/generate/generateIcons.mjs"
},
Expand All @@ -52,40 +53,19 @@
"eslint-import-resolver-custom-alias": "^1.3.2",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"minimist": "^1.2.8",
"node-fetch": "^3.3.2",
"p-memoize": "^7.1.1",
"prettier": "2.7.1",
"prettier": "3.1.1",
"semver": "^7.5.4",
"simple-git": "^3.21.0",
"svgo": "^3.1.0",
"svgson": "^5.3.1"
},
"lint-staged": {
"icons/*.svg": [
"node ./scripts/optimizeStagedSvgs.mjs",
"node ./scripts/generateNextJSAliases.mjs"
],
"icons/*.json": [
"ajv --spec=draft2020 -s icon.schema.json -d",
"prettier --write --print-width=0"
],
"categories/*.json": [
"ajv --spec=draft2020 -s category.schema.json -d",
"prettier --write --print-width=0"
]
},
"packageManager": "[email protected]",
"packageManager": "[email protected]+sha256.9cebf61abd83f68177b29484da72da9751390eaad46dfc3072d266bfbb1ba7bf",
"pnpm": {
"peerDependencyRules": {
"ignoreMissing": [
"@babel/core",
"@babel/preset-env"
]
},
"packageExtensions": {
"vue-template-compiler": {
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/lucide-angular/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
'plugin:@typescript-eslint/recommended',
'plugin:@angular-eslint/recommended',
'plugin:@angular-eslint/template/process-inline-templates',
'prettier',
],
rules: {
'@angular-eslint/directive-selector': [
Expand Down
2 changes: 0 additions & 2 deletions packages/lucide-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"test": "ng test --no-watch --no-progress --browsers=ChromeHeadlessCI",
"test:watch": "ng test",
"lint": "npx eslint 'src/**/*.{js,jsx,ts,tsx,html,css,scss}' --quiet --fix",
"format": "npx prettier 'src/**/*.{js,jsx,ts,tsx,html,css,scss}' --write",
"e2e": "ng e2e",
"version": "pnpm version --git-tag-version=false"
},
Expand All @@ -59,7 +58,6 @@
"@typescript-eslint/parser": "5.48.2",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jasmine-core": "~4.0.0",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/lucide-vue/src/createLucideIcon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default (iconName: string, iconNode: IconNode): Component => ({
return createElement(
'svg',
{
// eslint-disable-next-line prettier/prettier
// prettier-ignore
class: [defaultClass, data.class, data.staticClass, data.attrs && data.attrs.class].filter(Boolean),
style: [data.style, data.staticStyle, data.attrs && data.attrs.style].filter(Boolean),
attrs: {
Expand Down
61 changes: 8 additions & 53 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/** @satisfies {import('prettier').Config} */
const config = {
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
overrides: [
{
files: ['icons/*.json', 'categories/*.json'],
options: {
printWidth: 0,
},
},
],
};

export default config;
8 changes: 4 additions & 4 deletions scripts/generateSuperSVG.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { stringify, parseSync } from 'svgson';
import prettier from 'prettier';
import * as prettier from 'prettier';
import { appendFile, readSvgDirectory, getCurrentDirPath } from './helpers.mjs';

import readSvgs from '../packages/lucide-static/scripts/readSvgs.mjs';
Expand All @@ -10,7 +10,7 @@ const currentDir = getCurrentDirPath(import.meta.url);
const ICONS_DIR = path.resolve('icons');
const PACKAGE_DIR = path.resolve(currentDir);

export default function generateSprite(svgs, packageDir) {
async function generateSprite(svgs, packageDir) {
const symbols = svgs.map(({ parsedSvg }, index) => {
const itemsPerRow = 10;
const numInRow = index % itemsPerRow;
Expand All @@ -37,7 +37,7 @@ export default function generateSprite(svgs, packageDir) {
};

const spriteSvg = stringify(spriteSvgObject);
const prettifiedSprite = prettier.format(spriteSvg, { parser: 'babel' }).replace(/;/g, '');
const prettifiedSprite = (await prettier.format(spriteSvg, { parser: 'babel' })).replace(/;/g, '');

const xmlMeta = `<?xml version="1.0" encoding="utf-8"?>\n`;

Expand All @@ -54,4 +54,4 @@ const parsedSvgs = svgs.map(({ name, contents }) => ({
parsedSvg: parseSync(contents),
}));

generateSprite(parsedSvgs, PACKAGE_DIR);
await generateSprite(parsedSvgs, PACKAGE_DIR);
2 changes: 1 addition & 1 deletion scripts/render/processSvg.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {optimize} from 'svgo';
import prettier from 'prettier';
import * as prettier from 'prettier';
import {parseSync, stringify} from 'svgson';
import DEFAULT_ATTRS from './default-attrs.json' assert { type: 'json' };

Expand Down

0 comments on commit 675158d

Please sign in to comment.