profile
viewpoint

gkz/grasp 1253

JavaScript structural search, replace, and refactor

gkz/es-collections 57

An ES6/ES2015 (JavaScript) collections library including Stack, Queue, and PriorityQueue

gkz/coffee2ls 30

Compile CoffeeScript to LiveScript, based on CoffeeScriptRedux

audreyt/js2ls.org 20

Online JavaScript to LiveScript converter.

gkz/coffee2ls-codegen 10

LiveScript code generator

gkz/brunch-bare-livescript 8

barebones skeleton for brunch (brunch.io) with LiveScript (http://livescript.net)

gkz/grasp-squery 7

A query engine for Grasp - use CSS style selectors to query your JavaScript AST

gkz/domdocs 6

next-gen DOM documentation for developers

gkz/grasp-equery 4

A query engine for Grasp - use JavaScript code examples with wildcards

created tagfacebook/jscodeshift

tag0.10.0

A JavaScript codemod toolkit.

created time in 3 days

push eventfacebook/jscodeshift

George Zahariev

commit sha d918bc95537e5f0bf5167d0f09d6b3dd4be83b2b

0.10.0

view details

push time in 3 days

push eventfacebook/jscodeshift

George Zahariev

commit sha 587ac3ac66e4ff0f4970e80001310e499e482f07

retroactively update changelog for 0.8.0

view details

push time in 3 days

issue closedfacebook/flow

flat/flatMap not available

There is currently no open issue describing the lack of flatMap.

As this is a stage 3 proposal, it should be supported by Flow.

closed time in 4 days

gajus

issue commentfacebook/flow

flat/flatMap not available

I added support for common patterns (that are possible to type) for .flat:

https://flow.org/try/#0MYewdgzgLgBGCuBbCAuGBBATpghgTwB4FEAjAU0wD4YBeGAbXoEYBdAGgYCZ2GBmFlgDoAZgBscUABQBKANxA

gajus

comment created time in 4 days

issue closedfacebook/flow

Type constraint in generic type parameters of an async arrow function causes parser error

<!-- Please fill out this entire template so that we can address your bug report as quickly as possible.

Any bug reports that don't contain instructions to reproduce the issue will be closed. -->

Flow version: 105.1

Expected behavior

const fn = async <S: string>(_: S) => _

Should not give errors.

Actual behavior

Flow errors with

1: const fn = async <S: string>(_: S) => _
                      ^ Unexpected token `:`, expected the start of a statement

<!-- Please reproduce your issue on flow.org/try so that we can debug it.

Not all issues are reproducible on try-flow because they may require multiple files or specific flowconfig settings. If your bug can only be reproduced under one of these constraints, please make a small github repo that contains a minimal way to reproduce your problem. -->

  • Link to Try-Flow or Github repo: https://flow.org/try/#0MYewdgzgLgBAZmGBeGBDCBPMwYB4DKAXDNAE4CWYA5gHwAUA+sfgJTI0wNA

Flow does not give error if either async or the constraint is removed, or the function is changed from an arrow function to a "regular" async function expression/statement.

const noError1 = <S: string>(_: S) => Promise.resolve(_)  // ok
const noError2 = async <S>(_: S) => _  // ok
const noError3 = async function<S: string>(_: S) { return _ }  // ok

closed time in 5 days

noppa

issue commentfacebook/flow

Block-level /*flow-disable*/ and /*flow-enable*/

I don't understand why you would want to disable typing for a block of code.

agentcooper

comment created time in 5 days

issue commentfacebook/flow

Block-level /*flow-disable*/ and /*flow-enable*/

but for blocks of code where flow errors should be suppressed.

But what are the use-cases for this?

agentcooper

comment created time in 5 days

issue commentfacebook/flow

String is not a valid ComponentType

OK, so what you want is something which accepts a component with specific props, not just arbitrary props, because you need to be able to pass some type of props to it (e.g. href to either the Link or the a.

I don't think there is a way to express that for intrinsic elements (like a), but what you can do is create a simple component to encapsulate their usage, e.g. (props: {href: string}) => <a href={props.href} />, and you can do something like this:

https://flow.org/try/#0PTAEAEDMBsHsHcBQBLAtgB1gJwC6gFSgCGAzqAEoCmRAxnpFrKqAERbV0sDcivOAnukqgACo3QkAPABUAfKAC8oAN6JQoGk0wA7StpwAuChxwA6AMJbYu-dMGVJygBbtIRkjizJtAcwC+sgA0iH486oiQAK7adMjWoABCkTg41jJGyqZZAQAUypoY1nqGoOZ+RmKwEjKyAJQqaqDsOJFY2qCS5qAulJAKLD6wsD7QlKYFLKDAsjyhvEkp1qYAJr1EkdA4lRKKDeoFOsVGOejiJBk9bqAeXr5+9QrykkTdrgrKp1Ukppd+U0EhHi8TTaDygAAeu0kC1S7WmXCmYFWkHWmzIqVAAHIiJjQDgiD5ECCwfwoTD4gcivp3gAZbwAaz+8N4EWisXidO09Lyvwurncnm8-lqRiotDMAFlkODKMsAKKjVDFPZNSgtNodZbIABusgAykxhCiYqToAyNFYbHh4MgcE5iKAzVy8bAVL9JMAtbrZkA

danielo515

comment created time in 5 days

issue commentfacebook/flow

Block-level /*flow-disable*/ and /*flow-enable*/

Everyone giving a +1 or thumbs up, please give an actual example and use-case. I may be able to point you to alternative solutions.

For example for OP's example of using define, this should be done by a transform or your packager?

agentcooper

comment created time in 5 days

issue commentfacebook/flow

Replace React.PropTypes with Flow types

I still have some errors with flow. I'm currently using functional-component and type checking does not effect prop uses. In the component, i get error but when i try to use my component and pass wrong types, it doesn't give me any error. How can i fix it?

Make a new issue with a reproduction of your issue on https://flow.org/try/

danvk

comment created time in 6 days

issue commentfacebook/flow

String is not a valid ComponentType

It doesn't make sense to pass in a component, because by doing <C /> you are passing in a specific set of props (no props), which makes it not possible to ignore what props a component requires.

You should just pass in an element: https://flow.org/try/#0PTAEAEDMBsHsHcBQBLAtgB1gJwC6gFSgCGAzqAEoCmRAxnpFrKqAERbV0sDcivOAnukqgACo3RkAvKADeiUKErRKqSgDscALgoccAOgCyyAB6UAJgFFlqjYgC+80Ihqw1JPACFoRUNIAUMkoq6lqKoHbaYrASAJS+AHyKvF5EemaUkEQArtA4URK+so5BNqEAPGbIAG6gwPEANPa8Lm54xoVlKbXxQA

danielo515

comment created time in 6 days

issue closedfacebook/flow

Object property union

<!-- Please fill out this entire template so that we can address your bug report as quickly as possible.

Any bug reports that don't contain instructions to reproduce the issue will be closed. -->

/* @flow */

type ExportList = {
  [key: string]: boolean,
};
type Serialize = {
  [key: string]: string | boolean | number,
};

const ser = (obj: Serialize) => {}
const test:ExportList = {"yo": true}
ser(test)

Flow version: Flow, a static type checker for JavaScript, version 0.117.0

Expected behavior

Expected to not throw any error.

Actual behavior

It seems like union does not work in my example. It throws two errors.

<!-- Please reproduce your issue on flow.org/try so that we can debug it.

Not all issues are reproducible on try-flow because they may require multiple files or specific flowconfig settings. If your bug can only be reproduced under one of these constraints, please make a small github repo that contains a minimal way to reproduce your problem. -->

  • Link to Try-Flow or Github repo: Demo

closed time in 6 days

gabrielmicko

issue commentfacebook/flow

Object property union

That's because the object can be written to. You need to mark it as read only: https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAodAXAngBwKZgCiAHjnAE4YAyAlgM4ZgC8YA3qmGANoDWeWALjANyNAHYBzALpCARnDgw8AQzEAaVAF8A3Kmz4wAZTyjlMGgC8CLdpwDUvfkJHjpchUtVgAPmDEBXAFtZEx9hDFFJDR10AGM4MQZhUJYACjhZACshY1NzKwBKZgA+Nk04hKSMPAYBEjJKWiSbACIsOBahCP88cvQ6E1TqhgKgA

Otherwise the function ser could do:

obj['foo'] = 1;

which is obviously not valid for ExportList

gabrielmicko

comment created time in 6 days

issue commentfacebook/flow

Typings about WebRTC

Is the lack of such obvious types as WebRTC ones for several years the sign that flow project is being abandoned?

No, it means no one has put up a PR for them (and no one has requested these internally). We regularly merge PRs which add new library definitions.

leader22

comment created time in 9 days

push eventfacebook/jscodeshift

George Zahariev

commit sha d18f6a535bf2561ac34580045f5ffd0fc5384901

Update to latest flow parser, enable enums parsing

view details

push time in a month

push eventfacebook/jscodeshift

George Zahariev

commit sha 48355d9935060ea725689108ec96d6bd44bee8ee

Don't unnecessarily break things for older versions of node

view details

push time in a month

issue closedfacebook/flow

Duplicated comments in JSX

Flow version: 0.123.0

<Example />; // a
<Example />; // b

Expected behavior

There should be 2 comments in the AST.

Actual behavior

3 comments in the AST. // a is duplicated.

  • Link to Try-Flow or Github repo: https://github.com/prettier/prettier/pull/8071, Try-Flow

closed time in a month

thorn0

PR closed facebook/jscodeshift

[ci skip] Get more Open Source Helpers CLA Signed

CodeTriage is an app I have maintained for the past 4-5 years with the goal of getting people involved in Open Source projects like this one. The app sends subscribers a random open issue for them to help "triage". For some languages you can also suggested areas to add documentation.

The initial approach was inspired by seeing the work of the small core team spending countless hours asking "what version was this in" and "can you give us an example app". The idea is to outsource these small interactions to a huge team of volunteers and let the core team focus on their work.

I want to add a badge to the README of this project. The idea is to provide an easy link for people to get started contributing to this project. A badge indicates the number of people currently subscribed to help the repo. The color is based off of open issues in the project.

Here are some examples of other projects that have a badge in their README:

  • https://github.com/crystal-lang/crystal
  • https://github.com/rails/rails
  • https://github.com/codetriage/codetriage

Thanks for building open source software, I would love to help you find some helpers.

+1 -1

2 comments

1 changed file

schneems

pr closed time in a month

push eventfacebook/jscodeshift

Mickael Zhang

commit sha 62f288885d066cb967257f92424d4fabcbaf0119

rename any to isMatch

view details

George Zahariev

commit sha d7631b4525a98c9010199494033d2daf190ccbed

Merge pull request #371 from mickaelzhang/update-mm-method Rename micromatch any to isMatch

view details

push time in a month

PR merged facebook/jscodeshift

Rename micromatch any to isMatch CLA Signed

I was checking jscodeshift and micromatch source code and saw that .any is there for backward compat, and they renamed it to .isMatch

https://github.com/micromatch/micromatch/blob/fe4858b0c63b174fd3ae22674db39119b8fa4392/index.js#L126

+1 -1

0 comment

1 changed file

mickaelzhang

pr closed time in a month

issue closedgkz/LiveScript

Bitwise "xor" is ditched

The JavaScript operator ^ has got another, unrelated meaning.

JavaScript:

0x10 ^ 0x1A // 10

LiveScript:

0x10 ^ 0x1A // 2.028240960365167e+31

I have three problems with this.

  1. Obviously, this is quite confusing.
  2. ^ is an alias for another operator (**) and is not necessary (and there is Math.pow() too).
  3. We are left without bitwise xor.

closed time in a month

punund

issue commentgkz/LiveScript

Bitwise "xor" is ditched

Lookup "Bitwise and shift operators" under http://livescript.net/#operators

0x10 .^. 0x1A
punund

comment created time in a month

issue closedgkz/LiveScript

Incorrect if JavaScript depending on context

When compiling the code x = (if foo! then bar(that) or baz(that)) (that is, relying on if-let to locally bind result of the first subexpression), the resulting JavaScript looks like this:

x = (that = foo()) ? bar(that) || baz(that) : void 8;

Which works pretty straightforwardly, as one would expect. If, however, you pass the same exact expression to, say, while loop, the output will have different structure:

while (if foo! then bar(that) or baz(that))
  console.log 42
while ((that = foo()) && bar(that) || baz(that)) {
  console.log(42);
}

Which deviates from expected behaviour, because now baz will be executed even when that is falsey (due to JavaScript operator precedence). It is possible to reproduce structure from the first example in second case, but only by providing an explicit else branch:

while (if foo! then bar(that) or baz(that) else void)
  console.log 42
while ((that = foo()) ? bar(that) || baz(that) : void 8) {
  console.log(42);
}

closed time in a month

LeXofLeviafan

push eventgkz/LiveScript

Ryan Hendrickson

commit sha b8a8667815630e7206256e1716c82290bf68622d

fix gkz/LiveScript#1098 Most of the time, the precedence difference between `&&` and `||` doesn't need to be attended, because it's the same in LiveScript and JavaScript. But when synthetic `&&` nodes are created, it's important to ensure that the children of the node either must have had higher precedence when parsed, are also synthetic and represent expressions with higher precedence, or are wrapped in `Parens`. The reported bug, and a similar issue with the binary `?` operator, are the consequences if not.

view details

George Zahariev

commit sha f68805fe74c5c1630af13606065bd16199705a78

Merge pull request #1099 from rhendric/fix/LiveScript-1098 fix gkz/LiveScript#1098

view details

push time in a month

PR merged gkz/LiveScript

fix gkz/LiveScript#1098

Most of the time, the precedence difference between && and || doesn't need to be attended, because it's the same in LiveScript and JavaScript. But when synthetic && nodes are created, it's important to ensure that the children of the node either must have had higher precedence when parsed, are also synthetic and represent expressions with higher precedence, or are wrapped in Parens. The reported bug, and a similar issue with the binary ? operator, are the consequences if not.


As a simple bug fix, I will hold this PR open for one week, merging on or after Apr 27 if there are no comments, unless @gkz gets to it first again! :grin:

+16 -4

0 comment

4 changed files

rhendric

pr closed time in a month

push eventgkz/LiveScript

Ryan Hendrickson

commit sha a379b03731a50bec4dfcefd423a3df9baefbed80

fix gkz/LiveScript#1096 The minor code optimization of omitting parentheses around a single destructuring assignment is incorrect when the assignment is produced inside a binary expression, as the binary operator interferes with the parsing of the assignment's LHS in the generated JS. This change restricts the optimization to cases where the current precedence level is lower than that of binary operators. Since the number of expressions includes a final expression that captures the original RHS of the destructuring assignment if that value is needed, and since the optimization is always applied to top-level and parenthesis-level expressions by the second half of the if condition, this change only has an effect on single-assignment destructuring assignments that are direct children of a list or conditional expression, where the value of the destructuring assignment expression is not used (which rules out lists and most conditionals as well). #1096 illustrates one of the only ways such a circumstance is likely to arise in natural code.

view details

George Zahariev

commit sha d36873e08ba85f6d5f54734b1082a015e7fb4d49

Merge pull request #1097 from rhendric/fix/LiveScript-1096 fix gkz/LiveScript#1096

view details

push time in a month

issue closedgkz/LiveScript

Destructuring optional object in array produces invalid javascript

The code ([{foo}?]) -> produces following output:

(function(arg$){
  var ref$, foo;
  (ref$ = arg$[0]) != null && foo = ref$.foo;
});

Which fails to evaluate because of && before assignment.

At the same time, ([{foo, bar}?]) -> doesn't fail, because resulting output is taken in parens:

(function(arg$){
  var ref$, foo, bar;
  (ref$ = arg$[0]) != null && (foo = ref$.foo, bar = ref$.bar);
});

More to the point, optional object with alternative (([{foo}={}]) ->) doesn't fail either, because there's no right-side assignment:

(function(arg$){
  var ref$, foo;
  foo = ((ref$ = arg$[0]) != null
    ? ref$
    : {}).foo;
});

And adding more fields (([{foo, bar}={}]) ->) results in a comma chain, as usual:

(function(arg$){
  var ref$, foo, bar;
  ref$ = (ref$ = arg$[0]) != null
    ? ref$
    : {}, foo = ref$.foo, bar = ref$.bar;
});

closed time in a month

LeXofLeviafan

issue commentfacebook/flow

Duplicated comments in JSX

Should be fixed in the next version

thorn0

comment created time in 2 months

issue closedfacebook/flow

Feature Request: Utility function to get the values of an array (similar $Values for Objects)

At the moment, flow provides a useful$Values<> type for getting the type of the keys of an Object. Could we also get a utility that gives us the values of an Array, or extend the $Values<> type to support Arrays instead of only Objects.

The specific use case I'm after is something like this:

const list = ['a', 'b', 'c'];

const myFunc = function (key: $Values<typeof list>) => {
   console.log(key);
}

// This should be allowed
myFunc('a');
myFunc('b');
myFunc('c');

// This should throw an error because the given argument isn't one of the elements in my Array
myFunc('d');
myFunc('e');
myFunc(0);

closed time in 2 months

EvHaus
IssuesEvent

issue commentfacebook/flow

Feature Request: Utility function to get the values of an array (similar $Values for Objects)

type ArrayValues<TArr> = $Call<<T>(Array<T>) => T, TArr>;

https://flow.org/try/#0MYewdgzgLgBAHhAXDAggJzQQwJ4B5poCWYA5gHwwC8MA2gOQAWhdANDHQEbYCmdAugG4AUEKjYADt1QYcANUwAbAK7cIuACro0FagBIAwooW4NZABRacpgJRUK6tpoxlhZgERw3yS9nnLVuGKSIABm8BBk1gIwAPQxMADyANJshFB0EDAABgTEJFlCZgCM3jK+iipqQdyh4ZHRcTAAogBKLQktbGBKALYc3GgwhJnEoD3imFCEHApSAO5pDDC5pEA

EvHaus

comment created time in 2 months

issue closedfacebook/flow

Feature Request: Utility function to get the values of an array (similar $Values for Objects)

At the moment, flow provides a useful$Values<> type for getting the type of the keys of an Object. Could we also get a utility that gives us the values of an Array, or extend the $Values<> type to support Arrays instead of only Objects.

The specific use case I'm after is something like this:

const list = ['a', 'b', 'c'];

const myFunc = function (key: $Values<typeof list>) => {
   console.log(key);
}

// This should be allowed
myFunc('a');
myFunc('b');
myFunc('c');

// This should throw an error because the given argument isn't one of the elements in my Array
myFunc('d');
myFunc('e');
myFunc(0);

closed time in 2 months

EvHaus

Pull request review commenteslint/eslint

Upgrade: levn@0.4.1 (fixes #9366)

 describe("Linter", () => {     });      describe("when evaluating code with comments which have colon in its value", () => {-        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-\"}] */\nalert('test');";+        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\\\s*require\\\\s*\\\\(|^\\\\s*loader\\\\.lazy|-\\\\*-\"}] */\nalert('test');";          it("should not parse errors, should report a violation", () => {             const messages = linter.verify(code, {}, filename);              assert.strictEqual(messages.length, 1);             assert.strictEqual(messages[0].ruleId, "max-len");-            assert.strictEqual(messages[0].message, "This line has a length of 122. Maximum allowed is 100.");+            assert.strictEqual(messages[0].message, "This line has a length of 128. Maximum allowed is 100.");+            assert.include(messages[0].nodeType, "Program");+        });+    });++    describe("when evaluating code with comments that contain escape sequences", () => {+        const code = '/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\\\(" }] */\nconsole.log("test");\nvar a = "test2";';

You should add a test case like consoleXlog("test"); and make sure it does not fire if it's anything but a dot.

I'm saying is that what you actually want is an escaped backslash \, so you want \\ (under String.raw conditions). In JS console type "console\.log", you will see that the output is console.log. You get this right later on when you ensure there is an escaped backlash before the ( by doing \\(, so that it is escaped in the regex

kaicataldo

comment created time in 2 months

Pull request review commenteslint/eslint

Upgrade: levn@0.4.1 (fixes #9366)

 describe("Linter", () => {     });      describe("when evaluating code with comments which have colon in its value", () => {-        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-\"}] */\nalert('test');";+        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\\\s*require\\\\s*\\\\(|^\\\\s*loader\\\\.lazy|-\\\\*-\"}] */\nalert('test');";          it("should not parse errors, should report a violation", () => {             const messages = linter.verify(code, {}, filename);              assert.strictEqual(messages.length, 1);             assert.strictEqual(messages[0].ruleId, "max-len");-            assert.strictEqual(messages[0].message, "This line has a length of 122. Maximum allowed is 100.");+            assert.strictEqual(messages[0].message, "This line has a length of 128. Maximum allowed is 100.");+            assert.include(messages[0].nodeType, "Program");+        });+    });++    describe("when evaluating code with comments that contain escape sequences", () => {+        const code = '/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\\\(" }] */\nconsole.log("test");\nvar a = "test2";';

When you switch to using String.raw this will become more clear

kaicataldo

comment created time in 2 months

Pull request review commenteslint/eslint

Upgrade: levn@0.4.1 (fixes #9366)

 describe("Linter", () => {     });      describe("when evaluating code with comments which have colon in its value", () => {-        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\s*require\\s*\\(|^\\s*loader\\.lazy|-\\*-\"}] */\nalert('test');";+        const code = "/* eslint max-len: [2, 100, 2, {ignoreUrls: true, ignorePattern: \"data:image\\/|\\\\s*require\\\\s*\\\\(|^\\\\s*loader\\\\.lazy|-\\\\*-\"}] */\nalert('test');";          it("should not parse errors, should report a violation", () => {             const messages = linter.verify(code, {}, filename);              assert.strictEqual(messages.length, 1);             assert.strictEqual(messages[0].ruleId, "max-len");-            assert.strictEqual(messages[0].message, "This line has a length of 122. Maximum allowed is 100.");+            assert.strictEqual(messages[0].message, "This line has a length of 128. Maximum allowed is 100.");+            assert.include(messages[0].nodeType, "Program");+        });+    });++    describe("when evaluating code with comments that contain escape sequences", () => {+        const code = '/* eslint max-len: ["error", 1, { ignoreComments: true, ignorePattern: "console\\.log\\\\(" }] */\nconsole.log("test");\nvar a = "test2";';

I don't think the "...console\\.log..." does anything, since this is console\.log, when when passed through levn is just console.log

kaicataldo

comment created time in 2 months

pull request commenteslint/eslint

Upgrade: levn@0.4.1 (fixes #9366)

You should also update optionator to 0.9.1 - it uses levn internally, and this will keep the versions of levn used by your option parsing and comments in sync

kaicataldo

comment created time in 2 months

fork gkz/eslint

Find and fix problems in your JavaScript code.

https://eslint.org

fork in 2 months

created taggkz/optionator

tag0.9.1

JavaScript option parsing and help generation library

created time in 2 months

push eventgkz/optionator

George Zahariev

commit sha 1fd04d6749892326150ac3dcb564b0511fbc010e

0.9.1

view details

push time in 2 months

push eventgkz/optionator

George Zahariev

commit sha b102661f113d731661e2554f5e6675fde0117313

update levn dep

view details

George Zahariev

commit sha 165f6c10c982a53229e3f9e559a36aea36aad151

update package lock

view details

push time in 2 months

created taggkz/levn

tag0.4.1

Light ECMAScript (JavaScript) Value Notation - human written, concise, typed, flexible

created time in 2 months

push eventgkz/levn

George Zahariev

commit sha eb1040d2ec21bc3655ee140f38eb880adcd77134

0.4.1

view details

push time in 2 months

issue closedgkz/levn

Possible typo in src/cast.ls?

Hi, first of all, just want to say thanks for working on a fix for #2! Really appreciate it, and this is going to help the ESLint project.

I happened to read through the diff, and I'm wondering if there is a typo that could cause problems in the latest release. There is a token "repalce", which I assume would be "replace". See below link to review in context.

https://github.com/gkz/levn/blob/0c5f341936715f9dc4be60c7141ec5eb0769f536/src/cast.ls#L64

If I'm totally wrong, then I apologize for wasting your time. Please feel free to close the issue if that is the case.

closed time in 2 months

platinumazure

issue commentgkz/levn

Possible typo in src/cast.ls?

Thanks

platinumazure

comment created time in 2 months

push eventgkz/levn

George Zahariev

commit sha 8ae622f9e68cdf64fb5afa17ff9f5bff08b7793b

fix typo

view details

push time in 2 months

created taggkz/optionator

tag0.9.0

JavaScript option parsing and help generation library

created time in 2 months

push eventgkz/optionator

George Zahariev

commit sha b6fef87a008a0119fa385600e7bfe16c2e578999

0.9.0

view details

push time in 2 months

push eventgkz/optionator

George Zahariev

commit sha 7654f0cea239bdd6517a51a4ac550ff474423d4a

update range used in package.json

view details

push time in 2 months

push eventgkz/optionator

George Zahariev

commit sha 2bb29e5f7af952441f4a6c35bdb4022e82182330

update deps

view details

push time in 2 months

issue closedgkz/optionator

Project status?

Abandoned? Planning to return to it?

closed time in 2 months

stevenvachon

issue commentgkz/optionator

Project status?

If it works it works, I don't see why the number maters.

stevenvachon

comment created time in 2 months

created taggkz/levn

tag0.4.0

Light ECMAScript (JavaScript) Value Notation - human written, concise, typed, flexible

created time in 2 months

push eventgkz/levn

George Zahariev

commit sha 0c5f341936715f9dc4be60c7141ec5eb0769f536

0.4.0

view details

push time in 2 months

push eventgkz/levn

George Zahariev

commit sha 66069a3f74a7fa0534660205d2621d453abf7c45

Fix string escape issue Fixes #2

view details

push time in 2 months

issue closedgkz/levn

Escape sequences in quoted string literals are handled unintuitively

It makes sense for non-quoted strings to be treated as literally as possible. However, quoted string literals (which have their quotes stripped) should probably be treated as close to normal JavaScript strings as possible, so that data read by levn could also be compatible with JSON or other interchange formats.

const assert = require("assert");
const levn = require("levn");

const result1 = levn.parse("String", `\r\n`);
assert.equal(result1, "\\r\\n");  // Passes

const result2 = levn.parse("String", `"\r\n"`);
assert.equal(result2, "\r\n");  // Fails

Put another way, it seems to be impossible to parse a string in levn so that the resulting string has escape sequence characters such as \n.


This is causing some weird behavior in ESLint when parsing inline configuration comments. This example is kind of involved, so please bear with me.

  1. A user can specify a regular expression (as a string) for the ESLint rule to use to ignore certain lines of code:

    /* eslint max-len: ["error", 80, { ignorePattern: "require\\(" }] */
    
  2. If ESLint parses this file, it's supposed to activate the max-len rule and use the string as a regex pattern.

  3. When this pattern is used in an ESLint configuration file, it works as expected and looks for lines with "require(" in them.

  4. When we use levn to handle the inline configuration comment, the backslashes are doubled, so as to be treated literally. This results in a regex /require\\(/, which results in a SyntaxError because of the unmatched capturing parentheses.

So what I'm proposing is, if a string literal is quoted, it should only escape the backslashes if they don't make a sensible escape (i.e., the same way JavaScript handles string literals). I think unquoted string literals could still be handled with all backslashes treated literally.

Not sure if this should be considered a bug or a breaking change.

closed time in 2 months

platinumazure

push eventgkz/levn

George Zahariev

commit sha f6d6d56aff3ae1bee9a14e622c44e1b7d2993c5a

update deps, travis.yml, build

view details

push time in 2 months

push eventgkz/type-check

George Zahariev

commit sha c0e2222c96efd51765a870156c8441b52a8964ea

0.4.0

view details

push time in 2 months

created taggkz/type-check

tag0.4.0

a library which allows you to check the types of JavaScript values at runtime with a Haskell like type syntax

created time in 2 months

push eventgkz/type-check

George Zahariev

commit sha 4bc2a0e02e3201b831a6e09182bbc6ec42014b86

0.4.0

view details

push time in 2 months

push eventgkz/type-check

George Zahariev

commit sha 6a2c33cf5bd5f74ca4c57f49413d9247c1658ab6

Fix issue with multiple complex structures in union Fixes #11 Fixes #10

view details

George Zahariev

commit sha 47da1d9edb57114eea0f139119cfc1da1c3c0480

Use null check for custom types, build

view details

push time in 2 months

issue closedgkz/type-check

OR operator between complex types in array fails

It should be possible to do this:

typeCheck('[(Number) | (String)]', [[1], ['test'], [2]])

and

typeCheck('[[Number] | [String]]', [[1, 2], ['foo', 'bar'], [3]])

But it doesn't work, neither of them

closed time in 2 months

whitelizard

issue closedgkz/type-check

object check fails when using OR

typeCheck('[Object]', [{}]); // true

typeCheck('String | [String] | [Object]', [{}]); // false

Obviously the second result is wrong.

This lib so simple to use, shame its not maintained ATM. If you dont have time to work on these issues maybe you could seek maintainers to help you. Its a great lib. Thanks

closed time in 2 months

danday74

push eventgkz/type-check

George Zahariev

commit sha b518bbc1e6e2a758a73e1575a15f616d73a52532

Fix nested use of type-check and custom types Fixes #5

view details

push time in 2 months

issue closedgkz/type-check

Using more than one custom type on the same object fails

Hi there,

I was trying to create a type definition where I'd have two custom types being used on two separate properties of an object.

Essentially, something like: '{prop1: CustomType1, prop2: CustomType2}'

However, this seems to fail in a very weird way if my custom type reuses type-check itself to validate something.

But it doesn't fail if there is only one custom type being used. I created 2 isolated test cases to demonstrate. The first one doesn't fail, but the second one does. Also, the inner assert inside the validation method is passing, so the inner use of typeCheck is working properly.

var typeCheck = require('type-check').typeCheck
var assert = require('assert')

// asserts to true
assert(typeCheck('{prop1: CustomType1, prop2: String}', {
  prop1: {
    subprop1: 'str1'
  },
  prop2: 'str2'
}, {
  customTypes: {
    CustomType1: {
      typeOf: 'Object',
      validate: function (x) {
        var firstcheck = typeCheck('String', x.subprop1)
        assert(firstcheck, 'first check')
        return firstcheck
      }
    }
  }
}))

// asserts to false
assert(typeCheck('{prop1: CustomType1, prop2: CustomType2}', {
  prop1: {
    subprop1: 'str1'
  },
  prop2: {
    subprop2: 'str2'
  }
}, {
  customTypes: {
    CustomType1: {
      typeOf: 'Object',
      validate: function (x) {
        var firstcheck = typeCheck('String', x.subprop1)
        assert(firstcheck, 'first check')
        return firstcheck
      }
    },
    CustomType2: {
      typeOf: 'Object',
      validate: function (x) {
        var secondcheck = typeCheck('String', x.subprop2)
        assert(secondcheck, 'second check')
        return secondcheck
      }
    }
  }
}))

I tried debugging this and stepping into the code of the library but couldn't really figure out where and why it fails.

closed time in 2 months

trodrigues

issue closedgkz/type-check

String index signature

How would I test a js object that contains an index signature like this?:

{ "categories": { "Travel": { "category": "Travel", "index": 2.2, "subCategories": [{ "category": "Travel Guides & Travelogues", "index": 2.1 }, { "category": "Hotels & Transportation", "index": 1.4 }] }, "Shopping": { "category": "Shopping", "index": 1.6, "subCategories": [{ "category": "Apparel", "index": 1.5 }, { "category": "Discount & Outlet Stores", "index": 1.3 }] }, "Food & Drink": { "category": "Food & Drink", "index": 14.6, "subCategories": [{ "category": "Restaurants", "index": 3.9 }, { "category": "Cooking & Recipes", "index": 46.7 }] } } }

My typescript definition for this is fairly simple : interface Interests { categories : Categories; }

interface Categories {

}

interface Category { category : string; index : number; subCategories :Subcategory[]; }

interface Subcategory { category :string ; index : number; }

But I am trying to verify this at run time. So I tried to come up with the type-check call, but I can't seem to get it right... My last try was along these lines:

var thePayload = JSON.parse(... the above content...);

typeCheck( '{categories: Object[
{category : String,
index : Number,
subCategories : [
{category :String ,
index : Number,...
}
]
}]
}', thePayload)

Hope you have a moment to look at this... thanks in advance.

closed time in 2 months

hansrwindhoff

push eventgkz/type-check

George Zahariev

commit sha 4a15065e516837f1ad418af1d8baa31fe2c8d2b3

use latest livescript version in preroll script

view details

George Zahariev

commit sha 33976cc906a31c5ee86e2280e66e9e210083e6ab

Make 'type-of' optional for custom types Closes #2

view details

push time in 2 months

issue closedgkz/type-check

Allow for literal `typeof` comparison

I recently wrote a type assertion library/framework based on this for a LiveScript project, and in the conversion, I've ran into the following problem: I would like to check against less-specific typeof values, the basic 7:

  • boolean
  • number
  • object
  • string
  • function
  • symbol
  • undefined

Could this be added? I'd rather not have to resort to the below hack, as it would be rather slow:

for type in <[boolean number object string function symbol undefined]>
    customTypes[type] = typeOf: '*', validate: -> typeof it == type

closed time in 2 months

isiahmeadows

push eventgkz/type-check

George Zahariev

commit sha 43163de0b1905acaabde867616fe556aa7b84c2d

update travis.yml

view details

push time in 2 months

push eventgkz/type-check

George Zahariev

commit sha ff85f2225541a665f0dda73e777be5cee8f6811d

Update deps

view details

push time in 2 months

issue closedgkz/type-check

Unable to use type-check with jspm / system.js

I've tried various ways of using type-check with jspm but am unable to get it to load. Even including the Browser version fails at the require() step. It seems as though there is some fundamental incompatibility issue.

See: https://github.com/jspm/registry/issues/770

closed time in 2 months

nevf

issue closedgkz/type-check

Type Check 2.0

Hi Guys

I like this project but I do not understand why it was not implemented in Livescript style. So I built it in my free time and I hope it or something like this will be integrated with Livescript language Please checkout "https://github.com/askucher/ftjs"

You are welcome to collaborate !

closed time in 2 months

askucher

PR closed gkz/type-check

Create bower.json

So that I can install via bower

+12 -0

0 comment

1 changed file

amay0048

pr closed time in 2 months

PR closed gkz/prelude-ls

Housekeeping: Resurrect the unit tests

Closes https://github.com/gkz/prelude-ls/issues/116.

+78 -98

2 comments

11 changed files

anko

pr closed time in 2 months

PR closed gkz/prelude-ls

update src/Obj.ls

added 1 space as to match the other function definitions

+1 -1

0 comment

1 changed file

Atlas48

pr closed time in 2 months

issue closedgkz/prelude-ls

Tests failure

Hello,

test fails (below report using mocha -R spec) :

  437 passing (296ms)
  2 failing

  1) negate
       zero:

      AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual                                                                                                                                              

- 0
+ -0
      + expected - actual

      -0
      +-0
      
      at Context.<anonymous> (test/Num.ls:35:12)
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)

  2) ceiling
       negative number:

      AssertionError [ERR_ASSERTION]: Input A expected to strictly equal input B:
+ expected - actual

- 0
+ -0
      + expected - actual

      -0
      +-0
      
      at Context.<anonymous> (test/Num.ls:236:12)
      at callFn (/usr/lib/nodejs/mocha/lib/runnable.js:354:21)
      at Test.Runnable.run (/usr/lib/nodejs/mocha/lib/runnable.js:346:7)
      at Runner.runTest (/usr/lib/nodejs/mocha/lib/runner.js:442:10)
      at /usr/lib/nodejs/mocha/lib/runner.js:560:12
      at next (/usr/lib/nodejs/mocha/lib/runner.js:356:14)
      at /usr/lib/nodejs/mocha/lib/runner.js:366:7
      at next (/usr/lib/nodejs/mocha/lib/runner.js:290:14)
      at Immediate._onImmediate (/usr/lib/nodejs/mocha/lib/runner.js:334:5)

I had to disable 2 tests:

--- a/test/Num.ls
+++ b/test/Num.ls
@@ -30,9 +30,6 @@
     eq 0, f 0

 suite 'negate' ->
-  test 'zero' ->
-    eq 0, negate 0
-
   test 'negative number' ->
     eq -2, negate 2

@@ -202,9 +199,6 @@
   test 'positive number' ->
     eq 1, ceiling 0.1

-  test 'negative number' ->
-    eq 0, ceiling -0.9
-
 suite 'floor' ->
   test 'zero' ->
     eq 0, floor 0

closed time in 2 months

guimard

issue closedgkz/prelude-ls

npm release

I see there hasn't been activity for a while, but might you put out a release which includes the updated license? As a dependency of several packages, my license checker program (licensee.js) is not able to resolve your license properly. Thanks!

closed time in 2 months

brettz9

push eventgkz/prelude-ls

George Zahariev

commit sha b70abc5eabb2b38e5ec78759f313167cdaebdfb1

update browser, add .gitignore

view details

push time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha 093e5159e3a202ccca6a4ccd0ae4ba9b2e06053a

build browser

view details

push time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha 08b8122a7aa3a8d8700630283e321479c5001bff

1.2.1

view details

push time in 2 months

created taggkz/prelude-ls

tag1.2.1

prelude.ls is a functionally oriented utility library - powerful and flexible, almost all of functions are curried. It is written in, and is the recommended base library for, http://livescript.net

created time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha 781fc3eaac2dbcdc76ae3f0a898a8113f56a3744

1.2.1

view details

push time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha 80309d14a90485d838593d589f19d357a9694b6d

1.2.0

view details

push time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha d4052990d13eb5adf9a3cc6ca339c6d4bcd49740

update travis.yml

view details

push time in 2 months

push eventgkz/prelude-ls

George Zahariev

commit sha 7372a603d84d6291379d820bc0e7300e4c68b1cf

update

view details

push time in 2 months

push eventgkz/ast-types

George Zahariev

commit sha 3f71b98fbd450419ee2d9e48af67785ca86ff58f

flow parser 0.122, build

view details

push time in 2 months

PR opened benjamn/ast-types

Update JavaScript definitions

This is an extensive refactor and update of the JS definitions. It is based on the ESTree spec (https://github.com/estree/estree) while keeping existing legacy behaviour.

Changes:

  • Create files for es2016-es2019 (delete es7 file, which had a mix of definitions from a mix of years), and move every definition/change to the correct year. For example, if a change was added in a later standard (e.g. catch clause param can be null in ES2019), the definition in core.ts should not reflect this, but the new file es2019.ts updates the definition
  • Move definitions in babel-corethat were actually JS definitions, to the correct file
  • Created a core-operators.ts file which defines arrays of the various operators. This makes it easy (and safer) to later introduce a new operator in later versions of the standard
  • There are some changes in terms of the ImportSpecifier nodes from the es6 definition - now what we .build follows the ESTree standard and what was defined in the babel-core definitions - imported and local rather than id and name
+641 -566

0 comment

20 changed files

pr created time in 2 months

create barnchgkz/ast-types

branch : update-js

created branch time in 2 months

PR opened benjamn/ast-types

Update Flow definitions

This pull request updates the Flow definitions. While Flow does not have a formal AST specification for Flow specific additions/changes, we do maintain a set of AST types that have not yet upstreamed (https://github.com/facebook/flow/blob/master/packages/flow-parser/test/custom_ast_types.js) - this PR upstreams the Flow specific ones.

Changes:

  • Now that the es2020 defs were added, fork on that rather than the previous latest, es7
  • Changed vars to consts
  • Added SymbolTypeAnnotation, BigIntTypeAnnotation, and BigIntLiteralTypeAnnotation defs
  • Added ObjectTypeIndexer def
  • Made the name field of FunctionTypeParam optional
  • Added a default field to TypeParameter
  • Made supertype field of OpaqueType optional
  • Fixed up the definition of DeclareOpaqueType
  • Added additional things that can be exported in DeclareExportDeclaration
  • Added predicate fields to function related defs
  • Added "typeof" as option to importKind field of ImportDeclaration
  • Added a variety of Flow enums related defs

Note, there are some additional changes we need to upstream around export related nodes, however these need to be moved/added to the JS definitions first before we can update them here. Will do that in a future PR.

+427 -75

0 comment

7 changed files

pr created time in 2 months

create barnchgkz/ast-types

branch : update-flow

created branch time in 2 months

PR opened benjamn/ast-types

Update JSX definitions

This pull request updates the JSX to the latest spec: https://github.com/facebook/jsx/blob/master/AST.md

Changes:

  • Now that the es2020 defs were added, fork on that rather than the previous latest, es7
  • Change vars to consts
  • JSXAttribute value can be JSXElements or JSXFragments (this parses in both Acorn and Babel parser)
  • I've updated some nodes to be correctly based off of Node rather than Expression
  • JSXExpressionContainer can contain Expression or JSXEmptyExpression
  • The children of a JSXElement or JSXFragment can include JSXSpreadChild (and factored out the children list for re-use) - JSXSpreadChild def already existed, it just wasn't referenced here
  • JSXText contains a raw field, a string
  • JSXFragment has the fields openingFragment and closingFragment, not openingElement and closingElement - I believe this was a copy/paste typo from when the support for JSXFragments was first added. Flow, Acorn, and Babel parser all parse JSXFragments with openingFragment and closingFragment
+170 -166

0 comment

5 changed files

pr created time in 2 months

create barnchgkz/ast-types

branch : update-jsx

created branch time in 2 months

fork gkz/ast-types

Esprima-compatible implementation of the Mozilla JS Parser API

fork in 2 months

issue commentfacebook/flow

Flow commands (type-at-pos, autocomplete, get-def etc) doesn't work with `export { foo } from './some-file'`

type at pos and autocomplete still doesn't work as far as I know

Mayank1791989

comment created time in 2 months

created tagflowtype/flow-bin

tagv0.121.0

Binary wrapper for Flow - A static type checker for JavaScript

created time in 3 months

push eventflowtype/flow-bin

George Zahariev

commit sha 0a3a59c57253d6f8660878147c76653e602fd4ef

v0.121.0

view details

push time in 3 months

push eventflowtype/flow-for-vscode

George Zahariev

commit sha 2eef887531893d7c993c2517244396603d9435ad

Update mixin-deep dependency due to security vulnerability

view details

George Zahariev

commit sha 7a179ec7bcd882be3e9b829333bba2849ff24077

Merge pull request #379 from gkz/master Update mixin-deep dependency due to security vulnerability

view details

push time in 3 months

PR opened flowtype/flow-for-vscode

Update mixin-deep dependency due to security vulnerability

https://nvd.nist.gov/vuln/detail/CVE-2019-10746

mixin-deep is vulnerable to Prototype Pollution in versions before 1.3.2 and version 2.0.0. The function mixin-deep could be tricked into adding or modifying properties of Object.prototype using a constructor payload.

Test plan:

yarn build && yarn test
+3 -2

0 comment

1 changed file

pr created time in 3 months

push eventgkz/flow-for-vscode

George Zahariev

commit sha 2eef887531893d7c993c2517244396603d9435ad

Update mixin-deep dependency due to security vulnerability

view details

push time in 3 months

more