Skip to content
This repository was archived by the owner on Sep 12, 2023. It is now read-only.

Commit d009510

Browse files
committed
setup dev basic env
1 parent a303e52 commit d009510

File tree

9 files changed

+3482
-47
lines changed

9 files changed

+3482
-47
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
./lib
2+
./jest.config.js
3+
./test/fixtures

.eslintrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict'
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
node: true,
7+
jest: true
8+
},
9+
extends: [
10+
'plugin:vue-libs/recommended'
11+
],
12+
plugins: [
13+
'@typescript-eslint'
14+
],
15+
parser: 'vue-eslint-parser',
16+
parserOptions: {
17+
parser: '@typescript-eslint/parser',
18+
sourceType: 'module'
19+
},
20+
rules: {
21+
'no-unused-vars': 'off', // HACK: due to override with @typescript-eslint/no-unused-vars
22+
'@typescript-eslint/no-unused-vars': [2, { 'vars': 'all', 'args': 'none' }]
23+
}
24+
}

jest.config.js

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

package.json

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,21 @@
2424
}
2525
},
2626
"devDependencies": {
27+
"@types/jest": "^24.0.25",
28+
"@types/node": "^13.1.4",
29+
"@typescript-eslint/eslint-plugin": "^2.14.0",
30+
"@typescript-eslint/parser": "^2.14.0",
31+
"@typescript-eslint/typescript-estree": "^2.14.0",
32+
"eslint": "^6.8.0",
33+
"eslint-plugin-vue-libs": "^4.0.0",
34+
"jest": "^24.9.0",
35+
"jest-watch-typeahead": "^0.4.2",
2736
"lerna-changelog": "^1.0.0",
28-
"shipjs": "0.13.1"
37+
"opener": "^1.5.1",
38+
"shipjs": "0.13.1",
39+
"ts-jest": "^24.2.0",
40+
"typescript": "^3.7.4",
41+
"typescript-eslint-language-service": "^2.0.3"
2942
},
3043
"engines": {
3144
"node": ">= 10"
@@ -39,16 +52,22 @@
3952
"vue-i18n"
4053
],
4154
"license": "MIT",
42-
"main": "index.js",
55+
"main": "lib/index.js",
4356
"repository": {
4457
"type": "git",
4558
"url": "git+https://github.com/intlify/rollup-plugin-vue-i18n.git"
4659
},
4760
"scripts": {
48-
"build": "echo 'build!'",
49-
"lint": "echo 'lint!'",
61+
"build": "tsc -p .",
62+
"build:watch": "tsc -p . --watch",
63+
"clean": "rm -rf ./coverage",
64+
"coverage": "opener coverage/lcov-report/index.html",
65+
"lint": "eslint ./src ./test --ext .ts",
5066
"release:prepare": "shipjs prepare",
5167
"release:trigger": "shipjs trigger",
52-
"test": "echo 'test!'"
68+
"test": "npm run lint && npm run test:cover",
69+
"test:cover": "npm run test:unit -- --coverage",
70+
"test:unit": "jest --env node",
71+
"test:watch": "jest --env node --watch"
5372
}
5473
}

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function (a: number, b: number) {
2+
return a + b
3+
}

test/index.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import add from '../src/index'
2+
3+
test('add', () => {
4+
expect(add(1, 1)).toBe(2)
5+
})

tsconfig.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"compilerOptions": {
3+
/* Basic Options */
4+
// "incremental": true, /* Enable incremental compilation */
5+
"target": "es2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
6+
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
7+
// "lib": [], /* Specify library files to be included in the compilation. */
8+
// "allowJs": true, /* Allow javascript files to be compiled. */
9+
// "checkJs": true, /* Report errors in .js files. */
10+
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
11+
// "declaration": true, /* Generates corresponding '.d.ts' file. */
12+
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
13+
// "sourceMap": true, /* Generates corresponding '.map' file. */
14+
// "outFile": "./", /* Concatenate and emit output to single file. */
15+
"outDir": "./lib", /* Redirect output structure to the directory. */
16+
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
17+
// "composite": true, /* Enable project compilation */
18+
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
19+
// "removeComments": true, /* Do not emit comments to output. */
20+
// "noEmit": true, /* Do not emit outputs. */
21+
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
22+
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
23+
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
24+
25+
/* Strict Type-Checking Options */
26+
"strict": true, /* Enable all strict type-checking options. */
27+
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
28+
// "strictNullChecks": true, /* Enable strict null checks. */
29+
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
30+
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
31+
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
32+
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
33+
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
34+
35+
/* Additional Checks */
36+
// "noUnusedLocals": true, /* Report errors on unused locals. */
37+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
38+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
39+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
40+
41+
/* Module Resolution Options */
42+
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
43+
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
44+
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
45+
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
46+
/* List of folders to include type definitions from. */
47+
// "typeRoots": [
48+
// "node_modules/@types",
49+
// ],
50+
// "types": [], /* Type declaration files to be included in compilation. */
51+
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
52+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
53+
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
54+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
55+
"resolveJsonModule": true
56+
57+
/* Source Map Options */
58+
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
59+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60+
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61+
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
62+
63+
/* Experimental Options */
64+
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65+
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
66+
},
67+
"include": [
68+
"src"
69+
],
70+
"plugins": [
71+
{
72+
"name": "typescript-eslint-language-service"
73+
}
74+
]
75+
}

0 commit comments

Comments
 (0)