├── .all-contributorsrc ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .flowconfig ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .travis.yml ├── __snapshots__ └── test.js.snap ├── flow-typed └── npm │ └── jest_v23.x.x.js ├── index.js ├── license ├── package.json ├── readme.md ├── test.js └── yarn.lock /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "babel-preset-zero", 3 | "projectOwner": "akameco", 4 | "files": [ 5 | "readme.md" 6 | ], 7 | "imageSize": 100, 8 | "commit": false, 9 | "contributors": [ 10 | { 11 | "login": "akameco", 12 | "name": "akameco", 13 | "avatar_url": "https://avatars2.githubusercontent.com/u/4002137?v=4", 14 | "profile": "http://akameco.github.io", 15 | "contributions": [ 16 | "code", 17 | "doc", 18 | "test", 19 | "infra" 20 | ] 21 | } 22 | ] 23 | } 24 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/coverage/** 2 | **/flow-typed/** 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["precure/oss"], 3 | "rules": { 4 | "unicorn/prevent-abbreviations": "off" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [lints] 8 | 9 | [options] 10 | 11 | [strict] 12 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.js text eol=lf 3 | *.lock binary 4 | package-lock.json binary 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | - version: 10 | - `node` version: 11 | - `npm` (or `yarn`) version: 12 | 13 | **Do you want to request a *feature* or report a *bug*?:** 14 | 15 | **What is the current behavior?:** 16 | 17 | **What is the expected behavior?:** 18 | 19 | **Suggested solution:** 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | **What**: 8 | 9 | 10 | 11 | **Why**: 12 | 13 | 14 | 15 | **How**: 16 | 17 | 18 | **Checklist**: 19 | 20 | 21 | * [ ] Documentation 22 | * [ ] Tests 23 | * [ ] Ready to be merged 24 | * [ ] Added myself to contributors table 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | flow-typed 2 | lib 3 | coverage 4 | .github 5 | package.json 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | semi: false 2 | singleQuote: true 3 | trailingComma: es5 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '10' 4 | - '8' 5 | 6 | cache: 7 | yarn: true 8 | directories: 9 | - ".eslintcache" 10 | - "node_modules" 11 | 12 | notifications: 13 | email: false 14 | 15 | script: 16 | - yarn run test:ci 17 | 18 | branches: 19 | only: master 20 | -------------------------------------------------------------------------------- /__snapshots__/test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`plugin snapshot class-properties: class-properties 1`] = ` 4 | "\\"use strict\\"; 5 | 6 | class A { 7 | constructor() { 8 | this.a = () => 'hello'; 9 | } 10 | 11 | }" 12 | `; 13 | 14 | exports[`plugin snapshot dead code: dead code 1`] = ` 15 | "\\"use strict\\"; 16 | 17 | function hoge() {}" 18 | `; 19 | 20 | exports[`plugin snapshot import: import 1`] = ` 21 | "\\"use strict\\"; 22 | 23 | var _react = _interopRequireDefault(require(\\"react\\")); 24 | 25 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }" 26 | `; 27 | 28 | exports[`plugin snapshot object reset spread: object reset spread 1`] = ` 29 | "\\"use strict\\"; 30 | 31 | const a = Object.assign({}, foo);" 32 | `; 33 | -------------------------------------------------------------------------------- /flow-typed/npm/jest_v23.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: ad251f3a3446f6ab4e6691a94e701cad 2 | // flow-typed version: caa120caaa/jest_v23.x.x/flow_>=v0.39.x 3 | 4 | type JestMockFn, TReturn> = { 5 | (...args: TArguments): TReturn, 6 | /** 7 | * An object for introspecting mock calls 8 | */ 9 | mock: { 10 | /** 11 | * An array that represents all calls that have been made into this mock 12 | * function. Each call is represented by an array of arguments that were 13 | * passed during the call. 14 | */ 15 | calls: Array, 16 | /** 17 | * An array that contains all the object instances that have been 18 | * instantiated from this mock function. 19 | */ 20 | instances: Array 21 | }, 22 | /** 23 | * Resets all information stored in the mockFn.mock.calls and 24 | * mockFn.mock.instances arrays. Often this is useful when you want to clean 25 | * up a mock's usage data between two assertions. 26 | */ 27 | mockClear(): void, 28 | /** 29 | * Resets all information stored in the mock. This is useful when you want to 30 | * completely restore a mock back to its initial state. 31 | */ 32 | mockReset(): void, 33 | /** 34 | * Removes the mock and restores the initial implementation. This is useful 35 | * when you want to mock functions in certain test cases and restore the 36 | * original implementation in others. Beware that mockFn.mockRestore only 37 | * works when mock was created with jest.spyOn. Thus you have to take care of 38 | * restoration yourself when manually assigning jest.fn(). 39 | */ 40 | mockRestore(): void, 41 | /** 42 | * Accepts a function that should be used as the implementation of the mock. 43 | * The mock itself will still record all calls that go into and instances 44 | * that come from itself -- the only difference is that the implementation 45 | * will also be executed when the mock is called. 46 | */ 47 | mockImplementation( 48 | fn: (...args: TArguments) => TReturn 49 | ): JestMockFn, 50 | /** 51 | * Accepts a function that will be used as an implementation of the mock for 52 | * one call to the mocked function. Can be chained so that multiple function 53 | * calls produce different results. 54 | */ 55 | mockImplementationOnce( 56 | fn: (...args: TArguments) => TReturn 57 | ): JestMockFn, 58 | /** 59 | * Accepts a string to use in test result output in place of "jest.fn()" to 60 | * indicate which mock function is being referenced. 61 | */ 62 | mockName(name: string): JestMockFn, 63 | /** 64 | * Just a simple sugar function for returning `this` 65 | */ 66 | mockReturnThis(): void, 67 | /** 68 | * Accepts a value that will be returned whenever the mock function is called. 69 | */ 70 | mockReturnValue(value: TReturn): JestMockFn, 71 | /** 72 | * Sugar for only returning a value once inside your mock 73 | */ 74 | mockReturnValueOnce(value: TReturn): JestMockFn, 75 | /** 76 | * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) 77 | */ 78 | mockResolvedValue(value: TReturn): JestMockFn>, 79 | /** 80 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) 81 | */ 82 | mockResolvedValueOnce(value: TReturn): JestMockFn>, 83 | /** 84 | * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) 85 | */ 86 | mockRejectedValue(value: TReturn): JestMockFn>, 87 | /** 88 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) 89 | */ 90 | mockRejectedValueOnce(value: TReturn): JestMockFn> 91 | }; 92 | 93 | type JestAsymmetricEqualityType = { 94 | /** 95 | * A custom Jasmine equality tester 96 | */ 97 | asymmetricMatch(value: mixed): boolean 98 | }; 99 | 100 | type JestCallsType = { 101 | allArgs(): mixed, 102 | all(): mixed, 103 | any(): boolean, 104 | count(): number, 105 | first(): mixed, 106 | mostRecent(): mixed, 107 | reset(): void 108 | }; 109 | 110 | type JestClockType = { 111 | install(): void, 112 | mockDate(date: Date): void, 113 | tick(milliseconds?: number): void, 114 | uninstall(): void 115 | }; 116 | 117 | type JestMatcherResult = { 118 | message?: string | (() => string), 119 | pass: boolean 120 | }; 121 | 122 | type JestMatcher = (actual: any, expected: any) => JestMatcherResult; 123 | 124 | type JestPromiseType = { 125 | /** 126 | * Use rejects to unwrap the reason of a rejected promise so any other 127 | * matcher can be chained. If the promise is fulfilled the assertion fails. 128 | */ 129 | rejects: JestExpectType, 130 | /** 131 | * Use resolves to unwrap the value of a fulfilled promise so any other 132 | * matcher can be chained. If the promise is rejected the assertion fails. 133 | */ 134 | resolves: JestExpectType 135 | }; 136 | 137 | /** 138 | * Jest allows functions and classes to be used as test names in test() and 139 | * describe() 140 | */ 141 | type JestTestName = string | Function; 142 | 143 | /** 144 | * Plugin: jest-styled-components 145 | */ 146 | 147 | type JestStyledComponentsMatcherValue = 148 | | string 149 | | JestAsymmetricEqualityType 150 | | RegExp 151 | | typeof undefined; 152 | 153 | type JestStyledComponentsMatcherOptions = { 154 | media?: string; 155 | modifier?: string; 156 | supports?: string; 157 | } 158 | 159 | type JestStyledComponentsMatchersType = { 160 | toHaveStyleRule( 161 | property: string, 162 | value: JestStyledComponentsMatcherValue, 163 | options?: JestStyledComponentsMatcherOptions 164 | ): void, 165 | }; 166 | 167 | /** 168 | * Plugin: jest-enzyme 169 | */ 170 | type EnzymeMatchersType = { 171 | toBeChecked(): void, 172 | toBeDisabled(): void, 173 | toBeEmpty(): void, 174 | toBeEmptyRender(): void, 175 | toBePresent(): void, 176 | toContainReact(element: React$Element): void, 177 | toExist(): void, 178 | toHaveClassName(className: string): void, 179 | toHaveHTML(html: string): void, 180 | toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), 181 | toHaveRef(refName: string): void, 182 | toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), 183 | toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), 184 | toHaveTagName(tagName: string): void, 185 | toHaveText(text: string): void, 186 | toIncludeText(text: string): void, 187 | toHaveValue(value: any): void, 188 | toMatchElement(element: React$Element): void, 189 | toMatchSelector(selector: string): void 190 | }; 191 | 192 | // DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers 193 | type DomTestingLibraryType = { 194 | toBeInTheDOM(): void, 195 | toHaveTextContent(content: string): void, 196 | toHaveAttribute(name: string, expectedValue?: string): void 197 | }; 198 | 199 | // Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers 200 | type JestJQueryMatchersType = { 201 | toExist(): void, 202 | toHaveLength(len: number): void, 203 | toHaveId(id: string): void, 204 | toHaveClass(className: string): void, 205 | toHaveTag(tag: string): void, 206 | toHaveAttr(key: string, val?: any): void, 207 | toHaveProp(key: string, val?: any): void, 208 | toHaveText(text: string | RegExp): void, 209 | toHaveData(key: string, val?: any): void, 210 | toHaveValue(val: any): void, 211 | toHaveCss(css: {[key: string]: any}): void, 212 | toBeChecked(): void, 213 | toBeDisabled(): void, 214 | toBeEmpty(): void, 215 | toBeHidden(): void, 216 | toBeSelected(): void, 217 | toBeVisible(): void, 218 | toBeFocused(): void, 219 | toBeInDom(): void, 220 | toBeMatchedBy(sel: string): void, 221 | toHaveDescendant(sel: string): void, 222 | toHaveDescendantWithText(sel: string, text: string | RegExp): void 223 | }; 224 | 225 | 226 | // Jest Extended Matchers: https://github.com/jest-community/jest-extended 227 | type JestExtendedMatchersType = { 228 | /** 229 | * Note: Currently unimplemented 230 | * Passing assertion 231 | * 232 | * @param {String} message 233 | */ 234 | // pass(message: string): void; 235 | 236 | /** 237 | * Note: Currently unimplemented 238 | * Failing assertion 239 | * 240 | * @param {String} message 241 | */ 242 | // fail(message: string): void; 243 | 244 | /** 245 | * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. 246 | */ 247 | toBeEmpty(): void; 248 | 249 | /** 250 | * Use .toBeOneOf when checking if a value is a member of a given Array. 251 | * @param {Array.<*>} members 252 | */ 253 | toBeOneOf(members: any[]): void; 254 | 255 | /** 256 | * Use `.toBeNil` when checking a value is `null` or `undefined`. 257 | */ 258 | toBeNil(): void; 259 | 260 | /** 261 | * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. 262 | * @param {Function} predicate 263 | */ 264 | toSatisfy(predicate: (n: any) => boolean): void; 265 | 266 | /** 267 | * Use `.toBeArray` when checking if a value is an `Array`. 268 | */ 269 | toBeArray(): void; 270 | 271 | /** 272 | * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. 273 | * @param {Number} x 274 | */ 275 | toBeArrayOfSize(x: number): void; 276 | 277 | /** 278 | * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. 279 | * @param {Array.<*>} members 280 | */ 281 | toIncludeAllMembers(members: any[]): void; 282 | 283 | /** 284 | * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. 285 | * @param {Array.<*>} members 286 | */ 287 | toIncludeAnyMembers(members: any[]): void; 288 | 289 | /** 290 | * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. 291 | * @param {Function} predicate 292 | */ 293 | toSatisfyAll(predicate: (n: any) => boolean): void; 294 | 295 | /** 296 | * Use `.toBeBoolean` when checking if a value is a `Boolean`. 297 | */ 298 | toBeBoolean(): void; 299 | 300 | /** 301 | * Use `.toBeTrue` when checking a value is equal (===) to `true`. 302 | */ 303 | toBeTrue(): void; 304 | 305 | /** 306 | * Use `.toBeFalse` when checking a value is equal (===) to `false`. 307 | */ 308 | toBeFalse(): void; 309 | 310 | /** 311 | * Use .toBeDate when checking if a value is a Date. 312 | */ 313 | toBeDate(): void; 314 | 315 | /** 316 | * Use `.toBeFunction` when checking if a value is a `Function`. 317 | */ 318 | toBeFunction(): void; 319 | 320 | /** 321 | * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. 322 | * 323 | * Note: Required Jest version >22 324 | * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same 325 | * 326 | * @param {Mock} mock 327 | */ 328 | toHaveBeenCalledBefore(mock: JestMockFn): void; 329 | 330 | /** 331 | * Use `.toBeNumber` when checking if a value is a `Number`. 332 | */ 333 | toBeNumber(): void; 334 | 335 | /** 336 | * Use `.toBeNaN` when checking a value is `NaN`. 337 | */ 338 | toBeNaN(): void; 339 | 340 | /** 341 | * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. 342 | */ 343 | toBeFinite(): void; 344 | 345 | /** 346 | * Use `.toBePositive` when checking if a value is a positive `Number`. 347 | */ 348 | toBePositive(): void; 349 | 350 | /** 351 | * Use `.toBeNegative` when checking if a value is a negative `Number`. 352 | */ 353 | toBeNegative(): void; 354 | 355 | /** 356 | * Use `.toBeEven` when checking if a value is an even `Number`. 357 | */ 358 | toBeEven(): void; 359 | 360 | /** 361 | * Use `.toBeOdd` when checking if a value is an odd `Number`. 362 | */ 363 | toBeOdd(): void; 364 | 365 | /** 366 | * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). 367 | * 368 | * @param {Number} start 369 | * @param {Number} end 370 | */ 371 | toBeWithin(start: number, end: number): void; 372 | 373 | /** 374 | * Use `.toBeObject` when checking if a value is an `Object`. 375 | */ 376 | toBeObject(): void; 377 | 378 | /** 379 | * Use `.toContainKey` when checking if an object contains the provided key. 380 | * 381 | * @param {String} key 382 | */ 383 | toContainKey(key: string): void; 384 | 385 | /** 386 | * Use `.toContainKeys` when checking if an object has all of the provided keys. 387 | * 388 | * @param {Array.} keys 389 | */ 390 | toContainKeys(keys: string[]): void; 391 | 392 | /** 393 | * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. 394 | * 395 | * @param {Array.} keys 396 | */ 397 | toContainAllKeys(keys: string[]): void; 398 | 399 | /** 400 | * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. 401 | * 402 | * @param {Array.} keys 403 | */ 404 | toContainAnyKeys(keys: string[]): void; 405 | 406 | /** 407 | * Use `.toContainValue` when checking if an object contains the provided value. 408 | * 409 | * @param {*} value 410 | */ 411 | toContainValue(value: any): void; 412 | 413 | /** 414 | * Use `.toContainValues` when checking if an object contains all of the provided values. 415 | * 416 | * @param {Array.<*>} values 417 | */ 418 | toContainValues(values: any[]): void; 419 | 420 | /** 421 | * Use `.toContainAllValues` when checking if an object only contains all of the provided values. 422 | * 423 | * @param {Array.<*>} values 424 | */ 425 | toContainAllValues(values: any[]): void; 426 | 427 | /** 428 | * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. 429 | * 430 | * @param {Array.<*>} values 431 | */ 432 | toContainAnyValues(values: any[]): void; 433 | 434 | /** 435 | * Use `.toContainEntry` when checking if an object contains the provided entry. 436 | * 437 | * @param {Array.} entry 438 | */ 439 | toContainEntry(entry: [string, string]): void; 440 | 441 | /** 442 | * Use `.toContainEntries` when checking if an object contains all of the provided entries. 443 | * 444 | * @param {Array.>} entries 445 | */ 446 | toContainEntries(entries: [string, string][]): void; 447 | 448 | /** 449 | * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. 450 | * 451 | * @param {Array.>} entries 452 | */ 453 | toContainAllEntries(entries: [string, string][]): void; 454 | 455 | /** 456 | * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. 457 | * 458 | * @param {Array.>} entries 459 | */ 460 | toContainAnyEntries(entries: [string, string][]): void; 461 | 462 | /** 463 | * Use `.toBeExtensible` when checking if an object is extensible. 464 | */ 465 | toBeExtensible(): void; 466 | 467 | /** 468 | * Use `.toBeFrozen` when checking if an object is frozen. 469 | */ 470 | toBeFrozen(): void; 471 | 472 | /** 473 | * Use `.toBeSealed` when checking if an object is sealed. 474 | */ 475 | toBeSealed(): void; 476 | 477 | /** 478 | * Use `.toBeString` when checking if a value is a `String`. 479 | */ 480 | toBeString(): void; 481 | 482 | /** 483 | * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. 484 | * 485 | * @param {String} string 486 | */ 487 | toEqualCaseInsensitive(string: string): void; 488 | 489 | /** 490 | * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. 491 | * 492 | * @param {String} prefix 493 | */ 494 | toStartWith(prefix: string): void; 495 | 496 | /** 497 | * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. 498 | * 499 | * @param {String} suffix 500 | */ 501 | toEndWith(suffix: string): void; 502 | 503 | /** 504 | * Use `.toInclude` when checking if a `String` includes the given `String` substring. 505 | * 506 | * @param {String} substring 507 | */ 508 | toInclude(substring: string): void; 509 | 510 | /** 511 | * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. 512 | * 513 | * @param {String} substring 514 | * @param {Number} times 515 | */ 516 | toIncludeRepeated(substring: string, times: number): void; 517 | 518 | /** 519 | * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. 520 | * 521 | * @param {Array.} substring 522 | */ 523 | toIncludeMultiple(substring: string[]): void; 524 | }; 525 | 526 | interface JestExpectType { 527 | not: 528 | & JestExpectType 529 | & EnzymeMatchersType 530 | & DomTestingLibraryType 531 | & JestJQueryMatchersType 532 | & JestStyledComponentsMatchersType 533 | & JestExtendedMatchersType, 534 | /** 535 | * If you have a mock function, you can use .lastCalledWith to test what 536 | * arguments it was last called with. 537 | */ 538 | lastCalledWith(...args: Array): void, 539 | /** 540 | * toBe just checks that a value is what you expect. It uses === to check 541 | * strict equality. 542 | */ 543 | toBe(value: any): void, 544 | /** 545 | * Use .toBeCalledWith to ensure that a mock function was called with 546 | * specific arguments. 547 | */ 548 | toBeCalledWith(...args: Array): void, 549 | /** 550 | * Using exact equality with floating point numbers is a bad idea. Rounding 551 | * means that intuitive things fail. 552 | */ 553 | toBeCloseTo(num: number, delta: any): void, 554 | /** 555 | * Use .toBeDefined to check that a variable is not undefined. 556 | */ 557 | toBeDefined(): void, 558 | /** 559 | * Use .toBeFalsy when you don't care what a value is, you just want to 560 | * ensure a value is false in a boolean context. 561 | */ 562 | toBeFalsy(): void, 563 | /** 564 | * To compare floating point numbers, you can use toBeGreaterThan. 565 | */ 566 | toBeGreaterThan(number: number): void, 567 | /** 568 | * To compare floating point numbers, you can use toBeGreaterThanOrEqual. 569 | */ 570 | toBeGreaterThanOrEqual(number: number): void, 571 | /** 572 | * To compare floating point numbers, you can use toBeLessThan. 573 | */ 574 | toBeLessThan(number: number): void, 575 | /** 576 | * To compare floating point numbers, you can use toBeLessThanOrEqual. 577 | */ 578 | toBeLessThanOrEqual(number: number): void, 579 | /** 580 | * Use .toBeInstanceOf(Class) to check that an object is an instance of a 581 | * class. 582 | */ 583 | toBeInstanceOf(cls: Class<*>): void, 584 | /** 585 | * .toBeNull() is the same as .toBe(null) but the error messages are a bit 586 | * nicer. 587 | */ 588 | toBeNull(): void, 589 | /** 590 | * Use .toBeTruthy when you don't care what a value is, you just want to 591 | * ensure a value is true in a boolean context. 592 | */ 593 | toBeTruthy(): void, 594 | /** 595 | * Use .toBeUndefined to check that a variable is undefined. 596 | */ 597 | toBeUndefined(): void, 598 | /** 599 | * Use .toContain when you want to check that an item is in a list. For 600 | * testing the items in the list, this uses ===, a strict equality check. 601 | */ 602 | toContain(item: any): void, 603 | /** 604 | * Use .toContainEqual when you want to check that an item is in a list. For 605 | * testing the items in the list, this matcher recursively checks the 606 | * equality of all fields, rather than checking for object identity. 607 | */ 608 | toContainEqual(item: any): void, 609 | /** 610 | * Use .toEqual when you want to check that two objects have the same value. 611 | * This matcher recursively checks the equality of all fields, rather than 612 | * checking for object identity. 613 | */ 614 | toEqual(value: any): void, 615 | /** 616 | * Use .toHaveBeenCalled to ensure that a mock function got called. 617 | */ 618 | toHaveBeenCalled(): void, 619 | toBeCalled(): void; 620 | /** 621 | * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact 622 | * number of times. 623 | */ 624 | toHaveBeenCalledTimes(number: number): void, 625 | toBeCalledTimes(number: number): void; 626 | /** 627 | * 628 | */ 629 | toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; 630 | nthCalledWith(nthCall: number, ...args: Array): void; 631 | /** 632 | * 633 | */ 634 | toHaveReturned(): void; 635 | toReturn(): void; 636 | /** 637 | * 638 | */ 639 | toHaveReturnedTimes(number: number): void; 640 | toReturnTimes(number: number): void; 641 | /** 642 | * 643 | */ 644 | toHaveReturnedWith(value: any): void; 645 | toReturnWith(value: any): void; 646 | /** 647 | * 648 | */ 649 | toHaveLastReturnedWith(value: any): void; 650 | lastReturnedWith(value: any): void; 651 | /** 652 | * 653 | */ 654 | toHaveNthReturnedWith(nthCall: number, value: any): void; 655 | nthReturnedWith(nthCall: number, value: any): void; 656 | /** 657 | * Use .toHaveBeenCalledWith to ensure that a mock function was called with 658 | * specific arguments. 659 | */ 660 | toHaveBeenCalledWith(...args: Array): void, 661 | toBeCalledWith(...args: Array): void, 662 | /** 663 | * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called 664 | * with specific arguments. 665 | */ 666 | toHaveBeenLastCalledWith(...args: Array): void, 667 | lastCalledWith(...args: Array): void, 668 | /** 669 | * Check that an object has a .length property and it is set to a certain 670 | * numeric value. 671 | */ 672 | toHaveLength(number: number): void, 673 | /** 674 | * 675 | */ 676 | toHaveProperty(propPath: string, value?: any): void, 677 | /** 678 | * Use .toMatch to check that a string matches a regular expression or string. 679 | */ 680 | toMatch(regexpOrString: RegExp | string): void, 681 | /** 682 | * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. 683 | */ 684 | toMatchObject(object: Object | Array): void, 685 | /** 686 | * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. 687 | */ 688 | toStrictEqual(value: any): void, 689 | /** 690 | * This ensures that an Object matches the most recent snapshot. 691 | */ 692 | toMatchSnapshot(propertyMatchers?: {[key: string]: JestAsymmetricEqualityType}, name?: string): void, 693 | /** 694 | * This ensures that an Object matches the most recent snapshot. 695 | */ 696 | toMatchSnapshot(name: string): void, 697 | /** 698 | * Use .toThrow to test that a function throws when it is called. 699 | * If you want to test that a specific error gets thrown, you can provide an 700 | * argument to toThrow. The argument can be a string for the error message, 701 | * a class for the error, or a regex that should match the error. 702 | * 703 | * Alias: .toThrowError 704 | */ 705 | toThrow(message?: string | Error | Class | RegExp): void, 706 | toThrowError(message?: string | Error | Class | RegExp): void, 707 | /** 708 | * Use .toThrowErrorMatchingSnapshot to test that a function throws a error 709 | * matching the most recent snapshot when it is called. 710 | */ 711 | toThrowErrorMatchingSnapshot(): void 712 | } 713 | 714 | type JestObjectType = { 715 | /** 716 | * Disables automatic mocking in the module loader. 717 | * 718 | * After this method is called, all `require()`s will return the real 719 | * versions of each module (rather than a mocked version). 720 | */ 721 | disableAutomock(): JestObjectType, 722 | /** 723 | * An un-hoisted version of disableAutomock 724 | */ 725 | autoMockOff(): JestObjectType, 726 | /** 727 | * Enables automatic mocking in the module loader. 728 | */ 729 | enableAutomock(): JestObjectType, 730 | /** 731 | * An un-hoisted version of enableAutomock 732 | */ 733 | autoMockOn(): JestObjectType, 734 | /** 735 | * Clears the mock.calls and mock.instances properties of all mocks. 736 | * Equivalent to calling .mockClear() on every mocked function. 737 | */ 738 | clearAllMocks(): JestObjectType, 739 | /** 740 | * Resets the state of all mocks. Equivalent to calling .mockReset() on every 741 | * mocked function. 742 | */ 743 | resetAllMocks(): JestObjectType, 744 | /** 745 | * Restores all mocks back to their original value. 746 | */ 747 | restoreAllMocks(): JestObjectType, 748 | /** 749 | * Removes any pending timers from the timer system. 750 | */ 751 | clearAllTimers(): void, 752 | /** 753 | * The same as `mock` but not moved to the top of the expectation by 754 | * babel-jest. 755 | */ 756 | doMock(moduleName: string, moduleFactory?: any): JestObjectType, 757 | /** 758 | * The same as `unmock` but not moved to the top of the expectation by 759 | * babel-jest. 760 | */ 761 | dontMock(moduleName: string): JestObjectType, 762 | /** 763 | * Returns a new, unused mock function. Optionally takes a mock 764 | * implementation. 765 | */ 766 | fn, TReturn>( 767 | implementation?: (...args: TArguments) => TReturn 768 | ): JestMockFn, 769 | /** 770 | * Determines if the given function is a mocked function. 771 | */ 772 | isMockFunction(fn: Function): boolean, 773 | /** 774 | * Given the name of a module, use the automatic mocking system to generate a 775 | * mocked version of the module for you. 776 | */ 777 | genMockFromModule(moduleName: string): any, 778 | /** 779 | * Mocks a module with an auto-mocked version when it is being required. 780 | * 781 | * The second argument can be used to specify an explicit module factory that 782 | * is being run instead of using Jest's automocking feature. 783 | * 784 | * The third argument can be used to create virtual mocks -- mocks of modules 785 | * that don't exist anywhere in the system. 786 | */ 787 | mock( 788 | moduleName: string, 789 | moduleFactory?: any, 790 | options?: Object 791 | ): JestObjectType, 792 | /** 793 | * Returns the actual module instead of a mock, bypassing all checks on 794 | * whether the module should receive a mock implementation or not. 795 | */ 796 | requireActual(moduleName: string): any, 797 | /** 798 | * Returns a mock module instead of the actual module, bypassing all checks 799 | * on whether the module should be required normally or not. 800 | */ 801 | requireMock(moduleName: string): any, 802 | /** 803 | * Resets the module registry - the cache of all required modules. This is 804 | * useful to isolate modules where local state might conflict between tests. 805 | */ 806 | resetModules(): JestObjectType, 807 | /** 808 | * Exhausts the micro-task queue (usually interfaced in node via 809 | * process.nextTick). 810 | */ 811 | runAllTicks(): void, 812 | /** 813 | * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), 814 | * setInterval(), and setImmediate()). 815 | */ 816 | runAllTimers(): void, 817 | /** 818 | * Exhausts all tasks queued by setImmediate(). 819 | */ 820 | runAllImmediates(): void, 821 | /** 822 | * Executes only the macro task queue (i.e. all tasks queued by setTimeout() 823 | * or setInterval() and setImmediate()). 824 | */ 825 | advanceTimersByTime(msToRun: number): void, 826 | /** 827 | * Executes only the macro task queue (i.e. all tasks queued by setTimeout() 828 | * or setInterval() and setImmediate()). 829 | * 830 | * Renamed to `advanceTimersByTime`. 831 | */ 832 | runTimersToTime(msToRun: number): void, 833 | /** 834 | * Executes only the macro-tasks that are currently pending (i.e., only the 835 | * tasks that have been queued by setTimeout() or setInterval() up to this 836 | * point) 837 | */ 838 | runOnlyPendingTimers(): void, 839 | /** 840 | * Explicitly supplies the mock object that the module system should return 841 | * for the specified module. Note: It is recommended to use jest.mock() 842 | * instead. 843 | */ 844 | setMock(moduleName: string, moduleExports: any): JestObjectType, 845 | /** 846 | * Indicates that the module system should never return a mocked version of 847 | * the specified module from require() (e.g. that it should always return the 848 | * real module). 849 | */ 850 | unmock(moduleName: string): JestObjectType, 851 | /** 852 | * Instructs Jest to use fake versions of the standard timer functions 853 | * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, 854 | * setImmediate and clearImmediate). 855 | */ 856 | useFakeTimers(): JestObjectType, 857 | /** 858 | * Instructs Jest to use the real versions of the standard timer functions. 859 | */ 860 | useRealTimers(): JestObjectType, 861 | /** 862 | * Creates a mock function similar to jest.fn but also tracks calls to 863 | * object[methodName]. 864 | */ 865 | spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, 866 | /** 867 | * Set the default timeout interval for tests and before/after hooks in milliseconds. 868 | * Note: The default timeout interval is 5 seconds if this method is not called. 869 | */ 870 | setTimeout(timeout: number): JestObjectType 871 | }; 872 | 873 | type JestSpyType = { 874 | calls: JestCallsType 875 | }; 876 | 877 | /** Runs this function after every test inside this context */ 878 | declare function afterEach( 879 | fn: (done: () => void) => ?Promise, 880 | timeout?: number 881 | ): void; 882 | /** Runs this function before every test inside this context */ 883 | declare function beforeEach( 884 | fn: (done: () => void) => ?Promise, 885 | timeout?: number 886 | ): void; 887 | /** Runs this function after all tests have finished inside this context */ 888 | declare function afterAll( 889 | fn: (done: () => void) => ?Promise, 890 | timeout?: number 891 | ): void; 892 | /** Runs this function before any tests have started inside this context */ 893 | declare function beforeAll( 894 | fn: (done: () => void) => ?Promise, 895 | timeout?: number 896 | ): void; 897 | 898 | /** A context for grouping tests together */ 899 | declare var describe: { 900 | /** 901 | * Creates a block that groups together several related tests in one "test suite" 902 | */ 903 | (name: JestTestName, fn: () => void): void, 904 | 905 | /** 906 | * Only run this describe block 907 | */ 908 | only(name: JestTestName, fn: () => void): void, 909 | 910 | /** 911 | * Skip running this describe block 912 | */ 913 | skip(name: JestTestName, fn: () => void): void 914 | }; 915 | 916 | /** An individual test unit */ 917 | declare var it: { 918 | /** 919 | * An individual test unit 920 | * 921 | * @param {JestTestName} Name of Test 922 | * @param {Function} Test 923 | * @param {number} Timeout for the test, in milliseconds. 924 | */ 925 | ( 926 | name: JestTestName, 927 | fn?: (done: () => void) => ?Promise, 928 | timeout?: number 929 | ): void, 930 | /** 931 | * each runs this test against array of argument arrays per each run 932 | * 933 | * @param {table} table of Test 934 | */ 935 | each( 936 | table: Array> 937 | ): ( 938 | name: JestTestName, 939 | fn?: (...args: Array) => ?Promise 940 | ) => void, 941 | /** 942 | * Only run this test 943 | * 944 | * @param {JestTestName} Name of Test 945 | * @param {Function} Test 946 | * @param {number} Timeout for the test, in milliseconds. 947 | */ 948 | only( 949 | name: JestTestName, 950 | fn?: (done: () => void) => ?Promise, 951 | timeout?: number 952 | ): { 953 | each( 954 | table: Array> 955 | ): ( 956 | name: JestTestName, 957 | fn?: (...args: Array) => ?Promise 958 | ) => void, 959 | }, 960 | /** 961 | * Skip running this test 962 | * 963 | * @param {JestTestName} Name of Test 964 | * @param {Function} Test 965 | * @param {number} Timeout for the test, in milliseconds. 966 | */ 967 | skip( 968 | name: JestTestName, 969 | fn?: (done: () => void) => ?Promise, 970 | timeout?: number 971 | ): void, 972 | /** 973 | * Run the test concurrently 974 | * 975 | * @param {JestTestName} Name of Test 976 | * @param {Function} Test 977 | * @param {number} Timeout for the test, in milliseconds. 978 | */ 979 | concurrent( 980 | name: JestTestName, 981 | fn?: (done: () => void) => ?Promise, 982 | timeout?: number 983 | ): void 984 | }; 985 | declare function fit( 986 | name: JestTestName, 987 | fn: (done: () => void) => ?Promise, 988 | timeout?: number 989 | ): void; 990 | /** An individual test unit */ 991 | declare var test: typeof it; 992 | /** A disabled group of tests */ 993 | declare var xdescribe: typeof describe; 994 | /** A focused group of tests */ 995 | declare var fdescribe: typeof describe; 996 | /** A disabled individual test */ 997 | declare var xit: typeof it; 998 | /** A disabled individual test */ 999 | declare var xtest: typeof it; 1000 | 1001 | type JestPrettyFormatColors = { 1002 | comment: { close: string, open: string }, 1003 | content: { close: string, open: string }, 1004 | prop: { close: string, open: string }, 1005 | tag: { close: string, open: string }, 1006 | value: { close: string, open: string }, 1007 | }; 1008 | 1009 | type JestPrettyFormatIndent = string => string; 1010 | type JestPrettyFormatRefs = Array; 1011 | type JestPrettyFormatPrint = any => string; 1012 | type JestPrettyFormatStringOrNull = string | null; 1013 | 1014 | type JestPrettyFormatOptions = {| 1015 | callToJSON: boolean, 1016 | edgeSpacing: string, 1017 | escapeRegex: boolean, 1018 | highlight: boolean, 1019 | indent: number, 1020 | maxDepth: number, 1021 | min: boolean, 1022 | plugins: JestPrettyFormatPlugins, 1023 | printFunctionName: boolean, 1024 | spacing: string, 1025 | theme: {| 1026 | comment: string, 1027 | content: string, 1028 | prop: string, 1029 | tag: string, 1030 | value: string, 1031 | |}, 1032 | |}; 1033 | 1034 | type JestPrettyFormatPlugin = { 1035 | print: ( 1036 | val: any, 1037 | serialize: JestPrettyFormatPrint, 1038 | indent: JestPrettyFormatIndent, 1039 | opts: JestPrettyFormatOptions, 1040 | colors: JestPrettyFormatColors, 1041 | ) => string, 1042 | test: any => boolean, 1043 | }; 1044 | 1045 | type JestPrettyFormatPlugins = Array; 1046 | 1047 | /** The expect function is used every time you want to test a value */ 1048 | declare var expect: { 1049 | /** The object that you want to make assertions against */ 1050 | (value: any): 1051 | & JestExpectType 1052 | & JestPromiseType 1053 | & EnzymeMatchersType 1054 | & DomTestingLibraryType 1055 | & JestJQueryMatchersType 1056 | & JestStyledComponentsMatchersType 1057 | & JestExtendedMatchersType, 1058 | 1059 | /** Add additional Jasmine matchers to Jest's roster */ 1060 | extend(matchers: { [name: string]: JestMatcher }): void, 1061 | /** Add a module that formats application-specific data structures. */ 1062 | addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, 1063 | assertions(expectedAssertions: number): void, 1064 | hasAssertions(): void, 1065 | any(value: mixed): JestAsymmetricEqualityType, 1066 | anything(): any, 1067 | arrayContaining(value: Array): Array, 1068 | objectContaining(value: Object): Object, 1069 | /** Matches any received string that contains the exact expected string. */ 1070 | stringContaining(value: string): string, 1071 | stringMatching(value: string | RegExp): string, 1072 | not: { 1073 | arrayContaining: (value: $ReadOnlyArray) => Array, 1074 | objectContaining: (value: {}) => Object, 1075 | stringContaining: (value: string) => string, 1076 | stringMatching: (value: string | RegExp) => string, 1077 | }, 1078 | }; 1079 | 1080 | // TODO handle return type 1081 | // http://jasmine.github.io/2.4/introduction.html#section-Spies 1082 | declare function spyOn(value: mixed, method: string): Object; 1083 | 1084 | /** Holds all functions related to manipulating test runner */ 1085 | declare var jest: JestObjectType; 1086 | 1087 | /** 1088 | * The global Jasmine object, this is generally not exposed as the public API, 1089 | * using features inside here could break in later versions of Jest. 1090 | */ 1091 | declare var jasmine: { 1092 | DEFAULT_TIMEOUT_INTERVAL: number, 1093 | any(value: mixed): JestAsymmetricEqualityType, 1094 | anything(): any, 1095 | arrayContaining(value: Array): Array, 1096 | clock(): JestClockType, 1097 | createSpy(name: string): JestSpyType, 1098 | createSpyObj( 1099 | baseName: string, 1100 | methodNames: Array 1101 | ): { [methodName: string]: JestSpyType }, 1102 | objectContaining(value: Object): Object, 1103 | stringMatching(value: string): string 1104 | }; 1105 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 'use strict' 3 | const { hasAnyDep } = require('ptils') 4 | 5 | const isTest = (process.env.BABEL_ENV || process.env.NODE_ENV) === 'test' 6 | 7 | const envTargets = isTest ? { node: 'current' } : { node: '6' } 8 | 9 | module.exports = () => ({ 10 | presets: [ 11 | [ 12 | require.resolve('@babel/preset-env'), 13 | { targets: envTargets, loose: true, modules: false }, 14 | ], 15 | hasAnyDep('flow-bin') && require.resolve('@babel/preset-flow'), 16 | hasAnyDep('typescript') && require.resolve('@babel/preset-typescript'), 17 | hasAnyDep('react') && require.resolve('@babel/preset-react'), 18 | ].filter(Boolean), 19 | plugins: [ 20 | require.resolve('babel-plugin-macros'), 21 | [ 22 | require.resolve('@babel/plugin-proposal-class-properties'), 23 | { loose: true }, 24 | ], 25 | [ 26 | require.resolve('@babel/plugin-proposal-object-rest-spread'), 27 | { loose: true, useBuiltIns: true }, 28 | ], 29 | require.resolve('babel-plugin-minify-dead-code-elimination'), 30 | require.resolve('@babel/plugin-transform-modules-commonjs'), 31 | ], 32 | }) 33 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) akameco (akameco.github.io) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-zero", 3 | "version": "0.7.0", 4 | "description": "babelrc for zero config", 5 | "license": "MIT", 6 | "repository": "akameco/babel-preset-zero", 7 | "author": "akameco (akameco.github.io)", 8 | "engines": { 9 | "node": ">=6" 10 | }, 11 | "scripts": { 12 | "add-contributor": "all-contributors add", 13 | "fmt": "prettier --write '**/*.{js,json,md}'", 14 | "flow": "flow", 15 | "lint": "eslint .", 16 | "test": "jest", 17 | "test:cov": "jest --coverage --ci --runInBand", 18 | "test:ci": "yarn flow && yarn lint && yarn test:cov" 19 | }, 20 | "lint-staged": { 21 | "*.{js,json,md}": [ 22 | "prettier --write", 23 | "git add" 24 | ] 25 | }, 26 | "files": [ 27 | "index.js" 28 | ], 29 | "keywords": [ 30 | "babel", 31 | "babelrc", 32 | "babel-preset" 33 | ], 34 | "dependencies": { 35 | "@babel/plugin-proposal-class-properties": "7.5.5", 36 | "@babel/plugin-proposal-object-rest-spread": "7.5.5", 37 | "@babel/plugin-transform-modules-commonjs": "7.5.0", 38 | "@babel/preset-env": "7.5.5", 39 | "@babel/preset-flow": "7.0.0", 40 | "@babel/preset-react": "7.0.0", 41 | "@babel/preset-typescript": "7.3.3", 42 | "babel-plugin-macros": "2.6.1", 43 | "babel-plugin-minify-dead-code-elimination": "0.5.1", 44 | "ptils": "0.3.0" 45 | }, 46 | "devDependencies": { 47 | "@babel/core": "7.5.5", 48 | "all-contributors-cli": "6.8.1", 49 | "eslint": "6.2.2", 50 | "eslint-config-precure": "4.18.1", 51 | "flow-bin": "0.106.1", 52 | "husky": "3.0.4", 53 | "jest": "24.9.0", 54 | "jest-in-case": "1.0.2", 55 | "lint-staged": "9.2.3", 56 | "prettier": "1.18.2" 57 | }, 58 | "husky": { 59 | "hooks": { 60 | "pre-commit": "yarn flow && lint-staged" 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # babel-preset-zero 2 | 3 | [![Build Status](https://travis-ci.org/akameco/babel-preset-zero.svg?branch=master)](https://travis-ci.org/akameco/babel-preset-zero) 4 | [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest) 5 | [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) 6 | [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) 7 | 8 | > babelrc for zero config 9 | 10 | ## Support 11 | 12 | - **FlowType** 13 | - **TypeScript** 14 | - **React** 15 | 16 | ## Install 17 | 18 | ``` 19 | $ yarn add --dev babel-preset-zero 20 | ``` 21 | 22 | ## Usage 23 | 24 | ```js 25 | { 26 | "presets": ["zero"] 27 | } 28 | ``` 29 | 30 | ### Presets 31 | 32 | - [@babel/preset-env](https://github.com/babel/babel-preset-env) 33 | - [@babel/preset-flow](https://github.com/babel/babel/tree/master/packages/babel-preset-flow) (if flow-bin exist) 34 | - [@babel/preset-react](https://github.com/babel/babel/tree/master/packages/babel-preset-react) (if react exist) 35 | - [@babel/preset-typescript](https://github.com/babel/babel/tree/master/packages/babel-preset-typescript) (if typescript exist) 36 | 37 | ### Plugins 38 | 39 | - [@babel/plugin-transform-class-properties](https://github.com/babel/babel) 40 | - [babel-plugin-minify-dead-code-elimination](https://github.com/babel/minify/tree/master/packages/babel-plugin-minify-dead-code-elimination) 41 | - [babel-macros](https://github.com/kentcdodds/babel-macros) 42 | 43 | ## Contributors 44 | 45 | Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)): 46 | 47 | 48 | 49 | | [
akameco](http://akameco.github.io)
[💻](https://github.com/akameco/babel-preset-zero/commits?author=akameco "Code") [📖](https://github.com/akameco/babel-preset-zero/commits?author=akameco "Documentation") [⚠️](https://github.com/akameco/babel-preset-zero/commits?author=akameco "Tests") [🚇](#infra-akameco "Infrastructure (Hosting, Build-Tools, etc)") | 50 | | :---: | 51 | 52 | 53 | 54 | This project follows the [all-contributors](https://github.com/kentcdodds/all-contributors) specification. Contributions of any kind welcome! 55 | 56 | ## License 57 | 58 | MIT © [akameco](http://akameco.github.io) 59 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | const cases = require('jest-in-case') 4 | const { transform } = require('@babel/core') 5 | 6 | jest.mock('ptils', () => ({ 7 | hasAnyDep: jest.fn(() => false), 8 | })) 9 | 10 | function snapshot(name, input) { 11 | const { code } = transform(input, { 12 | presets: [require.resolve('.')], 13 | }) 14 | expect(code).toMatchSnapshot(name) 15 | } 16 | 17 | cases( 18 | 'plugin snapshot', 19 | ({ name, input }) => { 20 | snapshot(name, input) 21 | }, 22 | [ 23 | { name: 'object reset spread', input: 'const a = {...foo}' }, 24 | { 25 | name: 'class-properties', 26 | input: ` 27 | class A { a = () => 'hello' } 28 | `, 29 | }, 30 | { 31 | name: 'dead code', 32 | input: ` 33 | function hoge() {var x = 1;} 34 | `, 35 | }, 36 | { 37 | name: 'import', 38 | input: ` 39 | import React from 'react'; 40 | `, 41 | }, 42 | ] 43 | ) 44 | 45 | // cases( 46 | // 'presets snapshot', 47 | // ({ name, input }) => { 48 | // snapshot(name, input) 49 | // }, 50 | // [ 51 | // { 52 | // name: 'flowtype', 53 | // input: ` 54 | // // @flow 55 | // type A = string 56 | // const a: A = 'hello'`, 57 | // }, 58 | // { 59 | // name: 'react', 60 | // input: ` 61 | // const A = () =>
hello
62 | // `, 63 | // }, 64 | // ] 65 | // ) 66 | --------------------------------------------------------------------------------