Skip to content

Instantly share code, notes, and snippets.

@branflake2267
Created April 28, 2020 15:52
Show Gist options
  • Save branflake2267/651cdf8c0b31d443b2b76311dbfa2d4b to your computer and use it in GitHub Desktop.
Save branflake2267/651cdf8c0b31d443b2b76311dbfa2d4b to your computer and use it in GitHub Desktop.
Ext JS SDK eslint
**/build/*
**/sass/*
**/bootstrap*.js
**/ext-all*.js
**/ext-modern*.js
attic/*
deployment_workspace/*
docs/*
ext/*.js
ext/modern/modern/test/*
ext/packages/charts/server/*
ext/packages/font-awesome/*
ext/packages/font-ext/*
ext/packages/font-ios/*
ext/packages/font-pictos/*
ext/packages/google/*
ext/packages/legacy/*
ext/packages/soap/*
ext/resources/*
ext/templates/*
ext/test/*
ext/test_internal/*
ext/welcome/*
fiddle/*
lib/*
mondo_playground/*
packages/d3/d3.js
packages/d3/development/*
packages/d3/production/*
packages/d3/testing/*
packages/exporter/server/*
packages/pivot/architect/*
packages/pivot/server/*
packages/remote/package-loader/*
packages/froala-editor/froalaeditor.pkgd.*
reactor/*
staging/*
test/*
© 2020 GitHub, Inc.
Terms
Privacy
Security
Status
Help
Contact GitHub
Pricing
API
Training
Blog
About
module.exports = {
globals: {
Ext: false,
App: false,
d3: false,
FroalaEditor: false,
setImmediate: false,
clearImmediate: false
},
env: {
browser: true,
es6: false
},
extends: 'eslint:recommended',
parserOptions: {
ecmaVersion: 5
},
rules: {
indent: [
'error',
4,
{
SwitchCase: 1,
ArrayExpression: 'first',
ObjectExpression: 'first',
MemberExpression: 'off',
FunctionDeclaration: {
parameters: 'first',
body: 1
},
CallExpression: {
arguments: 'first'
},
outerIIFEBody: 0,
ignoreComments: false,
flatTernaryExpressions: true,
VariableDeclarator: 1
}
],
'id-blacklist': [
'error',
'abstract',
'await',
'byte',
'char',
'class',
'const',
'double',
'enum',
'export',
'extends',
'final',
'float',
'implements',
'import',
'int',
'interface',
'long',
'native',
'package',
'private',
'protected',
'public',
'short',
'static',
'super',
'synchronized',
'throws',
'transient',
'volatile'
],
'no-floating-decimal': 'error',
semi: ['error', 'always'],
'no-console': 0,
'no-debugger': 0,
'no-prototype-builtins': 0,
curly: ['error'],
'nonblock-statement-body-position': ['error', 'below'],
'space-before-blocks': [
'error',
{
functions: 'always',
keywords: 'always',
classes: 'always'
}
],
'space-infix-ops': ['error'],
'block-spacing': ['error', 'always'],
'semi-spacing': ['error', { before: false, after: true }],
'no-whitespace-before-property': ['error'],
'keyword-spacing': ['error', { before: true, after: true }],
'space-before-function-paren': ['error', 'never'],
'func-call-spacing': ['error', 'never'],
'space-in-parens': ['error', 'never'],
'no-multi-spaces': ['error', { ignoreEOLComments: true }],
'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 1 }],
'brace-style': ['error', 'stroustrup'],
'comma-dangle': ['error', 'never'],
'comma-spacing': ['error', { after: true }],
'dot-notation': ['error', { allowKeywords: true }],
'dot-location': ['error', 'property'],
'multiline-ternary': ['error', 'always-multiline'],
'operator-linebreak': [
'error',
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
eqeqeq: ['error', 'always', { null: 'ignore' }],
'no-trailing-spaces': [
'error',
{
ignoreComments: true
}
],
'spaced-comment': [
'error',
'always',
{
line: {
exceptions: [
'<debug>',
'</debug>',
'<example>',
'</example>',
'<legacyBrowser>',
'</legacyBrowser>',
'<feature logger>',
'<feature classSystem.alias>',
'<feature classSystem.singleton>',
'<feature classSystem.alternateClassName>',
'<feature classSystem.statics>',
'<feature classSystem.inheritableStatics>',
'<feature classSystem.config>',
'<feature classSystem.cachedConfig>',
'<feature classSystem.mixins>',
'<feature classSystem.backwardsCompatible>',
'<feature classSystem.platformConfig>',
'<feature classSystem.loader>',
'<feature legacyBrowser>',
'</feature>',
'<if nonBrowser>',
'<if legacyBrowser>',
'</if legacyBrowser>',
'</if>',
'<deprecated since=5.0>',
'</deprecated>',
'<locale>',
'<locale type="object" property="parseCodes">',
'</locale>',
'<deprecated since=0.99>',
'</deprecated>',
'-',
'='
]
},
block: {
balanced: true
}
}
],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'computed-property-spacing': ['error', 'never'],
'eol-last': ['error', 'always'],
'object-curly-spacing': ['error', 'always'],
'vars-on-top': ['error'],
'no-extra-boolean-cast': 'off',
'no-unused-expressions': ['error'],
'no-unused-vars': [
'error',
{
vars: 'all',
args: 'none',
ignoreRestSiblings: false
}
],
'one-var': ['error', 'consecutive'],
'one-var-declaration-per-line': ['error', 'initializations'],
// "valid-jsdoc": ["error", {
// "requireReturn": false
// }],
'max-len': [
'error',
{
code: 100,
ignoreComments: false,
ignoreStrings: false,
ignoreRegExpLiterals: true,
ignoreUrls: true
}
],
'comma-style': [
'error',
'last',
{
exceptions: {
ArrayExpression: false,
CallExpression: false,
FunctionDeclaration: false,
FunctionExpression: false,
ObjectExpression: false,
VariableDeclaration: false,
NewExpression: false
}
}
],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', prev: '*', next: 'case' },
{ blankLine: 'any', prev: 'case', next: 'case' },
{ blankLine: 'always', prev: 'break', next: 'case' },
{ blankLine: 'always', prev: 'break', next: 'default' },
{ blankLine: 'always', prev: 'var', next: '*' },
{ blankLine: 'always', prev: '*', next: 'block-like' },
{ blankLine: 'always', prev: '*', next: 'return' },
{ blankLine: 'always', prev: 'block-like', next: 'block-like' },
{ blankLine: 'always', prev: 'block-like', next: 'return' },
{ blankLine: 'always', prev: 'block-like', next: 'break' },
{ blankLine: 'always', prev: 'block-like', next: 'expression' }
]
},
overrides: [
{
files: ['packages/pivot-locale/**/overrides/**/*.js'],
rules: {
'key-spacing': 'off'
}
},
{
files: ['ext/classic/locale/overrides/**/*.js'],
rules: {
'max-len': 'off',
'no-useless-escape': 'off'
}
},
{
files: [
// Not only test/specs; some packages have other relevant directories
'**/test/**/*.js'
],
env: {
jasmine: true,
node: true
},
globals: {
topSuite: false,
xtopSuite: false,
wait: false,
waitForSpy: false,
waitsForSpy: false,
waitForSpyCalled: false,
spyOnEvent: false,
focusAndWait: false,
focusAndExpect: false,
expectFocused: false,
pressKey: false,
pressTabKey: false,
simulateTabKey: false,
waitAWhile: false,
waitForEvent: false,
waitsForEvent: false,
waitForFocus: false,
waitsForFocus: false,
waitForAnimation: false,
waitsForAnimation: false,
fireTabAndWait: false,
waitFor: false,
MockAjax: true,
MockAjaxManager: true,
spec: true,
specFor: false
},
rules: {
indent: 'off',
'vars-on-top': 'off',
'one-var': 'off',
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'max-len': 'off',
'no-multi-spaces': 'off',
'no-empty': 'off',
'newline-per-chained-call': 'off',
'dot-notation': 'off',
'brace-style': ['error', 'stroustrup', { allowSingleLine: true }]
}
}
]
};
@ericpoe
Copy link

ericpoe commented May 3, 2020

I love seeing an eslint config! This helps me and my fellow devs write consistently formatted code.

For the eslint config provided here, I notice that the default application built via ext-gen app -i does not comply with this eslint configuration (app name "foo", using modern UI and other defaults).

Starting out, each file uses tabs instead of spaces! Fixed via npm run eslint --fix

Perhaps this would be easier by allowing for es6 while compiling down to es5? Then the var that should be at the top of the file can be changed to let or const and not be flagged as a problem.

Also, max-len: [ 'error', { code: 100, ... }] flags a bunch of errors in the default app, but expanding it to a line length of 120 is far fewer. This just leaves 2 files with lines longer than 120 chars: HomeView.js and MainView.js

MainViewController.js has a != that should be a !== instead.

MainViewController.js has a vm var that is declared but never used.

@ericpoe
Copy link

ericpoe commented May 3, 2020

Changes to .eslintrc.js

  env: {
    es6: true
  },
  parserOptions: {
    ecmaVersion: 6
  },
  'max-len': [
      'error',
      {
        code: 120
      },

@ericpoe
Copy link

ericpoe commented May 3, 2020

Given the above, there are just a few issues to fix after npm run eslint-fix

My package.json includes:

"scripts": {
    "lint": "eslint app",
    "lint-fix": "npm run lint -- --fix",
  },

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