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

chore: Remove the deprecated flag #450

Merged
merged 2 commits into from Nov 1, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions README.md
Expand Up @@ -79,12 +79,6 @@ All of the arguments are optional:

`--parsers`, `--detectors` and `--specials`: These arguments are for advanced usage. They provide an easy way to customize the file parser and dependency detection. Check [the pluggable design document](https://github.com/depcheck/depcheck/blob/master/doc/pluggable-design.md) for more information.

### Deprecated arguments

The following arguments are deprecated and will be removed in next major version:

`--dev=[true|false]`: *[DEPRECATED]* It leads a wrong result for missing dependencies when it is `false`. This option will be enforced to `true` in next major version. The corresponding API option `withoutDev` is deprecated too.

## API

Similar options are provided to `depcheck` function for programming:
Expand All @@ -93,7 +87,6 @@ Similar options are provided to `depcheck` function for programming:
import depcheck from 'depcheck';

const options = {
withoutDev: false, // [DEPRECATED] check against devDependencies
ignoreBinPackage: false, // ignore the packages with bin entry
skipMissing: false, // skip calculation of missing dependencies
ignoreDirs: [ // folder with these names will be ignored
Expand Down
4 changes: 2 additions & 2 deletions doc/pluggable-design.md
Expand Up @@ -148,7 +148,7 @@ var opts = {

### Implement Custom Detector

Detector is a JavaScript function accepts an AST node and package dependencies (including devDependencies unless `withoutDev` option is `true`) and returns an array of dependency package names.
Detector is a JavaScript function accepts an AST node and package dependencies and returns an array of dependency package names.

The following code snippet is the ES6 `import` declaration detector:

Expand Down Expand Up @@ -228,7 +228,7 @@ As seen from the code snippet, there are four parameters passed into the *specia

- Content, same as normal parser, the file content.
- FilePath, the file path, use `path.basename` to retrieve the file name.
- Deps, an array containing the package dependencies (including devDependencies unless `withoutDev` option is `true`).
- Deps, an array containing the package dependencies.
- Dir, the checking root directory passed from API or CLI.

Pay attention that, special parser will match **all** files, please do file path or file name matching **by yourself** and only parse content only when necessary. In regards to the returning value, both AST node or plain string array are OK as a normal parser.
Expand Down
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -50,7 +50,6 @@
"@babel/parser": "^7.6.4",
"@babel/traverse": "^7.6.3",
"builtin-modules": "^3.0.0",
"deprecate": "^1.1.1",
"deps-regex": "^0.1.4",
"js-yaml": "^3.4.2",
"lodash": "^4.17.15",
Expand Down
16 changes: 0 additions & 16 deletions src/cli.js
Expand Up @@ -2,7 +2,6 @@ import fs from 'fs';
import path from 'path';
import yargs from 'yargs';
import lodash from 'lodash';
import deprecate from 'deprecate';

import depcheck from './index';
import { version } from '../package.json';
Expand Down Expand Up @@ -68,17 +67,6 @@ function print(result, log, json, rootDir) {
return result;
}

function checkDeprecation(argv) {
if (argv.dev === false) {
deprecate(
'depcheck',
'The option `dev` is deprecated. It leads a wrong result for missing dependencies'
+ ' when it is `false`. This option will be removed and enforced to `true` in next'
+ ' major version.',
);
}
}

export default function cli(args, log, error, exit) {
const opt = yargs(args)
.usage('Usage: $0 [DIRECTORY]')
Expand All @@ -92,7 +80,6 @@ export default function cli(args, log, error, exit) {
'ignore-bin-package': false,
'skip-missing': false,
})
.describe('dev', '[DEPRECATED] Check on devDependecies')
.describe('ignore-bin-package', 'Ignore package with bin entry')
.describe('skip-missing', 'Skip calculation of missing dependencies')
.describe('json', 'Output results to JSON')
Expand All @@ -104,8 +91,6 @@ export default function cli(args, log, error, exit) {
.version('version', 'Show version number', version)
.help('help', 'Show this help message');

checkDeprecation(opt.argv);

const dir = opt.argv._[0] || '.';
const rootDir = path.resolve(dir);

Expand All @@ -115,7 +100,6 @@ export default function cli(args, log, error, exit) {
`Path ${dir} does not contain a package.json file`,
))
.then(() => depcheck(rootDir, {
withoutDev: !opt.argv.dev,
ignoreBinPackage: opt.argv.ignoreBinPackage,
ignoreMatches: (opt.argv.ignores || '').split(','),
ignoreDirs: (opt.argv.ignoreDirs || '').split(','),
Expand Down
1 change: 0 additions & 1 deletion src/constants.js
Expand Up @@ -19,7 +19,6 @@ export const availableDetectors = constructComponent(component, 'detector');
export const availableSpecials = constructComponent(component, 'special');

export const defaultOptions = {
withoutDev: false,
ignoreBinPackage: false,
ignoreMatches: [
],
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Expand Up @@ -40,7 +40,6 @@ export default function depcheck(rootDir, options, callback) {
const getOption = (key) =>
(lodash.isUndefined(options[key]) ? defaultOptions[key] : options[key]);

const withoutDev = getOption('withoutDev');
const ignoreBinPackage = getOption('ignoreBinPackage');
const ignoreMatches = getOption('ignoreMatches');
const ignoreDirs = lodash.union(defaultOptions.ignoreDirs, options.ignoreDirs);
Expand All @@ -54,7 +53,7 @@ export default function depcheck(rootDir, options, callback) {

const metadata = options.package || readJSON(path.join(rootDir, 'package.json'));
const dependencies = metadata.dependencies || {};
const devDependencies = !withoutDev && metadata.devDependencies ? metadata.devDependencies : {};
const devDependencies = metadata.devDependencies ? metadata.devDependencies : {};
const peerDeps = Object.keys(metadata.peerDependencies || {});
const optionalDeps = Object.keys(metadata.optionalDependencies || {});
const deps = filterDependencies(rootDir, ignoreBinPackage, ignoreMatches, dependencies);
Expand Down
4 changes: 0 additions & 4 deletions test/cli.js
Expand Up @@ -14,10 +14,6 @@ function makeArgv(module, options) {
argv.push('--json');
}

if (options.withoutDev) {
argv.push('--dev=false');
}

if (typeof options.ignoreBinPackage !== 'undefined') {
argv.push(`--ignore-bin-package=${options.ignoreBinPackage}`);
}
Expand Down
14 changes: 0 additions & 14 deletions test/spec.js
Expand Up @@ -6,7 +6,6 @@ export default [
name: 'detect missing module for dynamic import() when missing in package.json',
module: 'import_function_missing',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -23,7 +22,6 @@ export default [
name: 'find module for dynamic import() when present',
module: 'import_function',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -38,7 +36,6 @@ export default [
name: 'find module for dynamic import() with magic Webpack comment',
module: 'import_function_webpack',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -53,7 +50,6 @@ export default [
name: 'missing module for require.resolve when missing in package.json',
module: 'require_resolve_missing',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -70,7 +66,6 @@ export default [
name: 'find module for require.resolve when present',
module: 'require_resolve',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -85,7 +80,6 @@ export default [
name: 'find unused dependencies',
module: 'bad',
options: {
withoutDev: true,
},
expected: {
dependencies: ['optimist'],
Expand Down Expand Up @@ -125,7 +119,6 @@ export default [
name: 'find all dependencies',
module: 'good',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -143,7 +136,6 @@ export default [
name: 'find all dependencies in ES6 files',
module: 'good_es6',
options: {
withoutDev: true,
},
expected: {
dependencies: ['unsupported-syntax'],
Expand Down Expand Up @@ -171,7 +163,6 @@ export default [
name: 'find all dependencies gatsby',
module: 'gatsby',
options: {
withoutDev: true,
},
expected: {
dependencies: ['gatsby-plugin-react-helmet', 'gatsby-plugin-sass'],
Expand All @@ -185,7 +176,6 @@ export default [
name: 'recognize experimental ES7 syntax enabled in Babel by default',
module: 'good_es7',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -200,7 +190,6 @@ export default [
name: 'support flow syntax in ES7 modules',
module: 'good_es7_flow',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand Down Expand Up @@ -319,7 +308,6 @@ export default [
name: 'find grunt dependencies',
module: 'grunt',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -334,7 +322,6 @@ export default [
name: 'find grunt task dependencies',
module: 'grunt-tasks',
options: {
withoutDev: true,
},
expected: {
dependencies: [],
Expand All @@ -349,7 +336,6 @@ export default [
name: 'find unused package in devDependencies',
module: 'dev',
options: {
withoutDev: false,
},
expected: {
dependencies: [],
Expand Down