Skip to content

Commit

Permalink
Refactor Lint/Format Setup (#499)
Browse files Browse the repository at this point in the history
  • Loading branch information
paescuj authored Dec 16, 2024
1 parent a1003eb commit 2bf8087
Show file tree
Hide file tree
Showing 96 changed files with 3,860 additions and 6,768 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

46 changes: 0 additions & 46 deletions .eslintrc.cjs

This file was deleted.

File renamed without changes.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ Before reporting an issue, please search to see if someone has filed a similar i

## Prerequisites

* Version:
* Are you running from source/main:
* Are you using a released build:
* Operating system:
- Version:
- Are you running from source/main:
- Are you using a released build:
- Operating system:

## Step to reproduce

*(Type here)*
_(Type here)_

### Actual behavior

## Any message or error

*(Type here)*
_(Type here)_

## Additional info or screenshots

* Screenshots
- Screenshots
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/icon_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ Before creating an icon request, please search to see if someone has requested t

## Icon Request

* Icon name:
* Use case:
* Screenshots of similar icons:
- Icon name:
- Use case:
- Screenshots of similar icons:
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v45

- name: Checkout repository
uses: actions/checkout@v4

- name: Setup
uses: ./.github/actions/setup

- name: Run Linter
run: pnpm exec eslint ${{ steps.changed-files.outputs.all_changed_files }}
24 changes: 12 additions & 12 deletions .github/workflows/website.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: Website

on:
workflow_dispatch:
workflow_run:
workflows:
- Release
types:
- completed

permissions:
actions: read
contents: read
pages: write
id-token: write

concurrency:
group: pages
group: ${{ github.workflow }}
cancel-in-progress: true

on:
workflow_dispatch:
workflow_run:
workflows:
- Release
types:
- completed

jobs:
build:
name: Build
Expand All @@ -33,7 +33,7 @@ jobs:
run: pnpm run build react

- name: Build website
run: ./node_modules/.bin/next build
run: pnpm run build
working-directory: iconoir.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -44,12 +44,12 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './iconoir.com/out'
path: ./iconoir.com/out

deploy:
name: Deploy
runs-on: ubuntu-latest
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
1 change: 0 additions & 1 deletion .prettierignore

This file was deleted.

4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

50 changes: 50 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"json5",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}
26 changes: 13 additions & 13 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand All @@ -118,11 +118,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].

Community Impact Guidelines were inspired by
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
at [https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ You can switch between icons from the right sidebar in the editor.
Import the CSS file:

```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/iconoir-icons/iconoir@main/css/iconoir.css"
/>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/iconoir-icons/iconoir@main/css/iconoir.css" />
```

Here is an example in HTML:
Expand Down
7 changes: 4 additions & 3 deletions bin/build/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Listr } from 'listr2';
import fs from 'node:fs/promises';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { Listr } from 'listr2';
import { pascalCase, snakeCase } from 'scule';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -37,6 +38,8 @@ const targets = {
},
};

const cliTargets = [];

const tasks = new Listr(
[
{
Expand Down Expand Up @@ -110,8 +113,6 @@ const tasks = new Listr(
},
);

const cliTargets = [];

// Get targets from command line arguments
// (build all targets if no arguments given)
for (const arg of process.argv.slice(2)) {
Expand Down
3 changes: 2 additions & 1 deletion bin/build/lib/import-export.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import path from 'node:path';

export function generateImport(name, from) {
if (Array.isArray(name)) name = `{${name.toString()}}`;
if (Array.isArray(name))
name = `{${name.toString()}}`;

return `import ${name} from "${from}";`;
}
Expand Down
7 changes: 5 additions & 2 deletions bin/build/lib/ts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ export function getDts(path, content, options) {
const _readFile = host.readFile;

host.readFile = (filename) => {
if (filename === path) return content;
if (filename === path)
return content;

return _readFile(filename);
};

const dtsFilename = path.replace(/\.(m|c)?(ts|js)x?$/, '.d.$1ts');

host.writeFile = (filename, contents) => {
if (filename === dtsFilename) output = contents;
if (filename === dtsFilename)
output = contents;
};

const program = ts.createProgram([path], options, host);
Expand All @@ -40,6 +42,7 @@ export function getDts(path, content, options) {
diagnostic.file,
diagnostic.start,
);

const message = ts.flattenDiagnosticMessageText(
diagnostic.messageText,
'\n',
Expand Down
11 changes: 5 additions & 6 deletions bin/build/targets/css/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ export default async (ctx, target) => {
const variantCssContent = [header];

const cssTarget = (icon, suffixed) => {
const iconName =
suffixed && variant !== ctx.global.defaultVariant
? icon.nameVariant
: icon.name;
const iconName = suffixed && variant !== ctx.global.defaultVariant
? icon.nameVariant
: icon.name;

return `.iconoir-${iconName}::before`;
};
Expand All @@ -31,8 +30,8 @@ export default async (ctx, target) => {

const transformedContent = fileContent
.replace(/\n/g, '')
.replace(/(width|height)="[0-9]+px"/g, '')
.replace(/[ ]+/g, ' ');
.replace(/(width|height)="\d+px"/g, '')
.replace(/ +/g, ' ');

const cssContent = `{mask-image:url('data:image/svg+xml;charset=utf-8,${transformedContent}');-webkit-mask-image:url('data:image/svg+xml;charset=utf-8,${transformedContent}');}`;

Expand Down
Loading

0 comments on commit 2bf8087

Please sign in to comment.