Skip to content

Commit

Permalink
3.0
Browse files Browse the repository at this point in the history
commit 3dfd2ff
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Oct 25 00:32:52 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.9

commit 2d842e6
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Oct 25 00:10:30 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.8

commit ae1363a
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Tue Oct 24 23:54:50 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.7

commit f74e487
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Sun Oct 22 15:18:19 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.6

commit 8117e94
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Fri Oct 20 21:02:16 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.5

commit 046d90b
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 19 16:51:39 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.4

commit 6cfb623
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 19 16:48:27 2017 -0400

    Disable no-else-return rule

    Doc updates also

commit 8fb9ef8
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 22:31:36 2017 -0400

    Disable `no-unexpected-multiline` in eslint 4

commit 3dabeae
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 21:08:36 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.3

commit ce3ba57
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 20:18:51 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.2

commit d7945d6
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 20:06:28 2017 -0400

    Packaging updates

commit fb7c378
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 20:03:24 2017 -0400

    Update deps

commit 97cae1f
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 18:11:10 2017 -0400

    Post-merge fixups

commit 1c30620
Merge: 5721d25 54ed517
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 18:05:41 2017 -0400

    Merge remote-tracking branch 'babel-eslint/7.x' into prerelease/3.0.0

    # Conflicts:
    #	README.md
    #	babylon-to-espree/toAST.js
    #	index.js
    #	package.json
    #	test/non-regression.js
    #	yarn.lock

commit 5721d25
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Oct 12 17:20:09 2017 -0400

    Remove separate `pickBy` dep

commit 6bd6f19
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Oct 11 21:38:51 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.1

commit fe34c6c
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Oct 11 01:24:05 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-beta.0

commit 52dadaa
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Oct 11 01:15:42 2017 -0400

    Monkey-patch getFirstTokens

commit 4197163
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Sun Oct 8 21:31:37 2017 -0400

    Linter uses tooling API

    wcjohnson/lightscript#30
    wcjohnson/lightscript#31

commit ab96233
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Sun Oct 8 16:35:32 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.6

commit ea1ddf6
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Sun Oct 8 16:34:20 2017 -0400

    Catch up to plugin

commit 8c36f6c
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Fri Oct 6 17:49:53 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.5

commit 3f9444e
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Tue Oct 3 15:26:06 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.4

commit f1ea213
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Mon Oct 2 21:36:21 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.3

commit 8dcd15b
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Mon Oct 2 21:35:09 2017 -0400

    Patch linter for 3.0 alpha changes

commit f35f5bb
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Sat Sep 30 22:09:47 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.2

commit 9b3c535
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Sep 28 21:27:31 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.1

commit 7e0882e
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Thu Sep 28 21:15:46 2017 -0400

    Update comprehension syntax

commit deb1718
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Sep 27 22:17:27 2017 -0400

    @oigroup/lightscript-eslint@3.0.0-alpha.0

commit 57160c5
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Sep 27 22:06:26 2017 -0400

    3.0 defaults update

commit 1b5e466
Author: William C. Johnson <wcjohnson@oigroup.net>
Date:   Wed Sep 27 22:06:20 2017 -0400

    Quieted unmapped node message

commit 54ed517
Author: Reyad Attiyat <reyad.attiyat@gmail.com>
Date:   Mon May 29 20:41:14 2017 -0500

    Fix: Convert RegExpLieteral value to RegExp object (fixes babel#477) (babel#478)

commit 94bb5a1
Author: Sebastian McKenzie <sebmck@fb.com>
Date:   Fri Apr 21 22:14:19 2017 +0100

    7.2.3

commit dfaff04
Author: Andres Suarez <zertosh@gmail.com>
Date:   Fri Apr 21 11:48:52 2017 -0400

    Fix flow type spread handling (babel#465)

commit f59d200
Author: Henry Zhu <hi@henryzoo.com>
Date:   Wed Apr 12 12:07:05 2017 -0400

    7.2.2

commit 8622009
Author: Vitor Balocco <vitorbal@gmail.com>
Date:   Wed Apr 12 17:59:23 2017 +0200

    Fix: use eslint-scope instead of escope if present (babel#461)

commit 0f611b8
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 30 13:49:51 2017 -0400

    Separate finding peer deps from monkeypatching (babel#460)

commit 1201e12
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 19:36:10 2017 -0400

    Remove unused .gitmodules (babel#457)

commit a750684
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 19:32:05 2017 -0400

    Use dedent for unpadding (babel#456)

commit cdb92fe
Merge: 21dac73 ec14787
Author: Henry Zhu <hi@henryzoo.com>
Date:   Sat Mar 25 19:15:23 2017 -0400

    Merge pull request babel#455 from babel/babylon-to-espree-tidy

    Tidy up babylon-to-espree

commit ec14787
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 18:03:17 2017 -0400

    Enable strict mode in all of babylon-to-espree

commit 6c5beec
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 18:01:13 2017 -0400

    Move ast convert steps to babylon-to-espree

commit d2ce789
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:42:51 2017 -0400

    Use for-loop for template literal conversion

commit 539af05
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:36:20 2017 -0400

    Only iterate over tokens once

commit 06c3a31
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:28:01 2017 -0400

    Inline fixDirectives and use for-loop

commit 5d32ad0
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 17:07:41 2017 -0400

    Consolidate versions of "convertComments"

commit 2541fc9
Author: Andres Suarez <zertosh@gmail.com>
Date:   Sat Mar 25 00:18:57 2017 -0400

    toAst pass "source" in state instead of keeping in scope

commit 21dac73
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 15:46:48 2017 -0400

    Add type parameter scope tests (babel#454)

commit 3cda62e
Author: Henry Zhu <hi@henryzoo.com>
Date:   Thu Mar 23 14:03:23 2017 -0400

    7.2.1

commit 5626de1
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 14:02:24 2017 -0400

    Remove left over eslint 2 estraverse code (babel#452)

    This was missed in babel#361

commit b5fb53b
Author: Andres Suarez <zertosh@gmail.com>
Date:   Thu Mar 23 12:49:19 2017 -0400

    Fix type param and interface declaration scoping (babel#449)

commit f1cee0f
Author: Andres Suarez <zertosh@gmail.com>
Date:   Wed Mar 22 22:35:31 2017 -0400

    Remove lodash dependency (babel#450)

commit eb05812
Author: Andres Suarez <zertosh@gmail.com>
Date:   Wed Mar 22 22:34:13 2017 -0400

    Format non-regression errors for legibility (babel#451)

commit 7972a05
Author: Luís Couto <hello@luiscouto.pt>
Date:   Tue Mar 21 00:11:30 2017 +0000

    Update README.md with codeFrame option (babel#448)

commit 4db4db5
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Mar 20 17:53:26 2017 -0400

    7.2.0

commit 4499412
Author: wtgtybhertgeghgtwtg <wtgtybhertgeghgtwtg@gmail.com>
Date:   Mon Mar 20 14:50:09 2017 -0700

    Use `lodash` instead of `lodash.pickby`. (babel#435)

commit a2c3b30
Author: Alex Rattray <rattray.alex@gmail.com>
Date:   Mon Mar 20 14:46:07 2017 -0700

    [flow] Process polymorphic type bounds on functions (babel#444)

commit 515adef
Author: Luís Couto <hello@luiscouto.pt>
Date:   Mon Mar 20 21:45:11 2017 +0000

    Add option to disable code frame. (babel#446)

    * Add option to disable code hightlight.

    * Rename codeHighlight with codeFrame

    * Add codeFrame tests

    * Remove colors from test assertions

commit ce66e73
Merge: bdeb86f b49ab20
Author: Henry Zhu <hi@henryzoo.com>
Date:   Mon Mar 20 11:44:33 2017 -0400

    Merge pull request babel#447 from kaicataldo/clean-up-eslint

    Chore: Clean up and upgrades

commit b49ab20
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Mon Mar 20 10:33:14 2017 -0400

    Updates ESLint version/remove unnecessary config

commit 702d6b8
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Mon Mar 20 10:27:28 2017 -0400

    Remove broken ESLint tests

commit 6b4c4ca
Author: Kai Cataldo <kaicataldo@gmail.com>
Date:   Sat Mar 11 22:15:47 2017 -0500

    Upgrade outdated dependencies
  • Loading branch information
wcjohnson committed Oct 25, 2017
1 parent bccfb2e commit 30af98b
Show file tree
Hide file tree
Showing 20 changed files with 708 additions and 665 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
module.exports = {
root: true,
extends: "babel",
parserOptions: {
ecmaVersion: 7,
sourceType: "module"
},
rules: {
"no-var": 0,
"max-len": 0
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# @oigroup/lightscript-eslint

> NB: This is a fork of lightscript-eslint which implements language changes that are not necessarily endorsed by upstream. Generally speaking, our intent is to closely follow the upstream language -- however, there may be notable deviations which are documented below.
> `@oigroup/lightscript-eslint` is most frequently tested with `eslint@^4.0.0`.
> It SHOULD be backwards-compatible with `eslint@^3.0.0` as well.
`@oigroup/lightscript-eslint` is a fork of `babel-eslint` that parses code with
`@oigroup/babylon-lightscript` and `@oigroup/babel-plugin-lightscript`.
Expand All @@ -12,7 +13,7 @@ all others will be processed exactly as in `babel-eslint`.
To use, just `npm install --save-dev @oigroup/lightscript-eslint`
and add `parser: "@oigroup/lightscript-eslint"` to your `.eslintrc`.

Testing so far has been limited; this is very much alpha software and it may not work well. So far, it is has seen limited use with the following configuration:
Example configuration (with React):

```json
{
Expand All @@ -28,10 +29,34 @@ Testing so far has been limited; this is very much alpha software and it may not
"browser": true,
"node": true,
"es6": true
},
"rules": {
"semi": ["error", "never"],
"react/require-render-return": 0
}
}
```

When running `eslint` from the CLI, you must tell it to process LightScript file extensions:

```
$ eslint --ext .js,.lsc src
```

### Live Linting

#### Visual Studio Code

- Set up eslint for your project as above. Verify that eslint lints correctly from the CLI.
- Install the `ESLint` extension for VSCode: https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint
- Tell VSCode to live-lint LightScript files by adding the following entry to your VSCode options (workspace or global):
```
"eslint.validate": ["javascript", "javascriptreact", "lightscript"]
```

### Broken Rules

The following lint rules are either buggy, broken, or do not make sense in the context of LightScript. They are disabled at the code level and will not run even if you enable them in your configuration.

- `no-unexpected-multiline`
- `no-else-return`

### Contributing

Issues: https://github.com/wcjohnson/lightscript/issues
2 changes: 2 additions & 0 deletions babylon-to-espree/attachComments.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

// comment fixes
module.exports = function (ast, comments, tokens) {
if (comments.length) {
Expand Down
17 changes: 17 additions & 0 deletions babylon-to-espree/convertComments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";

module.exports = function (comments) {
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
if (comment.type === "CommentBlock") {
comment.type = "Block";
} else if (comment.type === "CommentLine") {
comment.type = "Line";
}
// sometimes comments don't get ranges computed,
// even with options.ranges === true
if (!comment.range) {
comment.range = [comment.start, comment.end];
}
}
};
2 changes: 2 additions & 0 deletions babylon-to-espree/convertTemplateType.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = function (tokens, tt) {
var startingToken = 0;
var currentToken = 0;
Expand Down
54 changes: 35 additions & 19 deletions babylon-to-espree/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
exports.attachComments = require("./attachComments");

exports.toTokens = require("./toTokens");
exports.toAST = require("./toAST");

exports.convertComments = function (comments) {
for (var i = 0; i < comments.length; i++) {
var comment = comments[i];
if (comment.type === "CommentBlock") {
comment.type = "Block";
} else if (comment.type === "CommentLine") {
comment.type = "Line";
}
// sometimes comments don't get ranges computed,
// even with options.ranges === true
if (!comment.range) {
comment.range = [comment.start, comment.end];
}
}
"use strict";

var attachComments = require("./attachComments");
var convertComments = require("./convertComments");
var toTokens = require("./toTokens");
var toAST = require("./toAST");

module.exports = function (ast, traverse, tt, code) {
// remove EOF token, eslint doesn't use this for anything and it interferes
// with some rules see https://github.com/babel/babel-eslint/issues/2
// todo: find a more elegant way to do this
ast.tokens.pop();

// convert tokens
ast.tokens = toTokens(ast.tokens, tt, code);

// add comments
convertComments(ast.comments);

// transform esprima and acorn divergent nodes
toAST(ast, traverse, code);

// ast.program.tokens = ast.tokens;
// ast.program.comments = ast.comments;
// ast = ast.program;

// remove File
ast.type = "Program";
ast.sourceType = ast.program.sourceType;
ast.directives = ast.program.directives;
ast.body = ast.program.body;
delete ast.program;
delete ast._paths;

attachComments(ast, ast.comments, ast.tokens);
};
98 changes: 41 additions & 57 deletions babylon-to-espree/toAST.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,22 @@
var source;
"use strict";

var convertComments = require("./convertComments");
var cloneDeep = require("lodash/cloneDeep");

module.exports = function (ast, traverse, code) {
source = code;
var state = { source: code };
ast.range = [ast.start, ast.end];
traverse(ast, astTransformVisitor);
traverse(ast, astTransformVisitor, null, state);
};

function changeToLiteral(node) {
function changeToLiteral(node, state) {
node.type = "Literal";
if (!node.raw) {
if (node.extra && node.extra.raw) {
node.raw = node.extra.raw;
} else {
node.raw = source.slice(node.start, node.end);
}
}
}

function changeComments(nodeComments) {
for (var i = 0; i < nodeComments.length; i++) {
var comment = nodeComments[i];
if (comment.type === "CommentLine") {
comment.type = "Line";
} else if (comment.type === "CommentBlock") {
comment.type = "Block";
node.raw = state.source.slice(node.start, node.end);
}
comment.range = [comment.start, comment.end];
}
}

Expand Down Expand Up @@ -76,24 +66,40 @@ var astTransformVisitor = {
}

if (node.trailingComments) {
changeComments(node.trailingComments);
convertComments(node.trailingComments);
}

if (node.leadingComments) {
changeComments(node.leadingComments);
convertComments(node.leadingComments);
}

// make '_paths' non-enumerable (babel-eslint #200)
Object.defineProperty(node, "_paths", { value: node._paths, writable: true });
},
exit (path) {
exit (path, state) {
var node = path.node;

[
fixDirectives,
].forEach((fixer) => {
fixer(path);
});
// fixDirectives
if (path.isFunction() || path.isProgram()) {
var directivesContainer = node;
var body = node.body;
if (node.type !== "Program") {
directivesContainer = body;
body = body.body;
}
if (directivesContainer.directives) {
for (var i = directivesContainer.directives.length - 1; i >= 0; i--) {
var directive = directivesContainer.directives[i];
directive.type = "ExpressionStatement";
directive.expression = directive.value;
delete directive.value;
directive.expression.type = "Literal";
changeToLiteral(directive.expression, state);
body.unshift(directive);
}
delete directivesContainer.directives;
}
}

if (path.isJSXText()) {
node.type = "Literal";
Expand All @@ -102,7 +108,7 @@ var astTransformVisitor = {

if (path.isNumericLiteral() ||
path.isStringLiteral()) {
changeToLiteral(node);
changeToLiteral(node, state);
}

if (path.isBooleanLiteral()) {
Expand All @@ -119,7 +125,11 @@ var astTransformVisitor = {
if (path.isRegExpLiteral()) {
node.type = "Literal";
node.raw = node.extra.raw;
node.value = {};
try {
node.value = new RegExp(node.pattern, node.flags);
} catch (err) {
node.value = null;
}
node.regex = {
pattern: node.pattern,
flags: node.flags
Expand All @@ -135,7 +145,7 @@ var astTransformVisitor = {
}

if (path.isClassMethod() || path.isObjectMethod()) {
var code = source.slice(node.key.end, node.body.start);
var code = state.source.slice(node.key.end, node.body.start);
var offset = code.indexOf("(");

node.value = {
Expand Down Expand Up @@ -242,7 +252,8 @@ var astTransformVisitor = {

// template string range fixes
if (path.isTemplateLiteral()) {
node.quasis.forEach((q) => {
for (var j = 0; j < node.quasis.length; j++) {
var q = node.quasis[j];
q.range[0] -= 1;
if (q.tail) {
q.range[1] += 1;
Expand All @@ -255,34 +266,7 @@ var astTransformVisitor = {
} else {
q.loc.end.column += 2;
}
});
}
}
}
};


function fixDirectives (path) {
if (!(path.isProgram() || path.isFunction())) return;

var node = path.node;
var directivesContainer = node;
var body = node.body;

if (node.type !== "Program") {
directivesContainer = body;
body = body.body;
}

if (!directivesContainer.directives) return;

directivesContainer.directives.reverse().forEach((directive) => {
directive.type = "ExpressionStatement";
directive.expression = directive.value;
delete directive.value;
directive.expression.type = "Literal";
changeToLiteral(directive.expression);
body.unshift(directive);
});
delete directivesContainer.directives;
}
// fixDirectives
2 changes: 2 additions & 0 deletions babylon-to-espree/toToken.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = function (token, tt, source) {
var type = token.type;
token.range = [token.start, token.end];
Expand Down
13 changes: 8 additions & 5 deletions babylon-to-espree/toTokens.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
"use strict";

var convertTemplateType = require("./convertTemplateType");
var toToken = require("./toToken");

module.exports = function (tokens, tt, code) {
// transform tokens to type "Template"
convertTemplateType(tokens, tt);
var transformedTokens = tokens.filter((token) => {
return token.type !== "CommentLine" && token.type !== "CommentBlock";
});

for (var i = 0, l = transformedTokens.length; i < l; i++) {
transformedTokens[i] = toToken(transformedTokens[i], tt, code);
var transformedTokens = [];
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
if (token.type !== "CommentLine" && token.type !== "CommentBlock") {
transformedTokens.push(toToken(token, tt, code));
}
}

return transformedTokens;
Expand Down
1 change: 0 additions & 1 deletion eslint
Submodule eslint deleted from fdce86
6 changes: 0 additions & 6 deletions eslint-tester.js

This file was deleted.

0 comments on commit 30af98b

Please sign in to comment.