Skip to content

Instantly share code, notes, and snippets.

@nunof07
Last active April 5, 2019 16:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nunof07/a5a9d576cc84c11e96a219e2b3948f96 to your computer and use it in GitHub Desktop.
Save nunof07/a5a9d576cc84c11e96a219e2b3948f96 to your computer and use it in GitHub Desktop.
ESLint configuration for Sage theme
module.exports = {
'root': true,
'extends': [
'eslint:recommended',
'plugin:sonarjs/recommended',
'plugin:unicorn/recommended',
'es/2015/client',
],
'globals': {
'wp': true,
},
'env': {
'node': true,
'es6': true,
'amd': true,
'browser': true,
'jquery': true,
},
'parserOptions': {
'ecmaFeatures': {
'globalReturn': true,
'generators': true,
},
'ecmaVersion': 2018,
'sourceType': 'module',
},
'plugins': [
'import',
'sonarjs',
'unicorn',
],
'settings': {
'import/core-modules': [],
'import/ignore': [
'node_modules',
'\\.(coffee|scss|css|less|hbs|svg|json)$',
],
},
'rules': {
'quotes': ['error', 'single'],
'comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'ignore',
},
],
'unicorn/filename-case': [
'error',
{
'case': 'camelCase',
},
],
'linebreak-style': 0,
'id-length': [ 2, {
min: 2,
max: Number.infinity,
properties: 'always',
exceptions: [ '_', 'i', 'j', 'x', 'y', 'z', '$' ]
}],
'sort-imports': [ 2, {
ignoreCase: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: [ 'none', 'single', 'multiple', 'all' ]
}],
'space-before-function-paren': ['error', {
'anonymous': 'always',
'named': 'never',
'asyncArrow': 'always',
}],
'dot-location': ['error', 'property'],
},
};
npm install --save-dev eslint@5.16.0 eslint-config-es eslint-plugin-sonarjs eslint-plugin-unicorn
@nunof07
Copy link
Author

nunof07 commented Apr 5, 2019

First update eslint to the latest version and install the additional package.

@nunof07
Copy link
Author

nunof07 commented Apr 5, 2019

When using with Sage, either fix the linting errors in the build scripts or exclude the build scripts from linting by updating in package.json: "lint:scripts": "eslint resources/assets/scripts".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment