diff --git a/README.md b/README.md index 2f0c55bc..63f5eb62 100644 --- a/README.md +++ b/README.md @@ -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: @@ -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 diff --git a/doc/pluggable-design.md b/doc/pluggable-design.md index 68b3e60f..83cffb39 100644 --- a/doc/pluggable-design.md +++ b/doc/pluggable-design.md @@ -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: @@ -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. diff --git a/package-lock.json b/package-lock.json index 07fd7f39..51ece248 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2072,11 +2072,6 @@ } } }, - "deprecate": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/deprecate/-/deprecate-1.1.1.tgz", - "integrity": "sha512-ZGDXefq1xknT292LnorMY5s8UVU08/WKdzDZCUT6t9JzsiMSP4uzUhgpqugffNVcT5WC6wMBiSQ+LFjlv3v7iQ==" - }, "deps-regex": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deps-regex/-/deps-regex-0.1.4.tgz", diff --git a/package.json b/package.json index 982f1800..8bacbe12 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/cli.js b/src/cli.js index 51ab6317..d9dca006 100755 --- a/src/cli.js +++ b/src/cli.js @@ -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'; @@ -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]') @@ -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') @@ -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); @@ -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(','), diff --git a/src/constants.js b/src/constants.js index a60b7ad7..5efb9f3b 100644 --- a/src/constants.js +++ b/src/constants.js @@ -19,7 +19,6 @@ export const availableDetectors = constructComponent(component, 'detector'); export const availableSpecials = constructComponent(component, 'special'); export const defaultOptions = { - withoutDev: false, ignoreBinPackage: false, ignoreMatches: [ ], diff --git a/src/index.js b/src/index.js index 37c3b6a4..5b723903 100644 --- a/src/index.js +++ b/src/index.js @@ -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); @@ -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); diff --git a/test/cli.js b/test/cli.js index 4d95bfaa..ff107895 100644 --- a/test/cli.js +++ b/test/cli.js @@ -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}`); } diff --git a/test/spec.js b/test/spec.js index 5e830474..6b1186f7 100644 --- a/test/spec.js +++ b/test/spec.js @@ -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: [], @@ -23,7 +22,6 @@ export default [ name: 'find module for dynamic import() when present', module: 'import_function', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -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: [], @@ -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: [], @@ -70,7 +66,6 @@ export default [ name: 'find module for require.resolve when present', module: 'require_resolve', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -85,7 +80,6 @@ export default [ name: 'find unused dependencies', module: 'bad', options: { - withoutDev: true, }, expected: { dependencies: ['optimist'], @@ -125,7 +119,6 @@ export default [ name: 'find all dependencies', module: 'good', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -143,7 +136,6 @@ export default [ name: 'find all dependencies in ES6 files', module: 'good_es6', options: { - withoutDev: true, }, expected: { dependencies: ['unsupported-syntax'], @@ -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'], @@ -185,7 +176,6 @@ export default [ name: 'recognize experimental ES7 syntax enabled in Babel by default', module: 'good_es7', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -200,7 +190,6 @@ export default [ name: 'support flow syntax in ES7 modules', module: 'good_es7_flow', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -319,7 +308,6 @@ export default [ name: 'find grunt dependencies', module: 'grunt', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -334,7 +322,6 @@ export default [ name: 'find grunt task dependencies', module: 'grunt-tasks', options: { - withoutDev: true, }, expected: { dependencies: [], @@ -349,7 +336,6 @@ export default [ name: 'find unused package in devDependencies', module: 'dev', options: { - withoutDev: false, }, expected: { dependencies: [],