Skip to content

Commit

Permalink
Add top-level eslint config to support overrides for benchmarks, test…
Browse files Browse the repository at this point in the history
…s, and examples
  • Loading branch information
Planeshifter committed Aug 5, 2018
1 parent b0946a1 commit 3c1ea7e
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion etc/eslint/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
51 changes: 51 additions & 0 deletions etc/eslint/.eslintrc.overrides.js
Original file line number Diff line number Diff line change
@@ -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;
84 changes: 83 additions & 1 deletion etc/eslint/overrides/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 //

/**
Expand All @@ -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'
}
}
];

Expand Down
40 changes: 40 additions & 0 deletions etc/eslint/overrides/repl_namespace.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 3c1ea7e

Please sign in to comment.