Skip to content

Commit

Permalink
Add eslint-import and make noSpecialReplacements explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
imtoo committed Nov 4, 2016
1 parent e65b290 commit eda6418
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 9 deletions.
31 changes: 26 additions & 5 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -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}],
Expand All @@ -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
}],
Expand Down Expand Up @@ -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"
]
}
}
}
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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() { <div>Hello</div> }`
noSpecialReplacements: true
});
```

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/createBlueKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"')
Expand Down

0 comments on commit eda6418

Please sign in to comment.