Skip to content

Commit aa8fbd4

Browse files
committed
Re-indents to 2 spaces
1 parent 4168404 commit aa8fbd4

File tree

15 files changed

+460
-476
lines changed

15 files changed

+460
-476
lines changed

.babelrc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"presets": [
3-
"env"
4-
]
2+
"presets": ["env"]
53
}

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ root = true
33
[*]
44
charset = utf-8
55
indent_style = space
6-
indent_size = 4
6+
indent_size = 2
77
end_of_line = lf
88
insert_final_newline = true
99
trim_trailing_whitespace = true

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
dist/
3+
4+
package-lock.json
5+
6+
!**/.*

.eslintrc.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
// https://eslint.org/docs/user-guide/configuring
22

33
module.exports = {
4-
root: true,
5-
env: {
6-
browser: true,
7-
},
8-
extends: [
9-
'airbnb-base',
10-
],
11-
// add your custom rules here
12-
rules: {
13-
'class-methods-use-this': 'off',
14-
'comma-dangle': ['error', {
15-
'arrays': 'always-multiline',
16-
'objects': 'always-multiline',
17-
'imports': 'always-multiline',
18-
'exports': 'always-multiline',
19-
'functions': 'never',
20-
}],
21-
'indent': ['error', 4, {
22-
SwitchCase: 1,
23-
}],
24-
'no-duplicate-imports': 'error',
25-
// risk only exist with semi-colon auto insertion. Not our case.
26-
'no-plusplus': 'off',
27-
'no-param-reassign': 'off',
28-
'no-underscore-dangle': ['error', {
29-
'allowAfterSuper': true,
30-
'allowAfterThis': true,
31-
}],
32-
'prefer-destructuring': 'off',
33-
// don't require .js extension when importing
34-
'import/extensions': ['error', 'always', { js: 'never' }],
35-
// allow optionalDependencies
36-
'import/no-extraneous-dependencies': ['error', {
37-
optionalDependencies: ['test/unit/index.js'],
38-
}],
39-
'import/prefer-default-export': 'off',
40-
// allow debugger during development
41-
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
42-
},
4+
root: true,
5+
env: {
6+
browser: true,
7+
},
8+
extends: [
9+
'airbnb-base',
10+
],
11+
// add your custom rules here
12+
rules: {
13+
'class-methods-use-this': 'off',
14+
'comma-dangle': ['error', {
15+
arrays: 'always-multiline',
16+
objects: 'always-multiline',
17+
imports: 'always-multiline',
18+
exports: 'always-multiline',
19+
functions: 'never',
20+
}],
21+
indent: ['error', 2, {
22+
SwitchCase: 1,
23+
}],
24+
'no-duplicate-imports': 'error',
25+
// risk only exist with semi-colon auto insertion. Not our case.
26+
'no-plusplus': 'off',
27+
'no-param-reassign': 'off',
28+
'no-underscore-dangle': ['error', {
29+
allowAfterSuper: true,
30+
allowAfterThis: true,
31+
}],
32+
'prefer-destructuring': 'off',
33+
// don't require .js extension when importing
34+
'import/extensions': ['error', 'always', { js: 'never' }],
35+
// allow optionalDependencies
36+
'import/no-extraneous-dependencies': ['error', {
37+
optionalDependencies: ['test/unit/index.js'],
38+
}],
39+
'import/prefer-default-export': 'off',
40+
// allow debugger during development
41+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
42+
},
4343
};

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ install:
1010
before_script:
1111
- npm run build:dev
1212
script:
13+
- npm run lint
1314
- npm run test:codecov
1415
cache:
1516
directories:

build/build.main.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,71 +7,71 @@ const rollup = require('rollup');
77
const configs = require('./configs');
88

99
if (!fs.existsSync('dist')) {
10-
fs.mkdirSync('dist');
10+
fs.mkdirSync('dist');
1111
}
1212

1313
build(Object.keys(configs).map(key => configs[key]));
1414

1515
function build(builds) {
16-
let built = 0;
17-
const total = builds.length;
18-
const next = () => {
19-
buildEntry(builds[built]).then(() => {
20-
built++;
21-
if (built < total) {
22-
next();
23-
}
24-
}).catch(logError);
25-
};
16+
let built = 0;
17+
const total = builds.length;
18+
const next = () => {
19+
buildEntry(builds[built]).then(() => {
20+
built++;
21+
if (built < total) {
22+
next();
23+
}
24+
}).catch(logError);
25+
};
2626

27-
next();
27+
next();
2828
}
2929

3030
function buildEntry({ input, output }) {
31-
const isProd = /min\.js$/.test(output.file);
32-
return rollup.rollup(input)
33-
.then(bundle => bundle.generate(output))
34-
.then(({ code }) => {
35-
if (isProd) {
36-
const minified = (output.banner ? output.banner + '\n' : '') + uglify.minify(code, {
37-
output: { ascii_only: true },
38-
}).code;
39-
return write(output.file, minified, true);
40-
}
41-
return write(output.file, code);
42-
});
31+
const isProd = /min\.js$/.test(output.file);
32+
return rollup.rollup(input)
33+
.then(bundle => bundle.generate(output))
34+
.then(({ code }) => {
35+
if (isProd) {
36+
const minified = (output.banner ? output.banner + '\n' : '') + uglify.minify(code, {
37+
output: { ascii_only: true },
38+
}).code;
39+
return write(output.file, minified, true);
40+
}
41+
return write(output.file, code);
42+
});
4343
}
4444

4545
function write(dest, code, zip) {
46-
return new Promise((resolve, reject) => {
47-
function report(extra) {
48-
logError(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code) + (extra || ''));
49-
resolve();
50-
}
46+
return new Promise((resolve, reject) => {
47+
function report(extra) {
48+
logError(blue(path.relative(process.cwd(), dest)) + ' ' + getSize(code) + (extra || ''));
49+
resolve();
50+
}
5151

52-
fs.writeFile(dest, code, (err) => {
53-
if (err) return reject(err);
54-
if (zip) {
55-
zlib.gzip(code, (error, zipped) => {
56-
if (error) return reject(error);
57-
report(' (gzipped: ' + getSize(zipped) + ')');
58-
});
59-
} else {
60-
report();
61-
}
52+
fs.writeFile(dest, code, (err) => {
53+
if (err) return reject(err);
54+
if (zip) {
55+
zlib.gzip(code, (error, zipped) => {
56+
if (error) return reject(error);
57+
report(' (gzipped: ' + getSize(zipped) + ')');
6258
});
59+
} else {
60+
report();
61+
}
6362
});
63+
});
6464
}
6565

6666
function getSize(code) {
67-
return (code.length / 1024).toFixed(2) + 'kb';
67+
return (code.length / 1024).toFixed(2) + 'kb';
6868
}
6969

7070
function logError(e) {
71-
// eslint-disable-next-line no-console
72-
console.log(e);
71+
// eslint-disable-next-line no-console
72+
console.log(e);
7373
}
7474

7575
function blue(str) {
76-
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
76+
return '\x1b[1m\x1b[34m' + str + '\x1b[39m\x1b[22m';
7777
}

build/configs.js

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,64 @@ const banner =
1515
const resolve = _path => path.resolve(__dirname, '../', _path);
1616

1717
const configs = {
18-
umdDev: {
19-
input: resolve('src/index.js'),
20-
file: resolve(`dist/${name}.js`),
21-
format: 'umd',
22-
env: 'development',
23-
},
24-
umdProd: {
25-
input: resolve('src/index.js'),
26-
file: resolve(`dist/${name}.min.js`),
27-
format: 'umd',
28-
env: 'production',
29-
},
30-
commonjs: {
31-
input: resolve('src/index.js'),
32-
file: resolve(`dist/${name}.common.js`),
33-
format: 'cjs',
34-
},
35-
esm: {
36-
input: resolve('src/index.esm.js'),
37-
file: resolve(`dist/${name}.esm.js`),
38-
format: 'es',
39-
},
18+
umdDev: {
19+
input: resolve('src/index.js'),
20+
file: resolve(`dist/${name}.js`),
21+
format: 'umd',
22+
env: 'development',
23+
},
24+
umdProd: {
25+
input: resolve('src/index.js'),
26+
file: resolve(`dist/${name}.min.js`),
27+
format: 'umd',
28+
env: 'production',
29+
},
30+
commonjs: {
31+
input: resolve('src/index.js'),
32+
file: resolve(`dist/${name}.common.js`),
33+
format: 'cjs',
34+
},
35+
esm: {
36+
input: resolve('src/index.esm.js'),
37+
file: resolve(`dist/${name}.esm.js`),
38+
format: 'es',
39+
},
4040
};
4141

4242
function genConfig(opts) {
43-
const config = {
44-
input: {
45-
input: opts.input,
46-
plugins: [
47-
replace({
48-
__VERSION__: version,
49-
}),
50-
buble(),
51-
],
52-
},
53-
output: {
54-
banner,
55-
file: opts.file,
56-
format: opts.format,
57-
name: 'AxiosMiddleware',
58-
},
59-
};
43+
const config = {
44+
input: {
45+
input: opts.input,
46+
plugins: [
47+
replace({
48+
__VERSION__: version,
49+
}),
50+
buble(),
51+
],
52+
},
53+
output: {
54+
banner,
55+
file: opts.file,
56+
format: opts.format,
57+
name: 'AxiosMiddleware',
58+
},
59+
};
6060

61-
if (opts.env) {
62-
config.input.plugins.unshift(replace({
63-
'process.env.NODE_ENV': JSON.stringify(opts.env),
64-
}));
65-
}
61+
if (opts.env) {
62+
config.input.plugins.unshift(replace({
63+
'process.env.NODE_ENV': JSON.stringify(opts.env),
64+
}));
65+
}
6666

67-
return config;
67+
return config;
6868
}
6969

7070
function mapValues(obj, fn) {
71-
const res = {};
72-
Object.keys(obj).forEach((key) => {
73-
res[key] = fn(obj[key], key);
74-
});
75-
return res;
71+
const res = {};
72+
Object.keys(obj).forEach((key) => {
73+
res[key] = fn(obj[key], key);
74+
});
75+
return res;
7676
}
7777

7878
module.exports = mapValues(configs, genConfig);

0 commit comments

Comments
 (0)