-
-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
_tools/eslint/rules/line-closing-bracket-spacing
PR-URL: #4211 Private-ref: stdlib-js/todo#2325 Reviewed-by: Athan Reines <[email protected]>
- Loading branch information
1 parent
a3766c6
commit 9d632d5
Showing
11 changed files
with
1,081 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
163 changes: 163 additions & 0 deletions
163
...node_modules/@stdlib/_tools/eslint/rules/line-closing-bracket-spacing/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
<!-- | ||
@license Apache-2.0 | ||
Copyright (c) 2024 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. | ||
--> | ||
|
||
# line-closing-bracket-spacing | ||
|
||
> [ESLint rule][eslint-rules] to enforce that no spaces are present between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line. | ||
<section class="intro"> | ||
|
||
</section> | ||
|
||
<!-- /.intro --> | ||
|
||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var rule = require( '@stdlib/_tools/eslint/rules/line-closing-bracket-spacing' ); | ||
``` | ||
|
||
#### rule | ||
|
||
[ESLint rule][eslint-rules] to enforce that no spaces are present between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line. | ||
|
||
**Bad**: | ||
|
||
<!-- eslint-disable stdlib/line-closing-bracket-spacing --> | ||
|
||
```javascript | ||
var log = require( '@stdlib/console/log' ); | ||
|
||
log({ | ||
'foo': true | ||
} ); | ||
|
||
log([ | ||
1, | ||
2, | ||
3 | ||
] ); | ||
|
||
log([{ | ||
'bar': true | ||
} ] ); | ||
``` | ||
|
||
**Good**: | ||
|
||
```javascript | ||
var log = require( '@stdlib/console/log' ); | ||
|
||
log({ | ||
'foo': true | ||
}); | ||
|
||
log([ | ||
1, | ||
2, | ||
3 | ||
]); | ||
|
||
log([{ | ||
'bar': true | ||
}]); | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var Linter = require( 'eslint' ).Linter; | ||
var rule = require( '@stdlib/_tools/eslint/rules/line-closing-bracket-spacing' ); | ||
|
||
var linter = new Linter(); | ||
|
||
var code = [ | ||
'function test() {', | ||
' var log = require( \'@stdlib/console/log\' );', | ||
' log({', | ||
' "key": "value"', | ||
' } );', | ||
' var arr = [{', | ||
' "nested": true', | ||
' } ];', | ||
' log( arr );', | ||
'}' | ||
].join( '\n' ); | ||
|
||
linter.defineRule( 'line-closing-bracket-spacing', rule ); | ||
|
||
var result = linter.verify( code, { | ||
'rules': { | ||
'line-closing-bracket-spacing': 'error' | ||
} | ||
}); | ||
/* returns | ||
[ | ||
{ | ||
'ruleId': 'line-closing-bracket-spacing', | ||
'severity': 2, | ||
'message': 'No spaces allowed between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line', | ||
'line': 3, | ||
'column': 3, | ||
'nodeType': 'CallExpression' | ||
}, | ||
{ | ||
'ruleId': 'line-closing-bracket-spacing', | ||
'severity': 2, | ||
'message': 'No spaces allowed between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line', | ||
'line': 6, | ||
'column': 13, | ||
'nodeType': 'ArrayExpression' | ||
} | ||
] | ||
*/ | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
[eslint-rules]: https://eslint.org/docs/developer-guide/working-with-rules | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
66 changes: 66 additions & 0 deletions
66
lib/node_modules/@stdlib/_tools/eslint/rules/line-closing-bracket-spacing/examples/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 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'; | ||
|
||
var Linter = require( 'eslint' ).Linter; | ||
var rule = require( './../lib' ); | ||
|
||
var linter = new Linter(); | ||
|
||
var code = [ | ||
'function test() {', | ||
' var log = require( \'@stdlib/console/log\' );', | ||
' log({', | ||
' "key": "value"', | ||
' } );', | ||
' var arr = [{', | ||
' "nested": true', | ||
' } ];', | ||
' log( arr );', | ||
'}' | ||
].join( '\n' ); | ||
|
||
linter.defineRule( 'line-closing-bracket-spacing', rule ); | ||
|
||
var result = linter.verify( code, { | ||
'rules': { | ||
'line-closing-bracket-spacing': 'error' | ||
} | ||
}); | ||
console.log( result ); | ||
/* => | ||
[ | ||
{ | ||
'ruleId': 'line-closing-bracket-spacing', | ||
'severity': 2, | ||
'message': 'No spaces allowed between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line', | ||
'line': 3, | ||
'column': 3, | ||
'nodeType': 'CallExpression' | ||
}, | ||
{ | ||
'ruleId': 'line-closing-bracket-spacing', | ||
'severity': 2, | ||
'message': 'No spaces allowed between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line', | ||
'line': 6, | ||
'column': 13, | ||
'nodeType': 'ArrayExpression' | ||
} | ||
] | ||
*/ |
39 changes: 39 additions & 0 deletions
39
lib/node_modules/@stdlib/_tools/eslint/rules/line-closing-bracket-spacing/lib/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 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'; | ||
|
||
/** | ||
* ESLint rule to enforce that no spaces are present between a closing parenthesis or bracket and a nested object or array expression at the beginning of a line. | ||
* | ||
* @module @stdlib/_tools/eslint/rules/line-closing-bracket-spacing | ||
* | ||
* @example | ||
* var rule = require( '@stdlib/_tools/eslint/rules/line-closing-bracket-spacing' ); | ||
* | ||
* console.log( rule ); | ||
*/ | ||
|
||
// MODULES // | ||
|
||
var main = require( './main.js' ); | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = main; |
Oops, something went wrong.