Sebastien De Varennes
Sebastien De Varennes

Reputation: 805

How to fix eslint/prettier "Parsing error: ';' expected" for .css file?

Here's an example of an error I am receiving, which I do not know how to fix:

// example.css

body {
  height: 100%;
}

this would return the following error in the terminal when running eslint:

1:5 error Parsing error: ';' expected

Here are my eslintrc and prettierrc configurations, thank you for the help:

// eslintrc.js

module.exports = {
    env: {
        browser: true,
        jest: true,
        node: true,
        es6: true,
    },
    parser: '@typescript-eslint/parser',
    plugins: ['@typescript-eslint'],
    extends: [
        'airbnb',
        'prettier',
        'prettier/react',
        'prettier/@typescript-eslint',
        'plugin:@typescript-eslint/recommended',
    ],
    parserOptions: {
        ecmaVersion: 2018,
        sourceType: 'module',
        ecmaFeatures: {
            jsx: true,
        },
    },
    rules: {
        'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
        'react/jsx-filename-extension': ['warn', { extensions: ['.tsx', '.jsx'] }],
        '@typescript-eslint/interface-name-prefix': ['error', { prefixWithI: 'always' }]
    },
    settings: {
        react: {
            version: 'detect',
        },
        'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
        'import/parsers': {
            '@typescript-eslint/parser': ['.ts', '.tsx'],
        },
        'import/resolver': {
            node: {
                extensions: ['.js', '.jsx', '.ts', '.tsx'],
                moduleDirectory: ['node_modules', 'src'],
            },
        },
    },
};
// prettierrc.js

module.exports =  {
    semi:  true,
    trailingComma:  'all',
    singleQuote:  true,
    printWidth:  120,
    tabWidth:  2,
};

Upvotes: 7

Views: 12036

Answers (1)

Sebastien De Varennes
Sebastien De Varennes

Reputation: 805

After a bit more research, I found out that my eslint command was the issue:

yarn eslint src/**

This included .css, .json, etc. files even though my eslintrc was correctly configured. By switching to this function, the issue no longer occurs:

yarn eslint --ext js,jsx,ts,tsx src

Upvotes: 7

Related Questions