Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fixtures/eslint/.eslintrc.json
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
}
}
7 changes: 7 additions & 0 deletions fixtures/eslint/README.md
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)
11 changes: 11 additions & 0 deletions fixtures/eslint/index.js
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(() => {});
}
}
12 changes: 12 additions & 0 deletions fixtures/eslint/package.json
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"
}
}
35 changes: 35 additions & 0 deletions fixtures/eslint/proxy/index.js
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};
4 changes: 4 additions & 0 deletions fixtures/eslint/proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"private": true,
"version": "0.0.0"
}
3 changes: 3 additions & 0 deletions fixtures/eslint/watch.sh
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)
Loading