Skip to content

Commit

Permalink
license: add FB License header to all extractErrors code
Browse files Browse the repository at this point in the history
- this plugin is largely borrowed from the React monorepo, consistently
  add FB's License headers to each file, not just to extractErrors.ts

- also add comments pointing to the exact file and commit that each
  file was copied from
  - most of these are slightly out of date now:
    - evalToString is missing a line
    - extractErrors needs to be updated to Babel 7
      - babylon -> @babel/parser, babel-traverse -> @babel/traverse
    - transformErrorMessages has several new constructs added :/...
      - keeping a pseudo-fork up-to-date is pretty tedious and not very
        maintainble (it's also broken per the tests I've added)
        - would be better if we could ask FB to split out theirs as a
          separate package...
  • Loading branch information
agilgur5 committed Sep 21, 2020
1 parent 7edf7ea commit 2caad24
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/errors/evalToString.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// largely borrowed from https://github.com/facebook/react/blob/8b2d3783e58d1acea53428a10d2035a8399060fe/scripts/shared/evalToString.js
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export function evalToString(ast: any): string {
switch (ast.type) {
case 'StringLiteral':
Expand Down
1 change: 1 addition & 0 deletions src/errors/extractErrors.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// largely borrowed from https://github.com/facebook/react/blob/8b2d3783e58d1acea53428a10d2035a8399060fe/scripts/error-codes/extract-errors.js
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
Expand Down
9 changes: 9 additions & 0 deletions src/errors/invertObject.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// largely borrowed from https://github.com/facebook/react/blob/8b2d3783e58d1acea53428a10d2035a8399060fe/scripts/error-codes/invertObject.js

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/**
* turns
* { 'MUCH ERROR': '0', 'SUCH WRONG': '1' }
Expand Down
8 changes: 8 additions & 0 deletions src/errors/transformErrorMessages.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// largely borrowed from https://github.com/facebook/react/blob/2c8832075b05009bd261df02171bf9888ac76350/scripts/error-codes/transform-error-messages.js
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import fs from 'fs';
import { invertObject } from './invertObject';
import { evalToString } from './evalToString';
Expand Down

0 comments on commit 2caad24

Please sign in to comment.