Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit faff56a

Browse files
committed
setup linting, formatting, and testing
1 parent f35ee68 commit faff56a

File tree

15 files changed

+3802
-1596
lines changed

15 files changed

+3802
-1596
lines changed

.eslintrc.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict'
2+
3+
module.exports = {
4+
root: true,
5+
globals: {
6+
browser: true
7+
},
8+
env: {
9+
node: true,
10+
jest: true
11+
},
12+
extends: [
13+
'@antfu/eslint-config-ts',
14+
'plugin:prettier/recommended',
15+
'prettier'
16+
],
17+
rules: {}
18+
}

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Lint
2+
on:
3+
push:
4+
branches-ignore:
5+
- gh-pages
6+
- releases/**
7+
pull_request:
8+
branches-ignore:
9+
- gh-pages
10+
- releases/**
11+
types:
12+
- opened
13+
- synchronize
14+
- reopened
15+
permissions:
16+
contents: read
17+
env:
18+
CI: true
19+
20+
jobs:
21+
lint:
22+
name: 'Lint'
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
- name: Setup Node.js v14.x
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: 14
31+
cache: 'npm'
32+
- name: Install
33+
run: npm install
34+
- name: Lint
35+
run: npm run lint

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Test
2+
on:
3+
push:
4+
branches-ignore:
5+
- gh-pages
6+
- releases/**
7+
pull_request:
8+
branches-ignore:
9+
- gh-pages
10+
- releases/**
11+
types:
12+
- opened
13+
- synchronize
14+
- reopened
15+
permissions:
16+
contents: read
17+
env:
18+
CI: true
19+
20+
jobs:
21+
test:
22+
name: 'Test on Node.js ${{ matrix.node }} OS: ${{matrix.os}}'
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
matrix:
26+
os: [ubuntu-latest, windows-latest, macos-latest]
27+
node: [12, 14, 16]
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- name: Setup Node.js ${{ matrix.node }}
32+
uses: actions/setup-node@v2
33+
with:
34+
node-version: ${{ matrix.node }}
35+
cache: 'npm'
36+
- name: Install
37+
run: npm install
38+
- name: Test
39+
run: npm test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,7 @@ dist
103103
# TernJS port file
104104
.tern-port
105105

106+
# VSCode
107+
.vscode
108+
106109
dist

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist
2+
coverage
3+
tsconfig.json

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
semi: false
2+
singleQuote: true
3+
printWidth: 80
4+
trailingComma: "none"
5+
endOfLine: "auto"
6+
arrowParens: "avoid"

example/public/index.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7-
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
7+
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
88
<title><%= htmlWebpackPlugin.options.title %></title>
99
</head>
1010
<body>
1111
<noscript>
12-
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
12+
<strong
13+
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
14+
properly without JavaScript enabled. Please enable it to
15+
continue.</strong
16+
>
1317
</noscript>
1418
<div id="app"></div>
1519
<!-- built files will be auto injected -->

example/src/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ const i18n = createI18n({
1515
list: 'hello, {0}!',
1616
named: 'hello, {name}!',
1717
linked: '@:message.named How are you?',
18-
plural: 'no bananas | {n} banana | {n} bananas',
19-
},
18+
plural: 'no bananas | {n} banana | {n} bananas'
19+
}
2020
},
2121
ja: {
2222
message: {
2323
language: '日本語',
2424
list: 'こんにちは、{0}!',
2525
named: 'こんにちは、{name}!',
26-
linked: '@:message.named ごきげんいかが?',
27-
},
28-
},
29-
},
26+
linked: '@:message.named ごきげんいかが?'
27+
}
28+
}
29+
}
3030
})
3131

3232
const app = createApp({
3333
i18n,
34-
render: h => h(App),
34+
render: h => h(App)
3535
})
3636

3737
app.mount('#app')

jest.config.js

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
6+
module.exports = {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
// cacheDirectory: "/private/var/folders/0_/_d_95tmj7flf_jhbkp6xmgy80000gp/T/jest_dy",
15+
16+
// Automatically clear mock calls and instances between every test
17+
clearMocks: true,
18+
19+
// Indicates whether the coverage information should be collected while executing the test
20+
collectCoverage: true,
21+
22+
// An array of glob patterns indicating a set of files for which coverage information should be collected
23+
// collectCoverageFrom: undefined,
24+
25+
// The directory where Jest should output its coverage files
26+
coverageDirectory: 'coverage',
27+
28+
// An array of regexp pattern strings used to skip coverage collection
29+
// coveragePathIgnorePatterns: [
30+
// "/node_modules/"
31+
// ],
32+
coveragePathIgnorePatterns: ['/node_modules/', '<rootDir>/test/*.*'],
33+
34+
// Indicates which provider should be used to instrument code for coverage
35+
coverageProvider: 'v8',
36+
37+
// A list of reporter names that Jest uses when writing coverage reports
38+
// coverageReporters: [
39+
// "json",
40+
// "text",
41+
// "lcov",
42+
// "clover"
43+
// ],
44+
45+
// An object that configures minimum threshold enforcement for coverage results
46+
// coverageThreshold: undefined,
47+
48+
// A path to a custom dependency extractor
49+
// dependencyExtractor: undefined,
50+
51+
// Make calling deprecated APIs throw helpful error messages
52+
// errorOnDeprecated: false,
53+
54+
// Force coverage collection from ignored files using an array of glob patterns
55+
// forceCoverageMatch: [],
56+
57+
// A path to a module which exports an async function that is triggered once before all test suites
58+
// globalSetup: undefined,
59+
globals: {
60+
'ts-jest': {
61+
diagnostics: false,
62+
},
63+
},
64+
65+
// A path to a module which exports an async function that is triggered once after all test suites
66+
// globalTeardown: undefined,
67+
68+
// A set of global variables that need to be available in all test environments
69+
// globals: {},
70+
71+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
72+
// maxWorkers: "50%",
73+
74+
// An array of directory names to be searched recursively up from the requiring module's location
75+
// moduleDirectories: [
76+
// "node_modules"
77+
// ],
78+
79+
// An array of file extensions your modules use
80+
moduleFileExtensions: [
81+
"js",
82+
"jsx",
83+
"ts",
84+
"tsx",
85+
"json",
86+
"vue"
87+
],
88+
89+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
90+
// moduleNameMapper: {},
91+
92+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
93+
// modulePathIgnorePatterns: [],
94+
95+
// Activates notifications for test results
96+
// notify: false,
97+
98+
// An enum that specifies notification mode. Requires { notify: true }
99+
// notifyMode: "failure-change",
100+
101+
// A preset that is used as a base for Jest's configuration
102+
// preset: undefined,
103+
preset: 'ts-jest',
104+
105+
// Run tests from one or more projects
106+
// projects: undefined,
107+
108+
// Use this configuration option to add custom reporters to Jest
109+
// reporters: undefined,
110+
111+
// Automatically reset mock state between every test
112+
// resetMocks: false,
113+
114+
// Reset the module registry before running each individual test
115+
// resetModules: false,
116+
117+
// A path to a custom resolver
118+
// resolver: undefined,
119+
120+
// Automatically restore mock state between every test
121+
// restoreMocks: false,
122+
123+
// The root directory that Jest should scan for tests and modules within
124+
// rootDir: undefined,
125+
126+
// A list of paths to directories that Jest should use to search for files in
127+
// roots: [
128+
// "<rootDir>"
129+
// ],
130+
131+
// Allows you to use a custom runner instead of Jest's default test runner
132+
// runner: "jest-runner",
133+
134+
// The paths to modules that run some code to configure or set up the testing environment before each test
135+
// setupFiles: [],
136+
137+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
138+
// setupFilesAfterEnv: [],
139+
140+
// The number of seconds after which a test is considered as slow and reported as such in the results.
141+
// slowTestThreshold: 5,
142+
143+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
144+
// snapshotSerializers: [],
145+
146+
// The test environment that will be used for testing
147+
// testEnvironment: "jest-environment-node",
148+
testEnvironment: 'node',
149+
150+
// Options that will be passed to the testEnvironment
151+
// testEnvironmentOptions: {},
152+
153+
// Adds a location field to test results
154+
// testLocationInResults: false,
155+
156+
// The glob patterns Jest uses to detect test files
157+
// testMatch: [
158+
// "**/__tests__/**/*.[jt]s?(x)",
159+
// "**/?(*.)+(spec|test).[tj]s?(x)"
160+
// ],
161+
testMatch: ['<rootDir>/test/**/*(*.)@(spec|test).[tj]s?(x)'],
162+
163+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
164+
// testPathIgnorePatterns: [
165+
// "/node_modules/"
166+
// ],
167+
168+
// The regexp pattern or array of patterns that Jest uses to detect test files
169+
// testRegex: [],
170+
171+
// This option allows the use of a custom results processor
172+
// testResultsProcessor: undefined,
173+
174+
// This option allows use of a custom test runner
175+
// testRunner: "jest-circus/runner",
176+
177+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
178+
// testURL: "http://localhost",
179+
180+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
181+
// timers: "real",
182+
183+
// A map from regular expressions to paths to transformers
184+
// transform: undefined,
185+
transform: {
186+
// process `*.vue` files with `vue-jest`
187+
".*\\.(vue)$": "@vue/vue2-jest"
188+
},
189+
190+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
191+
// transformIgnorePatterns: [
192+
// "/node_modules/",
193+
// "\\.pnp\\.[^\\/]+$"
194+
// ],
195+
196+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
197+
// unmockedModulePathPatterns: undefined,
198+
199+
// Indicates whether each individual test should be reported during the run
200+
// verbose: undefined,
201+
202+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
203+
// watchPathIgnorePatterns: [],
204+
watchPathIgnorePatterns: ['/node_modules/', '/dist/', '/.git/'],
205+
206+
// Whether to use watchman for file crawling
207+
// watchman: true,
208+
}

0 commit comments

Comments
 (0)