Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

The generated eslint config is invalid #356

Closed
jackysee opened this issue Oct 12, 2017 · 1 comment
Closed

The generated eslint config is invalid #356

jackysee opened this issue Oct 12, 2017 · 1 comment

Comments

@jackysee
Copy link

I generate the .eslintrc.js using the api neutrino.call('eslintrc'). Eslint 4.7.2 is installed at project root so that the sublimelinter would use it to do the linting. But it doesn't work right now. I run it manually and found that eslint's config validator is complaining:

ESLint configuration in c:\myapp\.eslintrc.js is invalid:
        - Unexpected top-level property "cwd".

Error: ESLint configuration in c:\myapp\.eslintrc.js is invalid:
        - Unexpected top-level property "cwd".

    at validateConfigSchema (c:\myapp\node_modules\eslint\lib\config\config-validator.js:212:15)
    at Object.validate (c:\myapp\node_modules\eslint\lib\config\config-validator.js:229:5)
    at loadFromDisk (c:\myapp\node_modules\eslint\lib\config\config-file.js:549:19)
    at Object.load (c:\myapp\node_modules\eslint\lib\config\config-file.js:592:20)
    at Config.getLocalConfigHierarchy (c:\myapp\node_modules\eslint\lib\config.js:226:44)
    at Config.getConfigHierarchy (c:\myapp\node_modules\eslint\lib\config.js:180:43)
    at Config.getConfigVector (c:\myapp\node_modules\eslint\lib\config.js:285:21)
    at Config.getConfig (c:\myapp\node_modules\eslint\lib\config.js:328:29)
    at processText (c:\myapp\node_modules\eslint\lib\cli-engine.js:156:33)
    at processFile (c:\myapp\node_modules\eslint\lib\cli-engine.js:216:18)

The generated .eslintrc.js is

module.exports = {
    cwd: 'C:\\myapp',
    useEslintrc: true,
    root: true,
    extensions: ['js', 'jsx'],
    plugins: ['babel', 'vue'],
    extends: ['eslint:recommended', 'prettier'],
    env: { es6: true, browser: true, commonjs: true, node: true },
    parser: 'babel-eslint',
    parserOptions: {
        ecmaVersion: 2017,
        sourceType: 'module',
        ecmaFeatures: {
            objectLiteralDuplicateProperties: false,
            generators: true,
            impliedStrict: true
        }
    },
    settings: {},
    globals: { process: true },
    rules: {
        indent: ['error', 4],
        'linebreak-style': ['off', 'windows'],
        quotes: ['error', 'single'],
        semi: ['error', 'always'],
        'vue/jsx-uses-vars': 2
    },
    overrides: [{ files: '**/**_test.js', rules: { 'no-console': ['off'] } }],
    fix: true
};

I found that I have to delete a bunch of top-level properties to give a proper config for eslint to consume:

    let config = neutrino.call('eslintrc');
    delete config.cwd;
    delete config.useEslintrc;
    delete config.extensions;
    delete config.fix;
    fs.writeFileSync(
         path.join(__dirname, '.eslintrc.js'),
         'module.exports = ' + JSON.stringify(config)
    );
@eliperelman
Copy link
Member

I can replicate this as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants