-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ESLint rule playground * Update index.js * Update index.js
- Loading branch information
Showing
8 changed files
with
939 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"root": true, | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"plugins": ["react-hooks"], | ||
"rules": { | ||
"react-hooks/rules-of-hooks": 2 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# ESLint Playground Fixture | ||
|
||
This is an internal playground for quick iteration on our lint rules inside an IDE like VSCode. | ||
|
||
See instructions in `./index.js` in this directory. | ||
|
||
![Demo](https://duaw26jehqd4r.cloudfront.net/items/2Z390a31003O0l0o0e3O/Screen%20Recording%202019-01-16%20at%2010.29%20PM.gif?v=d6856125) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// This is a testing playground for our lint rules. | ||
|
||
// 1. Run yarn && yarn start | ||
// 2. "File > Add Folder to Workspace" this specific folder in VSCode with ESLint extension | ||
// 3. Changes to the rule source should get picked up without restarting ESLint server | ||
|
||
function Foo() { | ||
if (condition) { | ||
useEffect(() => {}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"private": true, | ||
"name": "eslint-playground", | ||
"dependencies": { | ||
"eslint": "4.1.0", | ||
"eslint-plugin-react-hooks": "link:./proxy" | ||
}, | ||
"scripts": { | ||
"start": "./watch.sh", | ||
"lint": "eslint index.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
// This file is a proxy for our rule definition that will | ||
// load the latest built version on every check. This makes | ||
// it convenient to test inside IDEs (which would otherwise | ||
// load a version of our rule once and never restart the server). | ||
// See instructions in ../index.js playground. | ||
|
||
let build; | ||
reload(); | ||
|
||
function reload() { | ||
for (let id in require.cache) { | ||
if (/eslint-plugin-react-hooks/.test(id)) { | ||
delete require.cache[id]; | ||
} | ||
} | ||
// Point to the built version. | ||
build = require('../../../build/node_modules/eslint-plugin-react-hooks'); | ||
} | ||
|
||
let rules = {}; | ||
for (let key in build.rules) { | ||
if (build.rules.hasOwnProperty(key)) { | ||
rules[key] = Object.assign({}, build.rules, { | ||
create() { | ||
// Reload changes to the built rule | ||
reload(); | ||
return build.rules[key].create.apply(this, arguments); | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
module.exports = {rules}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"private": true, | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
(cd ../.. && yarn build eslint --type=NODE_DEV) | ||
(cd ../.. && watchman-make --make 'yarn build eslint --type=NODE_DEV' -p 'packages/eslint-plugin-*/**/*' -t ignored) |
Oops, something went wrong.