-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fc14166
Showing
16 changed files
with
7,106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Lint | ||
run: nr lint | ||
|
||
typecheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Typecheck | ||
run: nr typecheck | ||
|
||
test: | ||
runs-on: ${{ matrix.os }} | ||
|
||
strategy: | ||
matrix: | ||
node: [16.x, 18.x] | ||
os: [ubuntu-latest] | ||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set node ${{ matrix.node }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install | ||
run: nci | ||
|
||
- name: Build | ||
run: nr build | ||
|
||
- name: Test | ||
run: nr test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
{ | ||
// Enable the ESlint flat config support | ||
"eslint.experimental.useFlatConfig": true, | ||
// 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" | ||
}, | ||
{ | ||
"rule": "format/*", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-indent", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-spacing", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-spaces", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-order", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-dangle", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*-newline", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*quotes", | ||
"severity": "off" | ||
}, | ||
{ | ||
"rule": "*semi", | ||
"severity": "off" | ||
} | ||
], | ||
// Enable eslint for all supported languages | ||
"eslint.validate": [ | ||
"javascript", | ||
"javascriptreact", | ||
"typescript", | ||
"typescriptreact", | ||
"vue", | ||
"html", | ||
"markdown", | ||
"json", | ||
"jsonc", | ||
"yaml", | ||
"toml", | ||
"gql", | ||
"graphql" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
function safolor(color) { | ||
if (typeof color !== "string") | ||
throw new TypeError("Expected a string"); | ||
const hex = color.match( | ||
/^#(?:([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?|([\da-f]{1})([\da-f]{1})([\da-f]{1})([\da-f]{1})?)$/i | ||
); | ||
if (hex === null) | ||
throw new SyntaxError("Expected a HEX format"); | ||
const [_, rr, gg, bb, __, r, g, b, ___] = hex; | ||
const R = rr || r.padEnd(2, r); | ||
const G = gg || g.padEnd(2, g); | ||
const B = bb || b.padEnd(2, b); | ||
const nR = (Math.round(Number.parseInt(R, 16) / 51) * 51).toString(16); | ||
const nG = (Math.round(Number.parseInt(G, 16) / 51) * 51).toString(16); | ||
const nB = (Math.round(Number.parseInt(B, 16) / 51) * 51).toString(16); | ||
return `#${nR.padEnd(2, nR)}${nG.padEnd(2, nG)}${nB.padEnd(2, nB)}`; | ||
} | ||
|
||
exports.safolor = safolor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type HEX = `#${string}`; | ||
declare function safolor(color: HEX): HEX; | ||
|
||
export { type HEX, safolor }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type HEX = `#${string}`; | ||
declare function safolor(color: HEX): HEX; | ||
|
||
export { type HEX, safolor }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type HEX = `#${string}`; | ||
declare function safolor(color: HEX): HEX; | ||
|
||
export { type HEX, safolor }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function safolor(color) { | ||
if (typeof color !== "string") | ||
throw new TypeError("Expected a string"); | ||
const hex = color.match( | ||
/^#(?:([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?|([\da-f]{1})([\da-f]{1})([\da-f]{1})([\da-f]{1})?)$/i | ||
); | ||
if (hex === null) | ||
throw new SyntaxError("Expected a HEX format"); | ||
const [_, rr, gg, bb, __, r, g, b, ___] = hex; | ||
const R = rr || r.padEnd(2, r); | ||
const G = gg || g.padEnd(2, g); | ||
const B = bb || b.padEnd(2, b); | ||
const nR = (Math.round(Number.parseInt(R, 16) / 51) * 51).toString(16); | ||
const nG = (Math.round(Number.parseInt(G, 16) / 51) * 51).toString(16); | ||
const nB = (Math.round(Number.parseInt(B, 16) / 51) * 51).toString(16); | ||
return `#${nR.padEnd(2, nR)}${nG.padEnd(2, nG)}${nB.padEnd(2, nB)}`; | ||
} | ||
|
||
export { safolor }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import config from '@antfu/eslint-config' | ||
|
||
export default config() |
Oops, something went wrong.