Skip to content

Commit 3c1ea7e

Browse files
committed
Add top-level eslint config to support overrides for benchmarks, tests, and examples
1 parent b0946a1 commit 3c1ea7e

File tree

5 files changed

+203
-2
lines changed

5 files changed

+203
-2
lines changed

.eslintrc.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var eslint = require( './etc/eslint/.eslintrc.overrides.js' );
24+
25+
26+
// EXPORTS //
27+
28+
module.exports = eslint;

etc/eslint/.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ eslint.rules = require( './rules' );
6262
* @memberof eslint
6363
* @type {Array}
6464
*/
65-
eslint.overrides = require( './overrides' );
65+
eslint.overrides = require( './overrides/repl_namespace.js' );
6666

6767
/**
6868
* Parser options.

etc/eslint/.eslintrc.overrides.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
// FIXME: remove the next line and uncomment the subsequent line once all remark JSDoc ESLint rules are completed
24+
var copy = require( './../../lib/node_modules/@stdlib/utils/copy' );
25+
26+
// var copy = require( './utils/copy.js' );
27+
var defaults = require( './.eslintrc.js' );
28+
29+
30+
// MAIN //
31+
32+
/**
33+
* ESLint configuration.
34+
*
35+
* @namespace eslint
36+
*/
37+
var eslint = copy( defaults );
38+
39+
/**
40+
* Overrides.
41+
*
42+
* @name overrides
43+
* @memberof eslint
44+
* @type {Array}
45+
*/
46+
eslint.overrides = require( './overrides' );
47+
48+
49+
// EXPORTS //
50+
51+
module.exports = eslint;

etc/eslint/overrides/index.js

+83-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,48 @@
1818

1919
'use strict';
2020

21+
// VARIABLES //
22+
23+
var restrictedSyntaxConfig = [ 'error',
24+
'ArrowFunctionExpression',
25+
'ClassBody',
26+
'ClassDeclaration',
27+
'ClassExpression',
28+
'DebuggerStatement',
29+
'ExperimentalRestProperty',
30+
'ExperimentalSpreadProperty',
31+
32+
// 'FunctionExpression',
33+
'LabeledStatement',
34+
'RestElement',
35+
'SpreadElement',
36+
'TaggedTemplateExpression',
37+
'TemplateElement',
38+
'TemplateLiteral',
39+
'WithStatement',
40+
'YieldExpression',
41+
'JSXIdentifier',
42+
'JSXNamespacedName',
43+
'JSXMemberExpression',
44+
'JSXEmptyExpression',
45+
'JSXExpressionContainer',
46+
'JSXElement',
47+
'JSXClosingElement',
48+
'JSXOpeningElement',
49+
'JSXAttribute',
50+
'JSXSpreadAttribute',
51+
'JSXText',
52+
'ExportDefaultDeclaration',
53+
'ExportNamedDeclaration',
54+
'ExportAllDeclaration',
55+
'ExportSpecifier',
56+
'ImportDeclaration',
57+
'ImportSpecifier',
58+
'ImportDefaultSpecifier',
59+
'ImportNamespaceSpecifier'
60+
];
61+
62+
2163
// MAIN //
2264

2365
/**
@@ -27,11 +69,51 @@
2769
*/
2870
var overrides = [
2971
{
30-
'env': {},
3172
'files': [ '[a-z].js' ],
3273
'rules': {
3374
'stdlib/repl-namespace-order': 'error'
3475
}
76+
},
77+
{
78+
'files': [ '**/benchmark/*.js' ],
79+
'rules': {
80+
'no-new-wrappers': 'warn',
81+
'max-lines': [ 'warn', {
82+
'max': 1000,
83+
'skipBlankLines': true,
84+
'skipComments': true
85+
}],
86+
'no-restricted-syntax': restrictedSyntaxConfig,
87+
'require-jsdoc': 'off',
88+
'stdlib/jsdoc-private-annotation': 'off'
89+
}
90+
},
91+
{
92+
'files': [ '**/examples/*.js' ],
93+
'rules': {
94+
'no-new-wrappers': 'warn',
95+
'vars-on-top': 'off',
96+
'no-console': 'off',
97+
'require-jsdoc': 'off',
98+
'stdlib/jsdoc-private-annotation': 'off',
99+
'stdlib/vars-order': 'off'
100+
}
101+
},
102+
{
103+
'files': [ '**/test/*.js' ],
104+
'rules': {
105+
'no-empty-function': 'off',
106+
'no-new-wrappers': 'warn',
107+
'max-lines': [ 'warn', {
108+
'max': 1000,
109+
'skipBlankLines': true,
110+
'skipComments': true
111+
}],
112+
'no-restricted-syntax': restrictedSyntaxConfig,
113+
'require-jsdoc': 'off',
114+
'stdlib/jsdoc-private-annotation': 'off',
115+
'no-undefined': 'off'
116+
}
35117
}
36118
];
37119

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MAIN //
22+
23+
/**
24+
* ESLint overrides for REPL namespace files.
25+
*
26+
* @namespace overrides
27+
*/
28+
var overrides = [
29+
{
30+
'files': [ '[a-z].js' ],
31+
'rules': {
32+
'stdlib/repl-namespace-order': 'error'
33+
}
34+
}
35+
];
36+
37+
38+
// EXPORTS //
39+
40+
module.exports = overrides;

0 commit comments

Comments
 (0)