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

Update dependencies #81

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
Empty file modified .commitlintrc.yml
100644 → 100755
Empty file.
Empty file modified .editorconfig
100644 → 100755
Empty file.
Empty file modified .eslintrc
100644 → 100755
Empty file.
Empty file modified .gitattributes
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/bug_report.md
100644 → 100755
Empty file.
Empty file modified .github/ISSUE_TEMPLATE/feature_request.md
100644 → 100755
Empty file.
Empty file modified .github/PULL_REQUEST_TEMPLATE.md
100644 → 100755
Empty file.
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified .npmrc
100644 → 100755
Empty file.
Empty file modified .prettierignore
100644 → 100755
Empty file.
Empty file modified .prettierrc
100644 → 100755
Empty file.
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified __tests__/core/built-in/rules/package-json-properties.test.js
100644 → 100755
Empty file.
Empty file modified __tests__/core/built-in/rules/root-files.test.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion __tests__/core/config.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const path = require('path');
const cosmiconfig = require('cosmiconfig');
const { cosmiconfig } = require('cosmiconfig');
const Config = require('../../src/core/config/config');
const ConfigFileValidationError = require('../../src/core/errors/exceptions/config-file-validation-error');

Expand Down
2 changes: 1 addition & 1 deletion __tests__/core/engine.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const cosmiconfig = require('cosmiconfig');
const { cosmiconfig } = require('cosmiconfig');

const AdviserRule = require('../../src/core/external/rule');

Expand Down
583 changes: 574 additions & 9 deletions __tests__/integration/package-lock.json
100644 → 100755

Large diffs are not rendered by default.

Empty file modified docs/README.md
100644 → 100755
Empty file.
Empty file modified docs/cli.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/logo.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docs/rules/package-json-properties.md
100644 → 100755
Empty file.
Empty file modified docs/rules/root-files.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/api.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/available-arguments.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/built-in-rules.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/configuration.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/contribute-core.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/create-plugins.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/create-rules.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/installation.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/plugins.md
100644 → 100755
Empty file.
Empty file modified docusaurus/docs/testing.md
100644 → 100755
Empty file.
Empty file modified docusaurus/website/package-lock.json
100644 → 100755
Empty file.
Empty file modified docusaurus/website/package.json
100644 → 100755
Empty file.
Empty file modified docusaurus/website/siteConfig.js
100644 → 100755
Empty file.
Empty file modified docusaurus/website/static/img/canada.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/cli.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/configuration-file.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/favicon.ico
100644 → 100755
Empty file.
Empty file modified docusaurus/website/static/img/full-logo-dark-bg.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/full-logo-white-bg.png
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/heart.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/install.gif
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/jam3-logo.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/social-logo.jpg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/undraw_building_blocks_n0nc.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/undraw_options_2fvi.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file modified docusaurus/website/static/img/undraw_version_control_9bpv.svg
100644 → 100755
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12,508 changes: 6,693 additions & 5,815 deletions package-lock.json
100644 → 100755

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@
},
"license": "MIT",
"devDependencies": {
"@commitlint/cli": "8.1.0",
"@commitlint/config-conventional": "7.5.0",
"audit-ci": "1.3.1",
"babel-eslint": "10.0.1",
"envinfo": "7.0.0",
"eslint": "5.16.0",
"eslint-config-jam3": "2.0.0",
"eslint-config-prettier": "4.3.0",
"eslint-config-standard": "12.0.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jest": "22.2.2",
"eslint-plugin-node": "8.0.1",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-standard": "4.0.0",
"husky": "2.1.0",
"jest": "24.7.1",
"lint-staged": "8.1.5",
"prettier": "1.16.4",
"standard-version": "7.0.1"
"@commitlint/cli": "12.1.4",
"@commitlint/config-conventional": "12.1.4",
"audit-ci": "4.1.0",
"babel-eslint": "10.1.0",
"envinfo": "7.8.1",
"eslint": "7.30.0",
"eslint-config-jam3": "2.0.1",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-promise": "5.1.0",
"eslint-plugin-standard": "5.0.0",
"husky": "7.0.1",
"jest": "27.0.6",
"lint-staged": "11.0.0",
"prettier": "2.3.2",
"standard-version": "9.3.0"
},
"jest": {
"collectCoverage": true,
Expand Down Expand Up @@ -71,19 +71,19 @@
}
},
"dependencies": {
"ajv": "6.10.0",
"async": "3.0.0",
"chalk": "2.4.2",
"cosmiconfig": "5.2.1",
"debug": "4.1.1",
"ajv": "8.6.1",
"async": "3.2.0",
"chalk": "4.1.1",
"cosmiconfig": "7.0.0",
"debug": "4.3.2",
"hyperlinker": "1.0.0",
"log-symbols": "3.0.0",
"optionator": "0.8.2",
"ora": "3.4.0",
"log-symbols": "4.1.0",
"optionator": "0.9.1",
"ora": "5.4.1",
"pluralize": "8.0.0",
"requireindex": "1.2.0",
"strip-ansi": "5.2.0",
"supports-hyperlinks": "2.0.0",
"strip-ansi": "6.0.0",
"supports-hyperlinks": "2.2.0",
"text-table": "0.2.0"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/bin/adviser.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ process.once('uncaughtException', errorHandler.onError);
if (isInitEnabled) {
init.createTemplate();
} else {
cli.execute(process.argv, exitCode => {
cli.execute(process.argv, (exitCode) => {
process.exitCode = exitCode;
});
}
22 changes: 11 additions & 11 deletions src/cli/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const Engine = require('../core/engine');
const Formatter = require('../core/formatters/formatter');
const Spinner = require('./spinner');
const EVENTS = require('../core/constants/events');

const options = require('./options');
const logger = require('../utils/logger');
const packageInfo = require('../package-info');
Expand Down Expand Up @@ -57,12 +56,12 @@ class CLI {
debug(`Parsing CLI arguments ${JSON.stringify(currentOptions)} for the engine`);
const engineOptions = this._prepareEngineOptions(currentOptions);

const config = new Config(engineOptions['configFile'] || engineOptions.cwd);
const config = new Config(engineOptions.configFile || engineOptions.cwd);
debug(`Engine called with the parameters ${JSON.stringify(engineOptions)}`);
const engine = new Engine(config, engineOptions);

if (!currentOptions.debug) {
console.log(`Adviser v${packageInfo.getVersion()}\n`);
console.log(`Adviser v${packageInfo.getVersion()}\n`); // eslint-disable-line

const spinner = new Spinner();

Expand All @@ -87,7 +86,7 @@ class CLI {
if (issues.items.length > 0) {
this.printResults(issues, processedRules, {
format: engineOptions.outputFormat,
verbose: currentOptions.verbose
verbose: currentOptions.verbose,
});

errorCode = 2;
Expand All @@ -100,19 +99,20 @@ class CLI {
if (currentOptions.verbose) {
if (issues.items.length > 0) {
this.printResults(issues, processedRules, {
format: 'verbose'
format: 'verbose',
});
}

if (processedRules.length > 0) {
this.printResults(issues, processedRules, {
format: 'summary'
format: 'summary',
});
}
} else {
const verboseResults = issues.items.filter(result => result.params.verbose !== undefined);
const verboseResults = issues.items.filter((result) => result.params.verbose !== undefined);

if (verboseResults.length >= 1) {
// eslint-disable-next-line
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would saw maybe we disable the eslint rule for console commands since this library makes a few instead of disabling it on lines?

console.log(
`Some rules reported a verbose result, call Adviser with ${chalk.gray('--verbose')} for more details.\n`
);
Expand All @@ -121,7 +121,7 @@ class CLI {

callback(errorCode);
})
.catch(error => {
.catch((error) => {
logger.error('Some rules has failed the run', error);
callback(errorCode);
});
Expand Down Expand Up @@ -155,11 +155,11 @@ class CLI {
const engineOptions = {
outputFormat: 'base',
cwd: process.cwd(),
verboseMode: cliOptions['verbose'] || false
verboseMode: cliOptions.verbose || false,
};

cliOptions.config && (engineOptions['configFile'] = cliOptions.config);
cliOptions.tags && (engineOptions['tags'] = cliOptions.tags);
cliOptions.config && (engineOptions.configFile = cliOptions.config);
cliOptions.tags && (engineOptions.tags = cliOptions.tags);

return engineOptions;
}
Expand Down
5 changes: 3 additions & 2 deletions src/cli/init.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';

const fs = require('fs');

const chalk = require('chalk');
const debug = require('debug')('adviser:cli-init');

Expand All @@ -18,7 +19,7 @@ const logger = require('../utils/logger');
function createTemplate() {
debug(`Creating file .adviserrc in the path ${process.cwd()}`);
const adviserInitConfigFileTemplate = require('../core/config/data/init-config-file-template.json');
fs.writeFile('.adviserrc', JSON.stringify(adviserInitConfigFileTemplate, null, 4), function(err) {
fs.writeFile('.adviserrc', JSON.stringify(adviserInitConfigFileTemplate, null, 4), function (err) {
if (err) throw err;
logger.info(
`Adviser created a base configuration file called ${chalk.yellow('.adviserrc')} with the following structure:`
Expand All @@ -29,5 +30,5 @@ function createTemplate() {
}

module.exports = {
createTemplate
createTemplate,
};
32 changes: 16 additions & 16 deletions src/cli/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,67 @@ module.exports = optionator({
prepend: `adviser ${chalk.red('[options]')}`,
defaults: {
concatRepeatedArrays: true,
defaults: Object
defaults: Object,
},
options: [
{
heading: chalk.yellow('Basic configuration')
heading: chalk.yellow('Basic configuration'),
},
{
option: 'config',
alias: 'c',
type: 'Path',
description: chalk.cyan('Specify config file path')
description: chalk.cyan('Specify config file path'),
},
{
heading: chalk.yellow('Output')
heading: chalk.yellow('Output'),
},
{
option: 'verbose',
type: 'Boolean',
description: chalk.cyan('More information on runtime')
description: chalk.cyan('More information on runtime'),
},
{
heading: chalk.yellow('Warnings')
heading: chalk.yellow('Warnings'),
},
{
option: 'quiet',
type: 'Boolean',
description: chalk.cyan('Report errors only - default: false')
description: chalk.cyan('Report errors only - default: false'),
},
{
heading: chalk.yellow('Funcionality')
heading: chalk.yellow('Funcionality'),
},
{
option: 'tags',
alias: 't',
type: '[String]',
description: chalk.cyan('Specify list of tags; e.g fast,perf,pkg')
description: chalk.cyan('Specify list of tags; e.g fast,perf,pkg'),
},
{
heading: chalk.yellow('Miscellaneous')
heading: chalk.yellow('Miscellaneous'),
},
{
option: 'init',
type: 'Boolean',
description: chalk.cyan('Run config initialization wizard')
description: chalk.cyan('Run config initialization wizard'),
},
{
option: 'debug',
type: 'Boolean',
description: chalk.cyan('Output debugging information')
description: chalk.cyan('Output debugging information'),
},
{
option: 'help',
alias: 'h',
type: 'Boolean',
description: chalk.cyan('Show help')
description: chalk.cyan('Show help'),
},
{
option: 'version',
alias: 'v',
type: 'Boolean',
description: chalk.cyan('Output the version number')
}
]
description: chalk.cyan('Output the version number'),
},
],
});
2 changes: 1 addition & 1 deletion src/cli/spinner.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Spinner {
if (stopState) {
this.spinner.stopAndPersist({
symbol: logSymbols.success,
text: stopState
text: stopState,
});
}

Expand Down
25 changes: 15 additions & 10 deletions src/core/built-in/rules/package-json-properties.js
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict';

const path = require('path');

const pluralize = require('pluralize');

const Rule = require('../../external/rule');
Expand All @@ -10,46 +11,50 @@ class PackageJsonProperties extends Rule {
constructor(context) {
super(context);

if (!this.context.options['required'] && !this.context.options['blacklist']) {
if (!this.context.options.required && !this.context.options.blacklist) {
throw new Error(`The rule must have at least one option, "required" or "blacklist"`);
}

if (this.context.options['required'] && !Array.isArray(this.context.options['required'])) {
if (this.context.options.required && !Array.isArray(this.context.options.required)) {
throw new Error(`Wrong "required" argument, an array is expected`);
}

if (this.context.options['blacklist'] && !Array.isArray(this.context.options['blacklist'])) {
if (this.context.options.blacklist && !Array.isArray(this.context.options.blacklist)) {
throw new Error(`Wrong "blacklist" argument, an array is expected`);
}
}

run(sandbox) {
const packagejson = this._getPackageJsonPath();

const requiredProps = this.context.options['required'];
const requiredProps = this.context.options.required;
if (requiredProps) {
const missingProps = requiredProps.filter(requiredProp => !packagejson.hasOwnProperty(requiredProp));
const missingProps = requiredProps.filter(
(requiredProp) => !Object.prototype.hasOwnProperty.call(packagejson, requiredProp)
);

if (missingProps.length > 0) {
sandbox.report({
message: `The package.json is missing the required ${pluralize(
'property',
missingProps.length
)}: ${missingProps.join(', ')}`
)}: ${missingProps.join(', ')}`,
});
}
}

const blacklistedProps = this.context.options['blacklist'];
const blacklistedProps = this.context.options.blacklist;
if (blacklistedProps) {
const notAllowedProps = blacklistedProps.filter(blacklistedProp => packagejson.hasOwnProperty(blacklistedProp));
const notAllowedProps = blacklistedProps.filter((blacklistedProp) =>
Object.prototype.hasOwnProperty.call(packagejson, blacklistedProp)
);

if (notAllowedProps.length > 0) {
sandbox.report({
message: `The package.json includes the restricted ${pluralize(
'property',
notAllowedProps.length
)}: ${notAllowedProps.join(', ')}`
)}: ${notAllowedProps.join(', ')}`,
});
}
}
Expand All @@ -73,7 +78,7 @@ PackageJsonProperties.meta = {
description: 'Property restrictions over package.json',
recommended: true,
docsUrl: docs.getURL('package-json-properties'),
tags: ['quick', 'packagejson']
tags: ['quick', 'packagejson'],
};

module.exports = PackageJsonProperties;
Loading