scripts/buildEditorConfig.js
function convertRules (config) {
  const result = {}

  const eslintRules = new CLIEngine({
    useEslintrc: false,
    baseConfig: {
      extends: [require.resolve(`@vue/eslint-config-${config}`)]
    }
  }).getConfigForFile().rules

  const getRuleOptions = (ruleName, defaultOptions = []) => {
    const ruleConfig = eslintRules[ruleName]

    if (!ruleConfig || ruleConfig === 0 || ruleConfig === 'off') {
      return
    }

    if (Array.isArray(ruleConfig) && (ruleConfig[0] === 0 || ruleConfig[0] === 'off')) {
      return
    }

    if (Array.isArray(ruleConfig) && ruleConfig.length > 1) {
      return ruleConfig.slice(1)
    }

    return defaultOptions
  }

  // https://eslint.org/docs/rules/indent
  const indent = getRuleOptions('indent', [4])
  if (indent) {
    result.indent_style = indent[0] === 'tab' ? 'tab' : 'space'

    if (typeof indent[0] === 'number') {
      result.indent_size = indent[0]
    }
  }

  // https://eslint.org/docs/rules/linebreak-style
  const linebreakStyle = getRuleOptions('linebreak-style', ['unix'])
  if (linebreakStyle) {
    result.end_of_line = linebreakStyle[0] === 'unix' ? 'lf' : 'crlf'
  }

  // https://eslint.org/docs/rules/no-trailing-spaces
  const noTrailingSpaces = getRuleOptions('no-trailing-spaces', [{ skipBlankLines: false, ignoreComments: false }])
  if (noTrailingSpaces) {
    if (!noTrailingSpaces[0].skipBlankLines && !noTrailingSpaces[0].ignoreComments) {
      result.trim_trailing_whitespace = true
    }
  }

  // https://eslint.org/docs/rules/eol-last
  const eolLast = getRuleOptions('eol-last', ['always'])
  if (eolLast) {
    result.insert_final_newline = eolLast[0] !== 'never'
  }

  // https://eslint.org/docs/rules/max-len
  const maxLen = getRuleOptions('max-len', [{ code: 80 }])
  if (maxLen) {
    // To simplify the implementation logic, we only read from the `code` option.

    // `max-len` has an undocumented array-style configuration,
    // where max code length specified directly as integers
    // (used by `eslint-config-airbnb`).

    if (typeof maxLen[0] === 'number') {
      result.max_line_length = maxLen[0]
    } else {
      result.max_line_length = maxLen[0].code
    }
  }

  return result
}
function convertRules (config) {
  const result = {}

  const eslintRules = new CLIEngine({
    useEslintrc: false,
    baseConfig: {
      extends: [require.resolve(`@vue/eslint-config-${config}`)]
    }
  }).getConfigForFile().rules

  const getRuleOptions = (ruleName, defaultOptions = []) => {
    const ruleConfig = eslintRules[ruleName]

    if (!ruleConfig || ruleConfig === 0 || ruleConfig === 'off') {
      return
    }

    if (Array.isArray(ruleConfig) && (ruleConfig[0] === 0 || ruleConfig[0] === 'off')) {
      return
    }

    if (Array.isArray(ruleConfig) && ruleConfig.length > 1) {
      return ruleConfig.slice(1)
    }

    return defaultOptions
  }

  // https://eslint.org/docs/rules/indent
  const indent = getRuleOptions('indent', [4])
  if (indent) {
    result.indent_style = indent[0] === 'tab' ? 'tab' : 'space'

    if (typeof indent[0] === 'number') {
      result.indent_size = indent[0]
    }
  }

  // https://eslint.org/docs/rules/linebreak-style
  const linebreakStyle = getRuleOptions('linebreak-style', ['unix'])
  if (linebreakStyle) {
    result.end_of_line = linebreakStyle[0] === 'unix' ? 'lf' : 'crlf'
  }

  // https://eslint.org/docs/rules/no-trailing-spaces
  const noTrailingSpaces = getRuleOptions('no-trailing-spaces', [{ skipBlankLines: false, ignoreComments: false }])
  if (noTrailingSpaces) {
    if (!noTrailingSpaces[0].skipBlankLines && !noTrailingSpaces[0].ignoreComments) {
      result.trim_trailing_whitespace = true
    }
  }

  // https://eslint.org/docs/rules/eol-last
  const eolLast = getRuleOptions('eol-last', ['always'])
  if (eolLast) {
    result.insert_final_newline = eolLast[0] !== 'never'
  }

  // https://eslint.org/docs/rules/max-len
  const maxLen = getRuleOptions('max-len', [{ code: 80 }])
  if (maxLen) {
    // To simplify the implementation logic, we only read from the `code` option.

    // `max-len` has an undocumented array-style configuration,
    // where max code length specified directly as integers
    // (used by `eslint-config-airbnb`).

    if (typeof maxLen[0] === 'number') {
      result.max_line_length = maxLen[0]
    } else {
      result.max_line_length = maxLen[0].code
    }
  }

  return result
}
function convertRules ( config ) { const result = { } const eslintRules = new CLIEngine ( { useEslintrc : false , baseConfig : { extends : [ require . resolve ( ` ${ config } ` ) ] } } ) . getConfigForFile ( ) . rules const getRuleOptions = ( ruleName , defaultOptions = [ ] ) => { const ruleConfig = eslintRules [ ruleName ] if ( ! ruleConfig || ruleConfig === 0 || ruleConfig === 'off' ) { return } if ( Array . isArray ( ruleConfig ) && ( ruleConfig [ 0 ] === 0 || ruleConfig [ 0 ] === 'off' ) ) { return } if ( Array . isArray ( ruleConfig ) && ruleConfig . length > 1 ) { return ruleConfig . slice ( 1 ) } return defaultOptions } // https://eslint.org/docs/rules/indent const indent = getRuleOptions ( 'indent' , [ 4 ] ) if ( indent ) { result . indent_style = indent [ 0 ] === 'tab' ? 'tab' : 'space' if ( typeof indent [ 0 ] === 'number' ) { result . indent_size = indent [ 0 ] } } // https://eslint.org/docs/rules/linebreak-style const linebreakStyle = getRuleOptions ( 'linebreak-style' , [ 'unix' ] ) if ( linebreakStyle ) { result . end_of_line = linebreakStyle [ 0 ] === 'unix' ? 'lf' : 'crlf' } // https://eslint.org/docs/rules/no-trailing-spaces const noTrailingSpaces = getRuleOptions ( 'no-trailing-spaces' , [ { skipBlankLines : false , ignoreComments : false } ] ) if ( noTrailingSpaces ) { if ( ! noTrailingSpaces [ 0 ] . skipBlankLines && ! noTrailingSpaces [ 0 ] . ignoreComments ) { result . trim_trailing_whitespace = true } } // https://eslint.org/docs/rules/eol-last const eolLast = getRuleOptions ( 'eol-last' , [ 'always' ] ) if ( eolLast ) { result . insert_final_newline = eolLast [ 0 ] !== 'never' } // https://eslint.org/docs/rules/max-len const maxLen = getRuleOptions ( 'max-len' , [ { code : 80 } ] ) if ( maxLen ) { // To simplify the implementation logic, we only read from the `code` option. // `max-len` has an undocumented array-style configuration, // where max code length specified directly as integers // (used by `eslint-config-airbnb`). if ( typeof maxLen [ 0 ] === 'number' ) { result . max_line_length = maxLen [ 0 ] } else { result . max_line_length = maxLen [ 0 ] . code } } return result }
Convert eslint rules to editorconfig rules.
Convert eslint rules to editorconfig rules .