Skip to content

Commit 3fb44e1

Browse files
committed
first commit
0 parents  commit 3fb44e1

14 files changed

Lines changed: 4287 additions & 0 deletions

.eslintignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/.github/**
2+
/.vscode/**
3+
/public/**
4+
next-env.d.ts
5+
next.config.js
6+
app.js
7+
/dist

.eslintrc.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*eslint-env node*/
2+
module.exports = {
3+
root: true,
4+
env: {
5+
browser: true,
6+
es2020: true,
7+
},
8+
extends: [
9+
'eslint:recommended',
10+
'plugin:@typescript-eslint/eslint-recommended',
11+
'plugin:@typescript-eslint/recommended',
12+
'plugin:react/recommended',
13+
'plugin:import/errors',
14+
'plugin:import/warnings',
15+
'plugin:prettier/recommended',
16+
'prettier',
17+
],
18+
parser: '@typescript-eslint/parser',
19+
parserOptions: {
20+
ecmaFeatures: {
21+
jsx: true,
22+
},
23+
ecmaVersion: 2020,
24+
sourceType: 'module',
25+
},
26+
plugins: ['@typescript-eslint', 'react', 'import'],
27+
settings: {
28+
'import/resolver': {
29+
node: {
30+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
31+
moduleDirectory: ['node_modules/'],
32+
},
33+
typescript: {
34+
config: 'tsconfig.json',
35+
alwaysTryTypes: true,
36+
},
37+
},
38+
react: {
39+
version: 'detect',
40+
},
41+
},
42+
rules: {
43+
'@typescript-eslint/ban-types': [
44+
'error',
45+
{
46+
types: {
47+
'{}': false,
48+
},
49+
},
50+
],
51+
'react/prop-types': ['off'],
52+
'react/react-in-jsx-scope': 'off',
53+
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
54+
'import/order': ['error'],
55+
'no-unused-vars': 'off',
56+
'@typescript-eslint/no-unused-vars': ['error'],
57+
'prettier/prettier': [
58+
'error',
59+
{
60+
trailingComma: 'all',
61+
endOfLine: 'lf',
62+
semi: true,
63+
singleQuote: true,
64+
printWidth: 162,
65+
tabWidth: 2,
66+
},
67+
],
68+
},
69+
};

.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
# See https://help.github.com/ignore-files/ for more about ignoring files.
3+
4+
# dependencies
5+
/node_modules
6+
7+
# misc
8+
.DS_Store
9+
.env.local
10+
.env.development.local
11+
.env.test.local
12+
.env.production.local
13+
14+
npm-debug.log*
15+
yarn-debug.log*
16+
yarn-error.log*
17+
18+
# Next.js
19+
/.next
20+
21+
/storybook-static
22+
23+
*.log
24+
25+
/dist/
26+
/coverage

.vscode/extensions.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"eamodio.gitlens",
5+
"streetsidesoftware.code-spell-checker",
6+
"esbenp.prettier-vscode",
7+
"firsttris.vscode-jest-runner",
8+
"vscode-icons-team.vscode-icons"
9+
]
10+
}

.vscode/settings.json

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
// 既定の改行文字。LF の場合には \n を CRLF の場合には \r\n を使用してください。
3+
"files.eol": "\n",
4+
// 指定した構文に対してプロファイルを定義するか、特定の規則がある独自のプロファイルをご使用ください。
5+
"emmet.syntaxProfiles": {
6+
"javascript": "jsx"
7+
},
8+
9+
// use stylelint-plus
10+
// see https://qiita.com/y-w/items/bd7f11013fe34b69f0df#vs-code%E3%81%A8%E7%B5%84%E3%81%BF%E5%90%88%E3%82%8F%E3%81%9B%E3%82%8B
11+
"css.validate": false,
12+
"scss.validate": false,
13+
"[css]": {
14+
"editor.formatOnSave": true
15+
},
16+
"[scss]": {
17+
"editor.formatOnSave": true
18+
},
19+
"stylelint.autoFixOnSave": true,
20+
21+
// for vscode-eslint
22+
"[javascript]": {
23+
"editor.formatOnSave": false
24+
},
25+
"editor.codeActionsOnSave": {
26+
"source.fixAll.eslint": true,
27+
"source.fixAll.markdownlint": true
28+
},
29+
"cSpell.words": [
30+
"NEXTAUTH",
31+
"Subnav",
32+
"Webev",
33+
"browserconfig",
34+
"countup",
35+
"favicons",
36+
"gtag",
37+
"hoge",
38+
"huga",
39+
"ipagp",
40+
"itizawa",
41+
"mixins",
42+
"msapplication",
43+
"noopener",
44+
"noreferrer",
45+
"pageview",
46+
"piyo",
47+
"randomstring",
48+
"stylelint",
49+
"toastr",
50+
"unstyled"
51+
]
52+
}
53+

jest.config.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"preset":"ts-jest",
3+
"testEnvironment":"node",
4+
"roots":[
5+
"<rootDir>/src"
6+
],
7+
"testPathIgnorePatterns":[
8+
"<rootDir>/.next/",
9+
"<rootDir>/node_modules/"
10+
],
11+
"transform":{
12+
"^.+\\.(ts|tsx)$":"ts-jest"
13+
},
14+
"moduleFileExtensions":[
15+
"ts",
16+
"tsx",
17+
"js",
18+
"jsx",
19+
"json",
20+
"node"
21+
],
22+
"globals":{
23+
"ts-jest":{
24+
"tsconfig":"<rootDir>/tsconfig.json"
25+
}
26+
},
27+
"moduleNameMapper": {
28+
"^~/(.*)$": "<rootDir>/src/$1"
29+
}
30+
}

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "webev-utils",
3+
"version": "1.0.0",
4+
"description": "webev-utils for webev app",
5+
"main": "dist/index.js",
6+
"module": "dist/esm/index.js",
7+
"types": "dist/esm/index.d.ts",
8+
"license": "MIT",
9+
"scripts": {
10+
"prebuild": "rimraf dist",
11+
"build": "run-p build:*",
12+
"build:common": "tsc",
13+
"build:esm": "tsc -p tsconfig.esm.json",
14+
"test": "jest",
15+
"lint": "eslint \"./**/*.{js,jsx,ts,tsx}\""
16+
},
17+
"volta": {
18+
"node": "14.17.4"
19+
},
20+
"devDependencies": {
21+
"@jest/types": "^27.0.6",
22+
"@types/jest": "^26.0.24",
23+
"@types/node": "^16.4.13",
24+
"@typescript-eslint/eslint-plugin": "^4.29.0",
25+
"@typescript-eslint/parser": "^4.29.0",
26+
"eslint": "^7.32.0",
27+
"eslint-config-prettier": "^8.3.0",
28+
"eslint-plugin-import": "^2.24.0",
29+
"eslint-plugin-prettier": "^3.4.0",
30+
"eslint-plugin-react": "^7.24.0",
31+
"jest": "^27.0.6",
32+
"npm-run-all": "^4.1.5",
33+
"prettier": "^2.3.2",
34+
"rimraf": "^3.0.2",
35+
"ts-jest": "^27.0.4",
36+
"ts-node": "^10.2.0",
37+
"typescript": "^4.3.5"
38+
},
39+
"files": [
40+
"dist"
41+
]
42+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { isValidUrl } from './isValidUrl';

src/isValidUrl/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { isValidUrl } from './isValidUrl';

src/isValidUrl/isValidUrl.spec.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { isValidUrl } from './isValidUrl';
2+
3+
describe('isValidUrl', (): void => {
4+
test('string', (): void => {
5+
const response = isValidUrl('hoge');
6+
expect(response).toBeFalsy();
7+
});
8+
9+
test('invalid', (): void => {
10+
const response = isValidUrl('example.com');
11+
expect(response).toBeFalsy();
12+
});
13+
14+
test('empty string', (): void => {
15+
const response = isValidUrl('');
16+
expect(response).toBeFalsy();
17+
});
18+
19+
test('https', (): void => {
20+
const response = isValidUrl('https://example.com');
21+
expect(response).toBeTruthy();
22+
});
23+
24+
test('http', (): void => {
25+
const response = isValidUrl('http://example.com');
26+
expect(response).toBeTruthy();
27+
});
28+
29+
test('with slash', (): void => {
30+
const response = isValidUrl('https://example.com/');
31+
expect(response).toBeTruthy();
32+
});
33+
});

0 commit comments

Comments
 (0)