lib/config.js
function readConfigFromFile(filePath) {
  var config = {};

  if (isFilePath(filePath)) {
    try {
      config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {};
    } catch (e) {
      e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message;
      throw e;
    }

    if (path.basename(filePath) === PACKAGE_CONFIG_FILENAME) {
      config = config[PACKAGE_CONFIG_FIELD_NAME] || {};
    }

  } else {

        // it's a package

    if (filePath.charAt(0) === '@') {
            // it's a scoped package

            // package name is 'nplint-config', or just a username
      var scopedPackageShortcutRegex = /^(@[^\/]+)(?:\/(?:eslint-config)?)?$/;
      if (scopedPackageShortcutRegex.test(filePath)) {
        filePath = filePath.replace(scopedPackageShortcutRegex, '$1/nplint-config');
      } else if (filePath.split('/')[1].indexOf('eslint-config-') !== 0) {
                // for scoped packages, insert the eslint-config after the first /
        filePath = filePath.replace(/^@([^\/]+)\/(.*)$/, '@$1/nplint-config-$2');
      }
    } else if (filePath.indexOf('nplint-config-') !== 0) {
      filePath = 'nplint-config-' + filePath;
    }

    config = util.mergeConfigs(config, require(filePath));
  }
  return config;
}
function readConfigFromFile(filePath) {
  var config = {};

  if (isFilePath(filePath)) {
    try {
      config = yaml.safeLoad(stripComments(fs.readFileSync(filePath, 'utf8'))) || {};
    } catch (e) {
      e.message = 'Cannot read config file: ' + filePath + '\nError: ' + e.message;
      throw e;
    }

    if (path.basename(filePath) === PACKAGE_CONFIG_FILENAME) {
      config = config[PACKAGE_CONFIG_FIELD_NAME] || {};
    }

  } else {

        // it's a package

    if (filePath.charAt(0) === '@') {
            // it's a scoped package

            // package name is 'nplint-config', or just a username
      var scopedPackageShortcutRegex = /^(@[^\/]+)(?:\/(?:eslint-config)?)?$/;
      if (scopedPackageShortcutRegex.test(filePath)) {
        filePath = filePath.replace(scopedPackageShortcutRegex, '$1/nplint-config');
      } else if (filePath.split('/')[1].indexOf('eslint-config-') !== 0) {
                // for scoped packages, insert the eslint-config after the first /
        filePath = filePath.replace(/^@([^\/]+)\/(.*)$/, '@$1/nplint-config-$2');
      }
    } else if (filePath.indexOf('nplint-config-') !== 0) {
      filePath = 'nplint-config-' + filePath;
    }

    config = util.mergeConfigs(config, require(filePath));
  }
  return config;
}
function readConfigFromFile ( filePath ) { var config = { } ; if ( isFilePath ( filePath ) ) { try { config = yaml . safeLoad ( stripComments ( fs . readFileSync ( filePath , 'utf8' ) ) ) || { } ; } catch ( e ) { e . message = 'Cannot read config file: ' + filePath + '\nError: ' + e . message ; throw e ; } if ( path . basename ( filePath ) === PACKAGE_CONFIG_FILENAME ) { config = config [ PACKAGE_CONFIG_FIELD_NAME ] || { } ; } } else { // it's a package if ( filePath . charAt ( 0 ) === '@' ) { // it's a scoped package // package name is 'nplint-config', or just a username var scopedPackageShortcutRegex = / ^(@[^\/]+)(?:\/(?:eslint-config)?)?$ / ; if ( scopedPackageShortcutRegex . test ( filePath ) ) { filePath = filePath . replace ( scopedPackageShortcutRegex , '$1/nplint-config' ) ; } else if ( filePath . split ( '/' ) [ 1 ] . indexOf ( 'eslint-config-' ) !== 0 ) { // for scoped packages, insert the eslint-config after the first / filePath = filePath . replace ( / ^@([^\/]+)\/(.*)$ / , '@$1/nplint-config-$2' ) ; } } else if ( filePath . indexOf ( 'nplint-config-' ) !== 0 ) { filePath = 'nplint-config-' + filePath ; } config = util . mergeConfigs ( config , require ( filePath ) ) ; } return config ; }
Read the config from the config JSON file
@param {string} filePath the path to the JSON config file
@returns {Object} config object
@private
Read the config from the config JSON file