Skip to content

Commit 135a6b1

Browse files
committed
added prettier
1 parent 26b0d1d commit 135a6b1

32 files changed

+17045
-2417
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ root = true
55
[*]
66
charset = utf-8
77
end_of_line = lf
8-
indent_size = 4
8+
indent_size = 2
99
indent_style = space
1010
insert_final_newline = true
1111
trim_trailing_whitespace = true

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
node_modules
2-
.idea

.prettierignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
vendor
4+
vendors

.prettierrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('prettier-config-nk');

.simple-git-hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// NOTE: once changed, don't forget to run `npx simple-git-hooks`.
22
module.exports = {
3-
"pre-commit": "npx lint-staged",
4-
}
3+
'pre-commit': 'npx lint-staged',
4+
};

.vscode/extensions.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"esbenp.prettier-vscode",
4+
"streetsidesoftware.code-spell-checker",
5+
"editorconfig.editorconfig",
6+
"dbaeumer.vscode-eslint"
7+
]
8+
}

.vscode/settings.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"editor.defaultFormatter": null,
3+
"[javascript]": {
4+
"editor.defaultFormatter": "esbenp.prettier-vscode"
5+
},
6+
"[json]": {
7+
"editor.defaultFormatter": "esbenp.prettier-vscode"
8+
},
9+
"editor.formatOnSave": true
10+
}

babel.config.js

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
module.exports = {
2-
presets: [
3-
'@babel/env',
4-
],
5-
plugins: [
6-
'@babel/plugin-transform-block-scoping',
7-
'@babel/plugin-transform-async-to-generator',
8-
'@babel/plugin-proposal-object-rest-spread',
9-
'@babel/plugin-proposal-class-properties',
10-
],
2+
presets: ['@babel/env'],
3+
plugins: [
4+
'@babel/plugin-transform-block-scoping',
5+
'@babel/plugin-transform-async-to-generator',
6+
'@babel/plugin-proposal-object-rest-spread',
7+
'@babel/plugin-proposal-class-properties',
8+
],
119
};

gulpfile.babel.js

+82-75
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,136 @@
1-
const gulp = require( 'gulp' );
2-
const $ = require( 'gulp-load-plugins' )();
3-
const del = require( 'del' );
4-
const browserSync = require( 'browser-sync' );
5-
const named = require( 'vinyl-named' );
6-
const webpack = require( 'webpack-stream' );
7-
const qunit = require( 'node-qunit-phantomjs' );
8-
const { data } = require( 'json-file' ).read( './package.json' );
1+
/* eslint-disable function-paren-newline */
2+
const gulp = require('gulp');
3+
const $ = require('gulp-load-plugins')();
4+
const del = require('del');
5+
const browserSync = require('browser-sync');
6+
const named = require('vinyl-named');
7+
const webpack = require('webpack-stream');
8+
const qunit = require('node-qunit-phantomjs');
9+
const { data } = require('json-file').read('./package.json');
910

10-
const webpackconfig = require( './webpack.config.js' );
11+
const webpackconfig = require('./webpack.config');
1112

1213
function getMainHeader() {
13-
return `/*!
14+
return `/*!
1415
* Name : Just Another Parallax [Jarallax]
15-
* Version : ${ data.version }
16-
* Author : ${ data.author }
17-
* GitHub : ${ data.homepage }
16+
* Version : ${data.version}
17+
* Author : ${data.author}
18+
* GitHub : ${data.homepage}
1819
*/
1920
`;
2021
}
2122
function getVideoHeader() {
22-
return `/*!
23+
return `/*!
2324
* Name : Video Background Extension for Jarallax
2425
* Version : 1.0.1
25-
* Author : ${ data.author }
26-
* GitHub : ${ data.homepage }
26+
* Author : ${data.author}
27+
* GitHub : ${data.homepage}
2728
*/
2829
`;
2930
}
3031
function getElementHeader() {
31-
return `/*!
32+
return `/*!
3233
* Name : DEPRECATED Elements Extension for Jarallax. Use laxxx instead https://github.com/alexfoxy/laxxx
3334
* Version : 1.0.0
34-
* Author : ${ data.author }
35-
* GitHub : ${ data.homepage }
35+
* Author : ${data.author}
36+
* GitHub : ${data.homepage}
3637
*/
3738
`;
3839
}
3940

4041
/**
4142
* Error Handler for gulp-plumber
4243
*/
43-
function errorHandler( err ) {
44-
// eslint-disable-next-line no-console
45-
console.error( err );
46-
this.emit( 'end' );
44+
function errorHandler(err) {
45+
// eslint-disable-next-line no-console
46+
console.error(err);
47+
this.emit('end');
4748
}
4849

4950
/**
5051
* Clean Task
5152
*/
52-
gulp.task( 'clean', () => del( [ 'dist' ] ) );
53+
gulp.task('clean', () => del(['dist']));
5354

5455
/**
5556
* JS Task
5657
*/
57-
gulp.task( 'js', () => (
58-
gulp.src( [ 'src/*.js', '!src/*.esm.js' ] )
59-
.pipe( $.plumber( { errorHandler } ) )
60-
.pipe( named() )
61-
.pipe( webpack( {
62-
config: webpackconfig,
63-
} ) )
64-
.pipe( $.if( ( file ) => file.path.match( /jarallax.js$/ ), $.header( getMainHeader() ) ) )
65-
.pipe( $.if( ( file ) => file.path.match( /jarallax-video.js$/ ), $.header( getVideoHeader() ) ) )
66-
.pipe( $.if( ( file ) => file.path.match( /jarallax-element.js$/ ), $.header( getElementHeader() ) ) )
67-
.pipe( gulp.dest( 'dist' ) )
68-
.pipe( $.rename( { suffix: '.min' } ) )
69-
.pipe( $.uglify( {
70-
output: {
71-
comments: /^!/,
72-
},
73-
} ) )
74-
.pipe( $.sourcemaps.write( '.' ) )
75-
.pipe( gulp.dest( 'dist' ) )
76-
.pipe( browserSync.stream() )
77-
) );
58+
gulp.task('js', () =>
59+
gulp
60+
.src(['src/*.js', '!src/*.esm.js'])
61+
.pipe($.plumber({ errorHandler }))
62+
.pipe(named())
63+
.pipe(
64+
webpack({
65+
config: webpackconfig,
66+
})
67+
)
68+
.pipe($.if((file) => file.path.match(/jarallax.js$/), $.header(getMainHeader())))
69+
.pipe($.if((file) => file.path.match(/jarallax-video.js$/), $.header(getVideoHeader())))
70+
.pipe($.if((file) => file.path.match(/jarallax-element.js$/), $.header(getElementHeader())))
71+
.pipe(gulp.dest('dist'))
72+
.pipe($.rename({ suffix: '.min' }))
73+
.pipe(
74+
$.uglify({
75+
output: {
76+
comments: /^!/,
77+
},
78+
})
79+
)
80+
.pipe($.sourcemaps.write('.'))
81+
.pipe(gulp.dest('dist'))
82+
.pipe(browserSync.stream())
83+
);
7884

7985
/**
8086
* CSS Task
8187
*/
82-
gulp.task( 'css', () => (
83-
gulp.src( 'src/*.css' )
84-
.pipe( gulp.dest( 'dist' ) )
85-
.pipe( browserSync.stream() )
86-
) );
87-
88+
gulp.task('css', () => gulp.src('src/*.css').pipe(gulp.dest('dist')).pipe(browserSync.stream()));
8889

8990
/**
9091
* BrowserSync Task
9192
*/
92-
gulp.task( 'browser_sync', ( cb ) => {
93-
browserSync.init( {
94-
server: {
95-
baseDir: [ 'demo', './' ],
96-
},
97-
} );
93+
gulp.task('browser_sync', (cb) => {
94+
browserSync.init({
95+
server: {
96+
baseDir: ['demo', './'],
97+
},
98+
});
9899

99-
cb();
100-
} );
100+
cb();
101+
});
101102

102103
/**
103104
* Build (default) Task
104105
*/
105-
gulp.task( 'build', gulp.series( 'clean', [ 'js', 'css' ] ) );
106+
gulp.task('build', gulp.series('clean', ['js', 'css']));
106107

107108
/**
108109
* Watch Task
109110
*/
110-
gulp.task( 'dev', gulp.series( 'build', 'browser_sync', () => {
111-
gulp.watch( 'src/*.js', gulp.series( 'js' ) );
112-
gulp.watch( 'src/*.css', gulp.series( 'css' ) );
113-
} ) );
111+
gulp.task(
112+
'dev',
113+
gulp.series('build', 'browser_sync', () => {
114+
gulp.watch('src/*.js', gulp.series('js'));
115+
gulp.watch('src/*.css', gulp.series('css'));
116+
})
117+
);
114118

115-
gulp.task( 'default', gulp.series( 'build' ) );
119+
gulp.task('default', gulp.series('build'));
116120

117121
/**
118122
* Test Task
119123
*/
120-
gulp.task( 'test', gulp.series( 'build', () => {
121-
qunit( './tests/index.html', {
122-
page: {
123-
viewportSize: { width: 1280, height: 800 },
124-
},
125-
'phantomjs-options': [ '--local-to-remote-url-access=true' ],
126-
// verbose: true,
127-
timeout: 15,
128-
} );
129-
} ) );
124+
gulp.task(
125+
'test',
126+
gulp.series('build', () => {
127+
qunit('./tests/index.html', {
128+
page: {
129+
viewportSize: { width: 1280, height: 800 },
130+
},
131+
'phantomjs-options': ['--local-to-remote-url-access=true'],
132+
// verbose: true,
133+
timeout: 15,
134+
});
135+
})
136+
);

index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
const jarallax = require( './src/jarallax.esm' ).default;
2-
const jarallaxVideo = require( './src/jarallax-video.esm' ).default;
3-
const jarallaxElement = require( './src/jarallax-element.esm' ).default;
1+
const jarallax = require('./src/jarallax.esm').default;
2+
const jarallaxVideo = require('./src/jarallax-video.esm').default;
3+
const jarallaxElement = require('./src/jarallax-element.esm').default;
44

55
module.exports = {
6-
jarallax,
7-
jarallaxElement() {
8-
return jarallaxElement( jarallax );
9-
},
10-
jarallaxVideo() {
11-
return jarallaxVideo( jarallax );
12-
},
6+
jarallax,
7+
jarallaxElement() {
8+
return jarallaxElement(jarallax);
9+
},
10+
jarallaxVideo() {
11+
return jarallaxVideo(jarallax);
12+
},
1313
};

lint-staged.config.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
2-
const micromatch = require( 'micromatch' );
2+
const micromatch = require('micromatch');
33

4-
function excludeVendor( lint ) {
5-
return ( filenames ) => {
6-
const files = micromatch( filenames, '!dist/**/*' );
4+
function excludeVendor(lint) {
5+
return (filenames) => {
6+
const files = micromatch(filenames, '!dist/**/*');
77

8-
if ( files && files.length ) {
9-
return `${ lint } ${ files.join( ' ' ) }`;
10-
}
8+
if (files && files.length) {
9+
return `${lint} ${files.join(' ')}`;
10+
}
1111

12-
return [];
13-
};
12+
return [];
13+
};
1414
}
1515

1616
module.exports = {
17-
'src/**/*.js': excludeVendor( 'eslint' ),
17+
'src/**/*.js': excludeVendor('eslint'),
1818
};

0 commit comments

Comments
 (0)