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(lint): fix global-require eslint rule #2588

Merged
merged 2 commits into from
Dec 25, 2022
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
7 changes: 5 additions & 2 deletions .eslint/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const eqeqeqRule = require('./eqeqeq-rule');
const noExtraParensRule = require('./no-extra-parens-rule');

module.exports = {
rules: {
eqeqeq: require('./eqeqeq-rule'),
'no-extra-parens': require('./no-extra-parens-rule'),
eqeqeq: eqeqeqRule,
'no-extra-parens': noExtraParensRule,
},
configs: {
recommended: {
Expand Down
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ module.exports = {

// TODO rules with a lot of errors to be fixed manually, fix in a separate PR
eqeqeq: 'off', // about 20 errors to be fixed manually
'global-require': 'off', // about 30 errors to be fixed manually
'no-shadow': 'off', // about 220 errors to be fixed manually
'prefer-arrow-callback': 'off', // about 350 errors (all autofixable)
},
Expand Down
9 changes: 6 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ const
gulp = require('gulp'),

// read user config to know what task to load
config = require('./tasks/config/user')
config = require('./tasks/config/user'),

admin = require('./tasks/collections/admin'),
rtl = require('./tasks/collections/rtl')
;

/*******************************
Expand All @@ -30,10 +33,10 @@ require('./tasks/collections/docs')(gulp);
--------------- */

if (config.rtl) {
require('./tasks/collections/rtl')(gulp);
rtl(gulp);
}

/* Admin Tasks */
if (config.admin) {
require('./tasks/collections/admin')(gulp);
admin(gulp);
}
3 changes: 2 additions & 1 deletion tasks/admin/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const
mkdirp = require('mkdirp'),

// admin files
github = require('../../config/admin/github'),
release = require('../../config/admin/release'),
project = require('../../config/project/release'),

Expand All @@ -38,6 +37,8 @@ const
;

module.exports = function (callback) {
const github = require('../../config/admin/github'); // eslint-disable-line global-require
lubber-de marked this conversation as resolved.
Show resolved Hide resolved

let
index = -1,
total = release.components.length,
Expand Down
5 changes: 3 additions & 2 deletions tasks/admin/components/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const
git = require('gulp-git'),

// admin files
github = require('../../config/admin/github'),
release = require('../../config/admin/release'),
project = require('../../config/project/release'),

Expand All @@ -36,6 +35,8 @@ const
;

module.exports = function (callback) {
const github = require('../../config/admin/github'); // eslint-disable-line global-require
lubber-de marked this conversation as resolved.
Show resolved Hide resolved

let
index = -1,
total = release.components.length,
Expand Down Expand Up @@ -73,7 +74,7 @@ module.exports = function (callback) {
: '',

componentPackage = fs.existsSync(outputDirectory + 'package.json')
? require(outputDirectory + 'package.json') // eslint-disable-line import/no-dynamic-require
? require(outputDirectory + 'package.json') // eslint-disable-line global-require, import/no-dynamic-require
: false,

isNewVersion = version && componentPackage.version !== version,
Expand Down
3 changes: 2 additions & 1 deletion tasks/admin/distributions/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const
mkdirp = require('mkdirp'),

// admin files
github = require('../../config/admin/github'),
release = require('../../config/admin/release'),
project = require('../../config/project/release'),

Expand All @@ -38,6 +37,8 @@ const
;

module.exports = function (callback) {
const github = require('../../config/admin/github'); // eslint-disable-line global-require
lubber-de marked this conversation as resolved.
Show resolved Hide resolved

let
index = -1,
total = release.distributions.length,
Expand Down
5 changes: 3 additions & 2 deletions tasks/admin/distributions/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const
git = require('gulp-git'),

// admin files
github = require('../../config/admin/github'),
release = require('../../config/admin/release'),
project = require('../../config/project/release'),

Expand All @@ -36,6 +35,8 @@ const
;

module.exports = function (callback) {
const github = require('../../config/admin/github'); // eslint-disable-line global-require
lubber-de marked this conversation as resolved.
Show resolved Hide resolved

let
index = -1,
total = release.distributions.length,
Expand Down Expand Up @@ -69,7 +70,7 @@ module.exports = function (callback) {
: '',

distributionPackage = fs.existsSync(outputDirectory + 'package.json')
? require(outputDirectory + 'package.json') // eslint-disable-line import/no-dynamic-require
? require(outputDirectory + 'package.json') // eslint-disable-line global-require, import/no-dynamic-require
: false,

isNewVersion = version && distributionPackage.version !== version,
Expand Down
32 changes: 16 additions & 16 deletions tasks/collections/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
* Admin Task Collection
*******************************/

const
// less/css distributions
initComponents = require('../admin/components/init'),
createComponents = require('../admin/components/create'),
updateComponents = require('../admin/components/update'),

// single component releases
initDistributions = require('../admin/distributions/init'),
createDistributions = require('../admin/distributions/create'),
updateDistributions = require('../admin/distributions/update'),

release = require('../admin/release'),
publish = require('../admin/publish'),
register = require('../admin/register')
;

/*
This are tasks to be run by project maintainers
- Creating Component Repos
Expand All @@ -14,22 +30,6 @@
*******************************/

module.exports = function (gulp) {
const
// less/css distributions
initComponents = require('../admin/components/init'),
createComponents = require('../admin/components/create'),
updateComponents = require('../admin/components/update'),

// single component releases
initDistributions = require('../admin/distributions/init'),
createDistributions = require('../admin/distributions/create'),
updateDistributions = require('../admin/distributions/update'),

release = require('../admin/release'),
publish = require('../admin/publish'),
register = require('../admin/register')
;

/* Release */
gulp.task('init distributions', initDistributions);
gulp.task('init distributions').description = 'Grabs each component from GitHub';
Expand Down
17 changes: 8 additions & 9 deletions tasks/collections/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* Define Build Sub-Tasks
*******************************/

module.exports = function (gulp) {
// build sub-tasks
const
watch = require('../watch'),
const watch = require('../watch'),

build = require('../build'),
buildJS = require('../build/javascript'),
buildCSS = require('../build/css'),
buildAssets = require('../build/assets')
;
// build sub-tasks
build = require('../build'),
buildJS = require('../build/javascript'),
buildCSS = require('../build/css'),
buildAssets = require('../build/assets')
;

module.exports = function (gulp) {
gulp.task('watch', watch);
gulp.task('watch').description = 'Watch for site/theme changes';

Expand Down
11 changes: 5 additions & 6 deletions tasks/collections/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* Define Docs Sub-Tasks
*******************************/

// docs tasks
const buildDocs = require('../docs/build'),
serveDocs = require('../docs/serve')
;

/*
Lets you serve files to a local documentation instance
https://github.com/fomantic/Fomantic-UI-Docs/
*/
module.exports = function (gulp) {
let
// docs tasks
serveDocs = require('../docs/serve'),
buildDocs = require('../docs/build')
;

gulp.task('serve-docs', serveDocs);
gulp.task('serve-docs').description = 'Serve file changes to SUI Docs';

Expand Down
11 changes: 5 additions & 6 deletions tasks/collections/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@
* Define Install Sub-Tasks
*******************************/

// docs tasks
const install = require('../install'),
checkInstall = require('../check-install')
;

/*
Lets you serve files to a local documentation instance
https://github.com/fomantic/Fomantic-UI-Docs/
*/
module.exports = function (gulp) {
let
// docs tasks
install = require('../install'),
checkInstall = require('../check-install')
;

gulp.task('install', install);
gulp.task('install').description = 'Runs set-up';

Expand Down
10 changes: 4 additions & 6 deletions tasks/collections/rtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
* Define RTL Sub-Tasks
*******************************/

module.exports = function (gulp) {
// rtl
const
buildRTL = require('../rtl/build'),
watchRTL = require('../rtl/watch')
;
const buildRTL = require('../rtl/build'),
watchRTL = require('../rtl/watch')
;

module.exports = function (gulp) {
gulp.task('watch-rtl', watchRTL);
gulp.task('watch-rtl').description = 'DEPRECATED - use \'watch\' instead - Watch files as RTL';

Expand Down
9 changes: 4 additions & 5 deletions tasks/collections/various.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
* Define Various Sub-Tasks
*******************************/

const clean = require('../clean'),
version = require('../version')
;

/*
Lets you serve files to a local documentation instance
https://github.com/fomantic/Fomantic-UI-Docs/
*/
module.exports = function (gulp) {
let
clean = require('../clean'),
version = require('../version')
;

gulp.task('clean', clean);
gulp.task('clean').description = 'Clean dist folder';

Expand Down
6 changes: 4 additions & 2 deletions tasks/config/npm/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const
gulp = require('gulp'),

// read user config to know what task to load
config = require('./tasks/config/user') // eslint-disable-line import/extensions
config = require('./tasks/config/user'), // eslint-disable-line import/extensions

rtl = require('./tasks/collections/rtl') // eslint-disable-line import/extensions
;

/*******************************
Expand All @@ -30,5 +32,5 @@ require('./tasks/collections/docs')(gulp); // eslint-disable-line import/extensi
--------------- */

if (config.rtl) {
require('./tasks/collections/rtl')(gulp); // eslint-disable-line import/extensions
rtl(gulp);
}
2 changes: 1 addition & 1 deletion tasks/config/project/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let
config = requireDotFile('semantic.json', process.cwd());

try {
npmPackage = require('../../../package.json');
npmPackage = require('../../../package.json'); // eslint-disable-line global-require
} catch (error) {
// generate fake package
npmPackage = {
Expand Down
6 changes: 4 additions & 2 deletions tasks/rtl/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
* Build Task
*******************************/

const gulp = require('gulp');
const gulp = require('gulp'),
build = require('../build')
;

// RTL builds are now handled by the default build process
module.exports = function (callback) {
gulp.series(require('../build'))(callback);
gulp.series(build)(callback);
};
7 changes: 5 additions & 2 deletions tasks/rtl/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* Watch Task
*******************************/

const gulp = require('gulp');
const
gulp = require('gulp'),
watch = require('../watch')
;

// RTL watch are now handled by the default watch process
module.exports = function (callback) {
gulp.series(require('../watch'))(callback);
gulp.series(watch)(callback);
};