Skip to content
Merged

ESLint #13549

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
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
blueprints/*/*files/**/*.js
dist/
tmp/
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 6,
sourceType: 'module',
},
extends: 'eslint:recommended',
env: {
qunit: true,
},
globals: {
'expectAssertion': true,
'expectDeprecation': true,
'expectNoDeprecation': true,
'expectWarning': true,
'expectNoWarning': true,
'ignoreAssertion': true,
'ignoreDeprecation': true,

// A safe subset of "browser:true":
'window': true,
'document': true,
'setTimeout': true,
'clearTimeout': true,
'setInterval': true,
'clearInterval': true,

'Symbol': true,
'WeakMap': true,
},
rules: {
'require-yuidoc-access': 'error',
'no-const-outside-module-scope': 'error',

// temporarily disabled
'no-unused-vars': 'off',
'comma-dangle': 'off',
},
};
1 change: 1 addition & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ module.exports = function() {
development: babelConfigFor('development'),
production: babelConfigFor('production')
},
eslintRulePaths: [__dirname + '/lib/eslint-rules'],
features: {
development: getFeatures('development'),
production: getFeatures('production')
Expand Down
29 changes: 29 additions & 0 deletions lib/eslint-rules/no-const-outside-module-scope.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

module.exports = function(context) {
return {
VariableDeclaration: function(node) {
if (node.kind !== 'const') {
return;
}

if (node.parent && node.parent.type === 'Program') {
// Declaration is in root of module.
return;
}

if (node.parent && node.parent.type === 'ExportNamedDeclaration' &&
node.parent.parent && node.parent.parent.type === 'Program') {
// Declaration is a `export const foo = 'asdf'` in root of the module.
return;
}

context.report({
node: node,
message: '`const` should only be used in module scope (not inside functions/blocks).'
});
}
};
};

module.exports.schema = []; // no options
34 changes: 34 additions & 0 deletions lib/eslint-rules/require-yuidoc-access.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

function isDocComment(comment) {
return comment.value[0] === '*';
}

function isModuleOnlyComment(comment) {
return comment.value.match(/^\*\n\s*@module.+\n(?:\s*@submodule.+\n)?$/);
}

function includesAccessDeclaration(comment) {
return comment.value.match(/\n\s*(@private|@public|@protected)\s/);
}

module.exports = function(context) {

var sourceCode = context.getSourceCode();

sourceCode.getAllComments().forEach(function(comment) {
if (comment.type !== 'Block') { return; }
if (!isDocComment(comment)) { return; }
if (isModuleOnlyComment(comment)) { return; }
if (includesAccessDeclaration(comment)) { return; }

context.report({
loc: comment.loc.start,
message: 'Access declaration missing, you must supply `@public`, `@private`, or `@protected` for doc comments.'
});
});

return {};
};

module.exports.schema = []; // no options
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"ember-cli-sauce": "^1.8.0",
"ember-cli-yuidoc": "0.8.4",
"ember-publisher": "0.0.7",
"emberjs-build": "0.18.0",
"emberjs-build": "0.19.0",
"express": "^4.5.0",
"finalhandler": "^0.4.0",
"git-repo-info": "^1.1.4",
Expand Down
1 change: 1 addition & 0 deletions packages/ember-glimmer/lib/helpers/debugger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-debugger:off */
/*jshint debug:true*/

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/ember-metal/lib/instrumentation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint no-console:off */
/* global console */

import { ENV } from 'ember-environment';
Expand Down Expand Up @@ -125,8 +126,8 @@ function withFinalizer(callback, finalizer, payload, binding) {
result = payload;
} finally {
finalizer();
return result;
}
return result;
}

function NOOP() {}
Expand Down
Loading