Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate eslint #299

Merged
merged 5 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
{
"extends": "eslint-config-edx-es5",
"env": {
"amd": true
},
"extends": "@edx/eslint-config",
"globals": {
"setFixtures": true // added globally by jasmine-jquery (bad)
},
"rules": {
"indent": ["error", 4],
"func-names": "off",
"import/no-extraneous-dependencies": "off",
"object-shorthand": "off",
"no-undef": "off",
"no-var": "off",
"one-var": "off",
"prefer-arrow-callback": "off",
"function-paren-newline": "off",
"one-var-declaration-per-line": "off",
"import/no-amd": "off",
"no-param-reassign": "off",
"new-cap": "off"
}
}
7 changes: 4 additions & 3 deletions doc/static/js/ui-toolkit-doc-factory.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// eslint-disable-next-line import/no-dynamic-require
require(
[
'jquery',
'edx-pattern-library/js/modernizr-custom',
'edx-pattern-library/js/afontgarde',
'edx-pattern-library/js/edx-icons'
'edx-pattern-library/js/edx-icons',
],
function() {
function () {
'use strict';
}
},
);
30 changes: 15 additions & 15 deletions gulp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,46 @@ module.exports = {
previewTargetDir: './_preview_site',
testing: {
sources: [
'./src/js/utils/spec-helpers/*.js'
'./src/js/utils/spec-helpers/*.js',
],
output: './doc/_testing',
viewClass: 'testing'
viewClass: 'testing',
},
utilities: {
sources: [
'./src/js/utils/*.js'
'./src/js/utils/*.js',
],
output: './doc/_utilities',
viewClass: 'utility'
viewClass: 'utility',
},
views: {
sources: [
'./src/js/!(utils)/*.js'
'./src/js/!(utils)/*.js',
],
output: './doc/_views',
viewClass: 'view'
viewClass: 'view',
},
browserSync: {
server: {
baseDir: './_site'
baseDir: './_site',
},
ui: {
port: 5000,
weinre: {
port: 5002
}
}
port: 5002,
},
},
},
templates: [
'./doc/*.md',
'./doc/_data/**/*',
'./doc/_layouts/**/*'
'./doc/_layouts/**/*',
],
static: [
'./doc/static/**/*'
'./doc/static/**/*',
],
gitHubPages: {
files: './_site/**/*'
}
}
files: './_site/**/*',
},
},
};
8 changes: 4 additions & 4 deletions gulp/tasks/clean.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict';

var gulp = require('gulp'),
config = require('../config'),
del = require('del');
del = require('del'),
config = require('../config');

gulp.task('clean', function() {
gulp.task('clean', function () {
return del([
// Remove the Jekyll site
config.documentation.targetDir,
Expand All @@ -15,7 +15,7 @@ gulp.task('clean', function() {
// Remove the JSDoc generated markdown
config.documentation.testing.output,
config.documentation.utilities.output,
config.documentation.views.output
config.documentation.views.output,
]);
});

Expand Down
2 changes: 1 addition & 1 deletion gulp/tasks/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var gulp = require('gulp'),
coveralls = require('gulp-coveralls');

gulp.task('coverage', function() {
gulp.task('coverage', function () {
return gulp.src('coverage/**/lcov.info')
.pipe(coveralls());
});
2 changes: 1 addition & 1 deletion gulp/tasks/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ var gulp = require('gulp'),
exports.default = gulp.series(
lint.lint,
test.test,
doc.docBuild
doc.docBuild,
);
48 changes: 24 additions & 24 deletions gulp/tasks/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,55 +12,55 @@ var gulp = require('gulp'),
childProcess = require('child_process'),
browserSync = require('browser-sync'),
runSequence = require('run-sequence'),
config = require('../config').documentation,
generateDoc = require('../utils/generate-doc'),
rename = require('gulp-rename'),
webpack = require('webpack'),
webpackStream = require('webpack-stream'),
ghPages = require('gulp-gh-pages'),
webpackConfig = require('../../webpack.config.js'),
config = require('../config').documentation,
generateDoc = require('../utils/generate-doc'),
webpackConfig = require('../../webpack.config.js'), // eslint-disable-line import/extensions
clean = require('./clean'),
renameAsMarkdown,
generateDocFor;

renameAsMarkdown = function(path) {
renameAsMarkdown = function (path) {
var renamedPath = path;
renamedPath.extname = '.md';
return renamedPath;
};

generateDocFor = function(options) {
generateDocFor = function (options) {
var i, sources,
sourceLength = options.sources.length;
for (i = 0; i < sourceLength; i += 1) {
sources = options.sources[i];
console.log('Generating documentation for ' + sources);
gulp.src(sources, {buffer: false})
console.log(`Generating documentation for ${sources}`);
gulp.src(sources, { buffer: false })
.pipe(generateDoc(options.viewClass))
.pipe(rename(renameAsMarkdown))
.pipe(gulp.dest(options.output));
}
};

gulp.task('doc', function(callback) {
gulp.task('doc', function (callback) {
runSequence(
'doc-build',
'doc-serve',
callback
callback,
);
});

gulp.task('doc-build', function(callback) {
gulp.task('doc-build', function (callback) {
runSequence(
['doc-testing', 'doc-utils', 'doc-views'],
'copy-pattern-library',
'webpack',
'jekyll-build',
callback
callback,
);
});

gulp.task('doc-serve', function(callback) {
gulp.task('doc-serve', function (callback) {
// Run browserSync to serve the doc site
browserSync(config.browserSync);

Expand All @@ -77,53 +77,53 @@ gulp.task('doc-serve', function(callback) {
callback();
});

gulp.task('doc-testing', function(callback) {
gulp.task('doc-testing', function (callback) {
generateDocFor(config.testing);
callback();
});

gulp.task('doc-utils', function(callback) {
gulp.task('doc-utils', function (callback) {
generateDocFor(config.utilities);
callback();
});

gulp.task('doc-views', function(callback) {
gulp.task('doc-views', function (callback) {
generateDocFor(config.views);
callback();
});

gulp.task('copy-pattern-library', function(callback) {
gulp.task('copy-pattern-library', function (callback) {
gulp.src(['./node_modules/edx-pattern-library/pattern-library/**/*'])
.pipe(gulp.dest('doc/public/edx-pattern-library'));
callback();
});

gulp.task('webpack', function() {
return gulp.src('.', {allowEmpty: true})
gulp.task('webpack', function () {
return gulp.src('.', { allowEmpty: true })
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest(webpackConfig.output.path))
.pipe(browserSync.stream());
});

gulp.task('webpack-rebuild', function(callback) {
gulp.task('webpack-rebuild', function (callback) {
runSequence(
'webpack',
'jekyll-rebuild',
callback
callback,
);
});

gulp.task('jekyll-build', function(callback) {
gulp.task('jekyll-build', function (callback) {
childProcess.execSync('jekyll build');
callback();
});

gulp.task('jekyll-rebuild', gulp.series('jekyll-build', function(callback) {
gulp.task('jekyll-rebuild', gulp.series('jekyll-build', function (callback) {
browserSync.reload();
callback();
}));

gulp.task('doc-publish', gulp.series(clean.clean, 'doc-build', function() {
gulp.task('doc-publish', gulp.series(clean.clean, 'doc-build', function () {
return gulp.src(config.gitHubPages.files)
.pipe(ghPages());
}));
Expand All @@ -132,5 +132,5 @@ exports.docBuild = gulp.series(
gulp.parallel('doc-testing', 'doc-utils', 'doc-views'),
'copy-pattern-library',
'webpack',
'jekyll-build'
'jekyll-build',
);
42 changes: 21 additions & 21 deletions gulp/tasks/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,74 +20,74 @@ var gulp = require('gulp'),
webpackStream = require('webpack-stream'),
gitUtils = require('../utils/git-utils'),
config = require('../config').documentation,
webpackConfig = require('../../webpack.config.js'),
webpackConfig = require('../../webpack.config.js'), // eslint-disable-line import/extensions
previewConfigFile = '_tmp_preview_config.yml',
previewDomain = process.env.S3_PREVIEW_DOMAIN;

gulp.task('preview', function(callback) {
gulp.task('preview', function (callback) {
runSequence(
'clean',
'doc-build',
'jekyll-build-preview',
'preview-webpack',
'upload-preview',
'show-preview',
callback
callback,
);
});

gulp.task('jekyll-build-preview', function() {
gulp.task('jekyll-build-preview', function () {
var branch = gitUtils.currentBranch(),
previewBaseUrl = '/' + branch + '/';
previewBaseUrl = `/${branch}/`;
// Create a temporary Jekyll configuration file which specifies the base URL for the preview site
childProcess.execSync(
'echo \'baseurl: ' + previewBaseUrl + '\' > ' + previewConfigFile
`echo 'baseurl: ${previewBaseUrl}' > ${previewConfigFile}`,
);

// Generate the preview version of the site
console.log('Generating preview for branch ' + branch);
console.log(`Generating preview for branch ${branch}`);
childProcess.execSync(
'jekyll build --config _config.yml,' + previewConfigFile + ' --destination ' + config.previewTargetDir
`jekyll build --config _config.yml,${previewConfigFile} --destination ${config.previewTargetDir}`,
);

// Remove the configuration file since it is no longer needed
childProcess.execSync('rm ' + previewConfigFile);
childProcess.execSync(`rm ${previewConfigFile}`);
});

gulp.task('preview-webpack', function() {
var outputPath = config.previewTargetDir + '/public/',
gulp.task('preview-webpack', function () {
var outputPath = `${config.previewTargetDir}/public/`,
branch = gitUtils.currentBranch();
process.env.SITE_ROOT = '/' + branch + '/';
process.env.SITE_ROOT = `/${branch}/`;
return gulp.src('')
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest(outputPath));
});

gulp.task('upload-preview', function() {
gulp.task('upload-preview', function () {
var branch = gitUtils.currentBranch();
if (previewDomain) {
childProcess.execSync(
'aws s3 sync ' + config.previewTargetDir + ' s3://' + previewDomain + '/' + branch
`aws s3 sync ${config.previewTargetDir} s3://${previewDomain}/${branch}`,
);
console.log('Preview site ready at http://' + previewDomain + '/' + branch);
console.log(`Preview site ready at http://${previewDomain}/${branch}`);
} else {
console.log(
'No preview domain specified. Please export environment variable S3_PREVIEW_DOMAIN and try again.'
'No preview domain specified. Please export environment variable S3_PREVIEW_DOMAIN and try again.',
);
}
});

gulp.task('remove-preview', function() {
gulp.task('remove-preview', function () {
var branch = gitUtils.currentBranch();
childProcess.execSync(
'aws s3 rm --recursive s3://' + previewDomain + '/' + branch
`aws s3 rm --recursive s3://${previewDomain}/${branch}`,
);
console.log('Removed preview for branch ' + branch);
console.log(`Removed preview for branch ${branch}`);
});

gulp.task('show-preview', function() {
gulp.task('show-preview', function () {
var branch = gitUtils.currentBranch();
childProcess.execSync(
'open http://' + previewDomain + '/' + branch
`open http://${previewDomain}/${branch}`,
);
});
4 changes: 2 additions & 2 deletions gulp/tasks/test-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var gulp = require('gulp'),
path = require('path'),
configFile = 'test/karma.debug.conf.js';

gulp.task('test-debug', function(callback) {
gulp.task('test-debug', function (callback) {
new karma.Server({
configFile: path.resolve(configFile)
configFile: path.resolve(configFile),
}, callback).start();
});
Loading