Moved grunt-eslint to npm script executing eslint (#10474)
refs #9441 * Updated top-level ids to use const * Removed one layer of indentation * Added .eslintignore files for server and test tasks * Added npm scripts for eslint * Fixed lint command in w/ grunt * Uninstalled grunt-eslint * Added eslint config
This commit is contained in:
parent
6e0409d6db
commit
bdd57b36cf
2
.eslintignore
Normal file
2
.eslintignore
Normal file
@ -0,0 +1,2 @@
|
||||
core/server/public/**/*.js
|
||||
core/server/lib/members/static/auth/**/*.js
|
74
Gruntfile.js
74
Gruntfile.js
@ -8,34 +8,32 @@
|
||||
|
||||
require('./core/server/overrides');
|
||||
|
||||
var config = require('./core/server/config'),
|
||||
urlService = require('./core/server/services/url'),
|
||||
_ = require('lodash'),
|
||||
chalk = require('chalk'),
|
||||
fs = require('fs-extra'),
|
||||
KnexMigrator = require('knex-migrator'),
|
||||
knexMigrator = new KnexMigrator({
|
||||
const config = require('./core/server/config');
|
||||
const urlService = require('./core/server/services/url');
|
||||
const _ = require('lodash');
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs-extra');
|
||||
const KnexMigrator = require('knex-migrator');
|
||||
const knexMigrator = new KnexMigrator({
|
||||
knexMigratorFilePath: config.get('paths:appRoot')
|
||||
}),
|
||||
});
|
||||
|
||||
path = require('path'),
|
||||
const path = require('path');
|
||||
const escapeChar = process.platform.match(/^win/) ? '^' : '\\';
|
||||
const cwd = process.cwd().replace(/( |\(|\))/g, escapeChar + '$1');
|
||||
const buildDirectory = path.resolve(cwd, '.build');
|
||||
const distDirectory = path.resolve(cwd, '.dist');
|
||||
|
||||
escapeChar = process.platform.match(/^win/) ? '^' : '\\',
|
||||
cwd = process.cwd().replace(/( |\(|\))/g, escapeChar + '$1'),
|
||||
buildDirectory = path.resolve(cwd, '.build'),
|
||||
distDirectory = path.resolve(cwd, '.dist'),
|
||||
|
||||
hasBuiltClient = false,
|
||||
logBuildingClient = function (grunt) {
|
||||
let hasBuiltClient = false;
|
||||
const logBuildingClient = function (grunt) {
|
||||
if (!hasBuiltClient) {
|
||||
grunt.log.writeln('Building admin client... (can take ~1min)');
|
||||
setTimeout(logBuildingClient, 5000, grunt);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
// ## Grunt configuration
|
||||
|
||||
configureGrunt = function (grunt) {
|
||||
// ## Grunt configuration
|
||||
const configureGrunt = function (grunt) {
|
||||
// #### Load all grunt tasks
|
||||
//
|
||||
// Find all of the task which start with `grunt-` and load them, rather than explicitly declaring them all
|
||||
@ -109,35 +107,6 @@ var config = require('./core/server/config'),
|
||||
}
|
||||
},
|
||||
|
||||
// ### grunt-eslint
|
||||
// Linting rules, run as part of `grunt validate`. See [grunt validate](#validate) and its subtasks for
|
||||
// more information.
|
||||
eslint: {
|
||||
server: {
|
||||
options: {
|
||||
config: '.eslintrc.json'
|
||||
},
|
||||
src: [
|
||||
'*.js',
|
||||
'core/*.js',
|
||||
'core/server/*.js',
|
||||
'core/server/**/*.js',
|
||||
'!core/server/public/**/*.js',
|
||||
'!core/server/lib/members/static/auth/**/*.js'
|
||||
]
|
||||
},
|
||||
test: {
|
||||
options: {
|
||||
config: './core/test/.eslintrc.json'
|
||||
},
|
||||
src: [
|
||||
'core/test/*.js',
|
||||
'core/test/**/*.js',
|
||||
'!core/test/coverage/**'
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// ### grunt-mocha-cli
|
||||
mochacli: {
|
||||
options: {
|
||||
@ -238,6 +207,9 @@ var config = require('./core/server/config'),
|
||||
// ### grunt-shell
|
||||
// Command line tools where it's easier to run a command directly than configure a grunt plugin
|
||||
shell: {
|
||||
lint: {
|
||||
command: 'yarn lint'
|
||||
},
|
||||
master: {
|
||||
command: function () {
|
||||
var upstream = grunt.option('upstream') || process.env.GHOST_UPSTREAM || 'upstream';
|
||||
@ -498,7 +470,7 @@ var config = require('./core/server/config'),
|
||||
//
|
||||
// `grunt lint` will run the linter
|
||||
grunt.registerTask('lint', 'Run the code style checks for server & tests',
|
||||
['eslint']
|
||||
['shell:lint']
|
||||
);
|
||||
|
||||
// ### test-setup *(utility)(
|
||||
@ -679,6 +651,6 @@ var config = require('./core/server/config'),
|
||||
grunt.task.run(['update_submodules:pinned', 'subgrunt:init', 'clean:built', 'clean:tmp', 'prod', 'clean:release', 'copy:admin_html', 'copy:release', 'compress:release']);
|
||||
}
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
module.exports = configureGrunt;
|
||||
|
1
core/test/.eslintignore
Normal file
1
core/test/.eslintignore
Normal file
@ -0,0 +1 @@
|
||||
core/test/coverage/**
|
@ -26,7 +26,9 @@
|
||||
"test": "grunt validate --verbose",
|
||||
"test:regression": "grunt test-regression --verbose",
|
||||
"setup": "yarn install && knex-migrator init && grunt symlink && grunt init || true",
|
||||
"lint": "grunt lint",
|
||||
"lint:server": "eslint --ignore-path .eslintignore 'core/server/**/*.js' 'core/*.js' '*.js'",
|
||||
"lint:test": "eslint -c core/test/.eslintrc.json --ignore-path core/test/.eslintignore 'core/test/**/*.js'",
|
||||
"lint": "yarn lint:server && yarn lint:test",
|
||||
"fixmodulenotdefined": "yarn cache clean && cd core/client && rm -rf node_modules tmp dist && yarn && cd ../../"
|
||||
},
|
||||
"engines": {
|
||||
@ -127,7 +129,6 @@
|
||||
"grunt-contrib-uglify": "4.0.0",
|
||||
"grunt-contrib-watch": "1.1.0",
|
||||
"grunt-cssnano": "2.1.0",
|
||||
"grunt-eslint": "21.0.0",
|
||||
"grunt-express-server": "0.5.4",
|
||||
"grunt-mocha-cli": "4.0.0",
|
||||
"grunt-mocha-istanbul": "5.0.2",
|
||||
|
@ -1625,7 +1625,7 @@ eslint-visitor-keys@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
|
||||
|
||||
eslint@5.12.1, eslint@^5.0.0:
|
||||
eslint@5.12.1:
|
||||
version "5.12.1"
|
||||
resolved "https://registry.yarnpkg.com/eslint/-/eslint-5.12.1.tgz#5ca9931fb9029d04e7be92b03ce3b58edfac7e3b"
|
||||
dependencies:
|
||||
@ -2565,13 +2565,6 @@ grunt-cssnano@2.1.0:
|
||||
dependencies:
|
||||
cssnano "^3.0.0"
|
||||
|
||||
grunt-eslint@21.0.0:
|
||||
version "21.0.0"
|
||||
resolved "https://registry.yarnpkg.com/grunt-eslint/-/grunt-eslint-21.0.0.tgz#5863f593d328c27ffec2a183319e5ad5380eed9e"
|
||||
dependencies:
|
||||
chalk "^2.1.0"
|
||||
eslint "^5.0.0"
|
||||
|
||||
grunt-express-server@0.5.4:
|
||||
version "0.5.4"
|
||||
resolved "https://registry.yarnpkg.com/grunt-express-server/-/grunt-express-server-0.5.4.tgz#8ce79c335c6cbb9ef50ee1dfaa61942028f43aeb"
|
||||
|
Loading…
Reference in New Issue
Block a user