Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eslint - move to hierarchical configuration #10197

Merged
merged 8 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,11 @@ app/assets/javascripts/locale/**/*.js

# hopeless and should go anyway
app/assets/javascripts/dynatree/jquery.dynatree.js

# not ours or already processed or not javascript
node_modules/
vendor/assets/bower_components/
public/
tmp/
db/
coverage/
185 changes: 0 additions & 185 deletions .eslintrc.js

This file was deleted.

94 changes: 94 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"root": true,
"installedESLint": true,
"env": {
"browser": true,
"jquery": true
},
"parserOptions": {
"ecmaVersion": 5,
"sourceType": "script",
"ecmaFeatures": {
"globalReturn": false,
"impliedStrict": false,
"jsx": false
}
},

"plugins": [],
"extends": ["airbnb-es5"],

"globals": {
"API": false, // local: miq_api.js
"ManageIQ": false, // local: mig_global.js
"Promise": false, // bower: es6-shim
"_": false, // bower: lodash
"__": false, // local: i18n.js
"angular": false, // bower: angular
"c3": false, // bower: c3
"d3": false, // bower: d3
"i18n": false, // gem: gettext_i18n_rails_js
"moment": false, // bower: moment
"numeral": false, // bower: numeral
"sprintf": false // bower: sprintf
},

"rules": {
"indent": [ "error", 2, {
"SwitchCase": 1,
"VariableDeclarator": 1
}],
"consistent-return": 1,
"default-case": 1,
"vars-on-top": 0,
"no-var": 0,
"linebreak-style": [ "error", "unix" ],
"semi-spacing": ["error", {
"before": false,
"after": true
}],
"semi": [ "error", "always" ],
"comma-dangle": [ "warn", "always-multiline" ],
"space-unary-ops": [ "error", {
"words": true,
"nonwords": false,
"overrides": {
"!": true
}
}],
"no-unused-vars": [ "error", {
"args": "all",
"argsIgnorePattern": "^_",
"vars": "local",
"caughtErrors": "all",
"caughtErrorsIgnorePattern": "^_"
}],
"no-console": 1,
"no-alert": 2,
"no-debugger": 2,
"no-else-return": 1,
"no-undef": [ "warn", {
"typeof": true
}],
"eqeqeq": [ "error", "smart" ],
"quotes": [ "warn", "single", {
"avoidEscape": true,
"allowTemplateLiterals": true
}],
"func-names": 0,
"no-mixed-spaces-and-tabs": 2,
"camelcase": 1,
"curly": [ "warn", "all" ],
"space-before-function-paren": [ "error", "never" ],
"no-eq-null": 0,
"no-param-reassign": 1,
"no-fallthrough": [ "error", {
"commentPattern": "fall.*through|pass"
}],
"no-use-before-define": [ "error", {
"functions": false,
"classes": true
}],
"padded-blocks": [ "error", "never" ]
}
}
1 change: 1 addition & 0 deletions app/assets/javascripts/components/.eslintrc.json
28 changes: 28 additions & 0 deletions app/assets/javascripts/controllers/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"plugins": ["angular"],
"extends": ["angular"],
"rules": {
// eslint-plugin-angular
"angular/module-setter": 0,
"angular/foreach": 0,
"angular/watchers-execution": [ "warn", "$apply" ],
"angular/json-functions": 0,
"angular/definedundefined": 0,
"angular/log": 0,
"angular/no-service-method": 0,
"angular/di": [ "error", "array" ], // strictDi

// only warnings for now
"angular/controller-as": 1,
"angular/module-getter": 1,
"angular/no-services": [ "warn", ["$http"] ],

// prefer lodash for typechecks
"angular/typecheck-array": 0,
"angular/typecheck-date": 0,
"angular/typecheck-function": 0,
"angular/typecheck-number": 0,
"angular/typecheck-object": 0,
"angular/typecheck-string": 0
}
}
1 change: 1 addition & 0 deletions app/assets/javascripts/directives/.eslintrc.json
1 change: 1 addition & 0 deletions app/assets/javascripts/services/.eslintrc.json
20 changes: 1 addition & 19 deletions bin/eslint
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,4 @@ ESLINT="node_modules/.bin/eslint"

cd `dirname $0`/..

MIQ_ESLINT=vanilla $ESLINT "$@" \
--ignore-pattern '**/controllers/**/*' \
--ignore-pattern '**/directives/**/*' \
--ignore-pattern '**/services/**/*' \
--ignore-pattern '**/components/**/*' \
app/assets/javascripts/

MIQ_ESLINT=angular $ESLINT "$@" \
app/assets/javascripts/controllers \
app/assets/javascripts/directives \
app/assets/javascripts/services \
app/assets/javascripts/components

MIQ_ESLINT=es6 $ESLINT "$@" \
--ext .es6 \
app/assets/javascripts/

MIQ_ESLINT=spec $ESLINT "$@" \
spec/javascripts/
$ESLINT "$@" app/assets/javascripts/ spec/javascripts/
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"devDependencies": {
"babel-eslint": "^6.0.4",
"eslint": "^2.10.2",
"eslint-config-airbnb": "^9.0.1",
"eslint-config-airbnb-es5": "^1.0.9",
"eslint-config-angular": "^0.5.0",
"eslint-plugin-angular": "^1.0.1",
Expand Down
14 changes: 14 additions & 0 deletions spec/javascripts/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"globals": {
"describe": false,
"context": false,
"it": false,
"beforeEach": false,
"afterEach": false,
"inject": false,
"spyOn": false,
"expect": false,
"jasmine": false,
"setFixtures": false
}
}