Skip to content

Commit e575f10

Browse files
committed
fix imports in examples, improve eslint config
1 parent 6a5c625 commit e575f10

20 files changed

+65
-73
lines changed

.eslintignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,4 @@ test/e2e/*.js
2323
**.min.js
2424
dist/
2525
__coverage__/
26-
rollup.config.js
27-
rollup.config.browser.js
28-
2926
index.d.ts

__tests__/.eslintrc.json

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,6 @@
44
"jest": true,
55
"node": true
66
},
7-
"extends": [
8-
"eslint:recommended",
9-
"standard-with-typescript",
10-
"plugin:@typescript-eslint/eslint-recommended",
11-
"plugin:@typescript-eslint/recommended",
12-
"plugin:prettier/recommended"
13-
],
14-
"parser": "@typescript-eslint/parser",
15-
"parserOptions": {
16-
"project": "./tsconfig.json",
17-
"sourceType": "module"
18-
},
19-
"plugins": ["prettier", "@typescript-eslint", "jest"],
20-
"root": true,
21-
"rules": {
22-
"@typescript-eslint/explicit-function-return-type": "off",
23-
"@typescript-eslint/interface-name-prefix": "off",
24-
"@typescript-eslint/member-delimiter-style": "off",
25-
"@typescript-eslint/no-empty-function": "off",
26-
"@typescript-eslint/no-var-requires": "off",
27-
"@typescript-eslint/semi": "off",
28-
"@typescript-eslint/space-before-function-paren": "off",
29-
"arrow-parens": "off",
30-
"class-methods-use-this": "off",
31-
"max-classes-per-file": "off",
32-
"standard/no-callback-literal": "off",
33-
"no-continue": "off",
34-
"no-empty-function": "off",
35-
"no-multi-assign": "off",
36-
"no-param-reassign": "off",
37-
"no-plusplus": "off",
38-
"no-prototype-builtins": "off",
39-
"no-restricted-globals": "off",
40-
"no-underscore-dangle": "off",
41-
"prettier/prettier": "error",
42-
"semi": "off"
43-
}
7+
"extends": "../.eslintrc.json",
8+
"plugins": ["prettier", "@typescript-eslint", "jest"]
449
}

examples/.eslintrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": "../.eslintrc.json",
8+
"parserOptions": {
9+
"project": "./tsconfig.json"
10+
}
11+
}

examples/javascript/childrens-book.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const brain = require('../../src');
1+
const brain = require('../../dist/brain');
22

33
const trainingData = [
44
'Jane saw Doug.',

examples/javascript/cross-validate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert');
2-
const brain = require('../../src');
2+
const brain = require('../../dist/brain');
33

44
const trainingData = [
55
// xor data, repeating to simulate that we have a lot of data

examples/javascript/gpu-fallback.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const brain = require('../../src');
1+
const brain = require('../../dist/brain');
22
const net = new brain.NeuralNetworkGPU();
33

44
const xorTrainingData = [

examples/javascript/gpu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
<head>
3-
<script src="../../dist/brain-browser.js"></script>
3+
<script src="https://unpkg.com/brain.js"></script>
44
<script>
55
const net = new brain.NeuralNetworkGPU();
66

examples/javascript/learn-math.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const brain = require('../../src');
1+
const brain = require('../../dist/brain');
22

33
const LSTM = brain.recurrent.LSTM;
44
const net = new LSTM();

examples/javascript/predict-numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert');
2-
const brain = require('../../src');
2+
const brain = require('../../dist/brain');
33

44
const net = new brain.recurrent.LSTMTimeStep({
55
inputSize: 2,

examples/javascript/predict-tense.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const brain = require('brain.js');
1+
const brain = require('../../dist/brain');
22

33
// create configuration for training
44
const config = {

examples/javascript/recommendation-engine/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</head>
2626

2727
<body onLoad="nextTry();">
28-
<script src="../../../dist/brain-browser.min.js"></script>
28+
<script src="https://unpkg.com/brain.js"></script>
2929
<script src="itemsInStock.js"></script>
3030
<script>
3131
const color_normalization_factor = 100;

examples/javascript/rendering-svg.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
padding-left: 100px;
7878
}
7979
</style>
80-
<script src="../../dist/brain-browser.js"></script>
80+
<script src="https://unpkg.com/brain.js"></script>
8181
</head>
8282
<body>
8383
<div class="flex-container">
@@ -86,16 +86,16 @@
8686
<div class="input-wrapper">
8787
<div class="input-label">Network type</div>
8888
<select name="network-type">
89-
<option value="NeuralNetwork"
90-
>FeedForward (brain.NeuralNetwork)</option
91-
>
89+
<option value="NeuralNetwork">
90+
FeedForward (brain.NeuralNetwork)
91+
</option>
9292
<option value="RNN">Recurrent (brain.recurrent.RNN)</option>
93-
<option value="RNNTimeStep"
94-
>Recurrent Time Step (brain.recurrent.RNNTimeStep)</option
95-
>
96-
<option value="FeedForward"
97-
>FeedForward (brain.FeedForward)</option
98-
>
93+
<option value="RNNTimeStep">
94+
Recurrent Time Step (brain.recurrent.RNNTimeStep)
95+
</option>
96+
<option value="FeedForward">
97+
FeedForward (brain.FeedForward)
98+
</option>
9999
<option value="Recurrent">Recurrent (brain.Recurrent)</option>
100100
</select>
101101
</div>
@@ -208,7 +208,9 @@
208208
name="inp-labels"
209209
cols="23"
210210
placeholder="inputs' labels separated by commas"
211-
>a,b,c,d,e,f,g,h,i,j</textarea>
211+
>
212+
a,b,c,d,e,f,g,h,i,j</textarea
213+
>
212214
</div>
213215
<div class="input-wrapper">
214216
<label class="input-label"

examples/javascript/stream-example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert');
2-
const brain = require('../../src');
2+
const brain = require('../../dist/brain');
33

44
const net = new brain.NeuralNetwork();
55
const xor = [

examples/javascript/string-classification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const brain = require('../../src');
1+
const brain = require('../../dist/brain');
22

33
// create configuration for training
44
const config = {

examples/javascript/which-letter-simple.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const assert = require('assert');
2-
const brain = require('../../src');
2+
const brain = require('../../dist/brain');
33

44
/**
55
* Return 0 or 1 for '#'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"dist": "npm run build",
113113
"lint": "run-p lint:**",
114114
"lint:eslint": "eslint --fix --ext .js,.ts __tests__ src",
115-
"lint:typecheck": "tsc",
115+
"lint:typecheck": "tsc --project tsconfig.source.json",
116116
"postinstall": "npm rebuild gpu.js",
117117
"test": "jest",
118118
"watch": "run-p watch:**",

rollup.config.browser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313

1414
// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
1515
// https://rollupjs.org/guide/en#external-e-external
16-
// external: ['gpu.js'],
16+
external: [],
1717

1818
plugins: [
1919
// Allows node_modules resolution
@@ -23,13 +23,13 @@ export default {
2323
extensions,
2424
}),
2525

26+
// Allow bundling cjs modules. Rollup doesn't understand cjs
27+
commonjs(),
28+
2629
// Allows the node builtins to be required/imported.
2730
globals(),
2831
builtins(),
2932

30-
// Allow bundling cjs modules. Rollup doesn't understand cjs
31-
commonjs(),
32-
3333
// Compile TypeScript/JavaScript files
3434
babel({
3535
extensions,

rollup.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export default {
2222
extensions,
2323
}),
2424

25+
// Allow bundling cjs modules. Rollup doesn't understand cjs
26+
commonjs(),
27+
2528
// Allows the node builtins to be required/imported.
2629
globals(),
2730
builtins(),
2831

29-
// Allow bundling cjs modules. Rollup doesn't understand cjs
30-
commonjs(),
31-
3232
// Compile TypeScript/JavaScript files
3333
babel({
3434
extensions,

tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"allowSyntheticDefaultImports": true,
55
"checkJs": false,
66
"esModuleInterop": true,
7-
"incremental": true,
87
"module": "esnext",
98
"moduleResolution": "node",
109
"noEmit": true,
@@ -15,6 +14,5 @@
1514
"strict": true,
1615
"target": "esnext"
1716
},
18-
"exclude": ["node_modules", "**/*.json", "**/*.config.js", "**/*.d.ts"],
19-
"include": ["./src", "./__tests__"]
17+
"exclude": ["node_modules", "**/*.json", "**/*.d.ts", "./dist"]
2018
}

tsconfig.source.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"compilerOptions": {
3+
"allowJs": true,
4+
"allowSyntheticDefaultImports": true,
5+
"checkJs": false,
6+
"esModuleInterop": true,
7+
"module": "esnext",
8+
"moduleResolution": "node",
9+
"noEmit": true,
10+
"noEmitOnError": true,
11+
"outDir": "./dist",
12+
"rootDir": "./",
13+
"skipLibCheck": true,
14+
"strict": true,
15+
"target": "esnext"
16+
},
17+
"exclude": ["node_modules", "**/*.json", "**/*.d.ts", "./dist"],
18+
"include": ["./src"]
19+
}

0 commit comments

Comments
 (0)