diff --git a/README.md b/README.md index fafb5ee2..3a0ecdff 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,30 @@ Example configuration (with React): } ``` +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 diff --git a/index.js b/index.js index a4c8a177..df146474 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,11 @@ var codeFrame = require("babel-code-frame"); var lscPlugin = require("@oigroup/babel-plugin-lightscript"); var lscTooling = require("@oigroup/babel-plugin-lightscript/lib/tooling"); +var lightScriptDisabledRulesTable = { + "no-unexpected-multiline": true, + "no-else-return": true +}; + var hasPatched = false; var eslintOptions = {}; @@ -370,13 +375,14 @@ function monkeypatch(modules) { }; // monkeypatch rules + // in eslint 4, rule getter is a class whereas it was an object in 3... var emptyRule = function() { return {}; }; emptyRule.create = function() { return {}; }; var rules = getModule(eslintMod, "./rules"); var _get = rules.get || rules.prototype.get; var nextGet = function get(ruleId) { - // disable no-unexpected-multiline, lsc compiler deals with this - if (ruleId === "no-unexpected-multiline") { + // disable invalid or broken rules + if (ruleId && lightScriptDisabledRulesTable[ruleId]) { return emptyRule; } else { return _get.call(this || rules, ruleId); diff --git a/test/non-regression.js b/test/non-regression.js index 24d2dc97..a4ad1728 100644 --- a/test/non-regression.js +++ b/test/non-regression.js @@ -410,6 +410,20 @@ a = b -> c ); }); + it("no-else-return disabled", () => { + verifyAndAssertMessages( + unpad(` + f() -> + if true: + { three: 3 } + else: + {} + `), + { "no-else-return": 2 }, + [] + ); + }); + //////////// end lsc tests });