diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 000000000000..0bfa6a817256 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var eslint = require( './etc/eslint/.eslintrc.overrides.js' ); + + +// EXPORTS // + +module.exports = eslint; diff --git a/etc/eslint/.eslintrc.js b/etc/eslint/.eslintrc.js index 05884e680773..d957e504d5e7 100644 --- a/etc/eslint/.eslintrc.js +++ b/etc/eslint/.eslintrc.js @@ -62,7 +62,7 @@ eslint.rules = require( './rules' ); * @memberof eslint * @type {Array} */ -eslint.overrides = require( './overrides' ); +eslint.overrides = require( './overrides/repl_namespace.js' ); /** * Parser options. diff --git a/etc/eslint/.eslintrc.overrides.js b/etc/eslint/.eslintrc.overrides.js new file mode 100644 index 000000000000..8b603bf87967 --- /dev/null +++ b/etc/eslint/.eslintrc.overrides.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +// FIXME: remove the next line and uncomment the subsequent line once all remark JSDoc ESLint rules are completed +var copy = require( './../../lib/node_modules/@stdlib/utils/copy' ); + +// var copy = require( './utils/copy.js' ); +var defaults = require( './.eslintrc.js' ); + + +// MAIN // + +/** +* ESLint configuration. +* +* @namespace eslint +*/ +var eslint = copy( defaults ); + +/** +* Overrides. +* +* @name overrides +* @memberof eslint +* @type {Array} +*/ +eslint.overrides = require( './overrides' ); + + +// EXPORTS // + +module.exports = eslint; diff --git a/etc/eslint/overrides/index.js b/etc/eslint/overrides/index.js index 90c4380b51a9..3e35ff9e02cb 100644 --- a/etc/eslint/overrides/index.js +++ b/etc/eslint/overrides/index.js @@ -18,6 +18,48 @@ 'use strict'; +// VARIABLES // + +var restrictedSyntaxConfig = [ 'error', + 'ArrowFunctionExpression', + 'ClassBody', + 'ClassDeclaration', + 'ClassExpression', + 'DebuggerStatement', + 'ExperimentalRestProperty', + 'ExperimentalSpreadProperty', + + // 'FunctionExpression', + 'LabeledStatement', + 'RestElement', + 'SpreadElement', + 'TaggedTemplateExpression', + 'TemplateElement', + 'TemplateLiteral', + 'WithStatement', + 'YieldExpression', + 'JSXIdentifier', + 'JSXNamespacedName', + 'JSXMemberExpression', + 'JSXEmptyExpression', + 'JSXExpressionContainer', + 'JSXElement', + 'JSXClosingElement', + 'JSXOpeningElement', + 'JSXAttribute', + 'JSXSpreadAttribute', + 'JSXText', + 'ExportDefaultDeclaration', + 'ExportNamedDeclaration', + 'ExportAllDeclaration', + 'ExportSpecifier', + 'ImportDeclaration', + 'ImportSpecifier', + 'ImportDefaultSpecifier', + 'ImportNamespaceSpecifier' +]; + + // MAIN // /** @@ -27,11 +69,51 @@ */ var overrides = [ { - 'env': {}, 'files': [ '[a-z].js' ], 'rules': { 'stdlib/repl-namespace-order': 'error' } + }, + { + 'files': [ '**/benchmark/*.js' ], + 'rules': { + 'no-new-wrappers': 'warn', + 'max-lines': [ 'warn', { + 'max': 1000, + 'skipBlankLines': true, + 'skipComments': true + }], + 'no-restricted-syntax': restrictedSyntaxConfig, + 'require-jsdoc': 'off', + 'stdlib/jsdoc-private-annotation': 'off' + } + }, + { + 'files': [ '**/examples/*.js' ], + 'rules': { + 'no-new-wrappers': 'warn', + 'vars-on-top': 'off', + 'no-console': 'off', + 'require-jsdoc': 'off', + 'stdlib/jsdoc-private-annotation': 'off', + 'stdlib/vars-order': 'off' + } + }, + { + 'files': [ '**/test/*.js' ], + 'rules': { + 'no-empty-function': 'off', + 'no-new-wrappers': 'warn', + 'max-lines': [ 'warn', { + 'max': 1000, + 'skipBlankLines': true, + 'skipComments': true + }], + 'no-restricted-syntax': restrictedSyntaxConfig, + 'require-jsdoc': 'off', + 'stdlib/jsdoc-private-annotation': 'off', + 'no-undefined': 'off' + } } ]; diff --git a/etc/eslint/overrides/repl_namespace.js b/etc/eslint/overrides/repl_namespace.js new file mode 100644 index 000000000000..f3a06a7af100 --- /dev/null +++ b/etc/eslint/overrides/repl_namespace.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* ESLint overrides for REPL namespace files. +* +* @namespace overrides +*/ +var overrides = [ + { + 'files': [ '[a-z].js' ], + 'rules': { + 'stdlib/repl-namespace-order': 'error' + } + } +]; + + +// EXPORTS // + +module.exports = overrides;