diff --git a/.eslintrc b/.eslintrc index 68ca2fc..c71f394 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,10 +1,17 @@ { + "ecmaFeatures": { + "jsx": true + }, "env": { "browser": true, "mocha": true, "node": true }, "parser": "babel-eslint", + "plugins": [ + "react", + "import" + ], "rules": { "array-bracket-spacing": 2, "brace-style": [2, "stroustrup", {"allowSingleLine": true}], @@ -18,6 +25,12 @@ "eol-last": 2, "eqeqeq": [2, "allow-null"], "guard-for-in": 0, + // eslint-plugin-import + "import/no-unresolved": [2, {"commonjs": true}], + "import/named": 2, + "import/default": 2, + "import/namespace": 2, + "import/export": 2, "indent": [2, 2, { "SwitchCase": 1 }], @@ -116,10 +129,18 @@ // Not ready yet. "react/sort-comp": 2, "react/wrap-multilines": 2, }, - "plugins": [ - "react" - ], - "ecmaFeatures": { - "jsx": true + "settings": { + "import/ignore": [ + "node_modules", + "\\.json$" + ], + "import/parser": "babel-eslint", + "import/resolve": { + "extensions": [ + ".js", + ".jsx", + ".json" + ] + } } } diff --git a/README.md b/README.md index 220bba3..25f53c5 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ createBlueKit({ baseDir: `${__dirname}/src/browser`, // relative paths from base dir where to look for components paths: ['./components/', './auth'], - // set to false to disable specialized component code mutations the bluekit team uses - specialReplacements: false + // set to true when providing simple components such as `export default function MyComponent() {
Hello
}` + noSpecialReplacements: true }); ``` @@ -91,6 +91,10 @@ gulp ava gulp eslint ``` +## Additional info + +BlueKit automatically hides props that don’t affect the component’s look. + If you get some kind of weird error and BlueKit doesn't load at all, try to reset localStorage by running `localStorage.clear();`. We are working on automatic checks of localStorage values. ## License diff --git a/example/src/App.js b/example/src/App.js index b47feaf..88f772e 100644 --- a/example/src/App.js +++ b/example/src/App.js @@ -1,6 +1,6 @@ import React, {Component} from '../../node_modules/react'; import BlueKit from '../../src'; -import componentsIndex from './componentsIndex'; +import componentsIndex from './componentsIndex'; // eslint-disable-line export default class App extends Component { render() { diff --git a/package.json b/package.json index eeee56d..401576a 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,7 @@ "babel-register": "^6.6.5", "eslint": "2.0.0", "eslint-config-airbnb": "^0.1.0", + "eslint-plugin-import": "^2.1.0", "eslint-plugin-react": "^3.5.1", "estraverse-fb": "^1.3.1", "expect": "^1.12.2", diff --git a/src/createBlueKit.js b/src/createBlueKit.js index bb68a47..f81fdc5 100644 --- a/src/createBlueKit.js +++ b/src/createBlueKit.js @@ -48,7 +48,7 @@ function getImportFile(directory, file) { function generateComponentData(config, file, directory) { const filePath = path.join(directory, file); let content = fs.readFileSync(filePath).toString() - if (config.specialReplacements) { + if (!config.noSpecialReplacements) { content = content .replace('_interopRequireDefault(_react)', 'require("react")') .replace(/import Component from ["']react-pure-render\/component["']/, 'import {Component} from "react"')