Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@silvermine/eslint-plugin-silvermine

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@silvermine/eslint-plugin-silvermine - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

.github/workflows/ci.yml

18

CHANGELOG.md

@@ -1,5 +0,19 @@

# Change Log
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
All notable changes to this project will be documented in this file.
See [our coding standards][commit-messages] for commit guidelines.
## [2.5.0](https://github.com/silvermine/eslint-plugin-silvermine/compare/v2.4.0...v2.5.0) (2024-12-10)
### Features
* allow array access in fluent chainging ([#54](https://github.com/silvermine/eslint-plugin-silvermine/issues/54)) ([c112091](https://github.com/silvermine/eslint-plugin-silvermine/commit/c112091068a1f9067ce4df8e769156f5ece46def))
### Bug Fixes
* lint chained expressions after class or awaited expression ([#62](https://github.com/silvermine/eslint-plugin-silvermine/issues/62)) ([7f69d18](https://github.com/silvermine/eslint-plugin-silvermine/commit/7f69d18b797ab55223c91035fb28ff10848f6ec3))
## [2.3.0-rc.0](https://github.com/silvermine/eslint-plugin-silvermine/compare/v2.2.1...v2.3.0-rc.0) (2020-01-22)

@@ -6,0 +20,0 @@

12

docs/rules/call-indentation.md

@@ -9,2 +9,3 @@ # Check indentation of function call (call-indentation)

## Option 1 - All start on the same line
A call to a function that spans multiple lines because of an array,

@@ -22,3 +23,3 @@ object or anonymous function call should begin and end with the

### Invalid examples:
### Invalid examples

@@ -31,2 +32,3 @@ ```js

```
The inner function should have started on the same line as the outer

@@ -36,9 +38,10 @@ and the inner function's closing bracket should be indented to the same level

```
```js
fn(arg1, arg2,
arg3);
```
The arg3 should have been on the same line as the other two.
```
```js
promise.then(function() {

@@ -59,5 +62,6 @@ yayItWorked();

```
Only one multiline argument is allowed.
### Valid examples:
### Valid examples

@@ -64,0 +68,0 @@ ```js

@@ -73,7 +73,10 @@ /**

if (node.object.type === 'CallExpression' && !sameLine && lastLineIndent !== propertyLineIndent) {
if (!sameLine && lastLineIndent !== propertyLineIndent) {
context.report({
node: node.object,
message: 'Call expression should be on a new line and indented',
node: node.property,
message: 'Expected identifier "{{ identifier }}" to align with preceding {{ object }}',
data: {
identifier: node.property.name,
object: node.object.type,
},
});

@@ -84,9 +87,27 @@ }

function checkMemberExpression(node) {
var numberOfLines = node.property.loc.start.line - node.object.loc.end.line + 1,
objectComments = helper.sourceCode.getCommentsAfter(node.object);
var objectComments,
numberOfLines;
if (node.object.type === 'FunctionExpression') {
numberOfLines = node.property && node.object
? node.property.loc.start.line - node.object.loc.end.line + 1
: null;
// If this is an array accessor, pass if it's on the same line as its
// parent member expression's EOL.
if (node.property && node.type === 'MemberExpression' && node.computed && node.property.type === 'Literal') {
// This is an array accessor, check the previous node.
let parentNode = node.parent;
if (parentNode && parentNode.loc.end.line === node.property.loc.start.line) {
// It's okay for array accessors to be on the same line.
return;
}
}
if (node.object && node.object.type === 'FunctionExpression' || numberOfLines === null) {
return;
}
objectComments = helper.sourceCode.getCommentsAfter(node.object);
// if there are leading comments, we need to subtract their lines from the number

@@ -123,3 +144,3 @@ // of lines of the expression or we will not be able to put comments between

return {
'MemberExpression': checkMemberExpression,
'CallExpression, MemberExpression': checkMemberExpression,
};

@@ -126,0 +147,0 @@

{
"name": "@silvermine/eslint-plugin-silvermine",
"version": "2.4.0",
"version": "2.5.0",
"description": "eslint plugins to support our JS Code Standards. See @silvermine/eslint-config-silvermine",
"scripts": {
"test": "check-node-version --npm 6.14.12 && nyc mocha -- 'tests/**/*.test.js'",
"check-node-version": "check-node-version --npm 10.5.0",
"test": "nyc mocha -- 'tests/**/*.test.js'",
"commitlint": "commitlint --from 2317166",
"eslint": "eslint .",
"markdownlint": "markdownlint -c .markdownlint.json -i CHANGELOG.md '{,!(node_modules)/**/}*.md'",
"standards": "npm run markdownlint && npm run eslint",
"release:preview": "node ./node_modules/@silvermine/standardization/scripts/release.js preview",

@@ -35,14 +39,8 @@ "release:prep-changelog": "node ./node_modules/@silvermine/standardization/scripts/release.js prep-changelog",

"devDependencies": {
"@commitlint/cli": "12.1.1",
"@commitlint/travis-cli": "12.1.1",
"@silvermine/eslint-config": "3.1.0-beta.1",
"@silvermine/standardization": "1.3.0",
"@silvermine/standardization": "2.0.0",
"@typescript-eslint/parser": "5.17.0",
"check-node-version": "4.0.2",
"coveralls": "3.0.9",
"cz-conventional-changelog": "3.0.2",
"eslint": "8.12.0",
"grunt": "1.4.1",
"grunt-cli": "1.4.3",
"grunt-eslint": "24.0.0",
"mocha": "5.2.0",

@@ -49,0 +47,0 @@ "nyc": "15.1.0",

@@ -15,7 +15,8 @@ # Silvermine ESLint Plugin

Shareable [ESLint](http://eslint.org/) plugins that are used by our shareable config rules.
See [eslint-config-silvermine](https://github.com/silvermine/eslint-config-silvermine/) for more details.
See [eslint-config-silvermine][1] for more details.
## Why?
Because we need it. Whitespace errors are evil. As are the other hundreds of types of errors this protects us from.
Because we need it. Whitespace errors are evil. As are the other hundreds of types of errors
this protects us from.

@@ -26,4 +27,7 @@ ## Installation

```
```shell
$ npm install eslint --save-dev
+ eslint@8.16.0
installed 9 packages and audited 955 packages in 5.833s
```

@@ -33,4 +37,7 @@

```
```shell
$ npm install @silvermine/eslint-plugin-silvermine --save-dev
+ @silvermine/eslint-plugin-silvermine@2.4.0
installed 1 package and audited 955 packages in 4.95s
```

@@ -40,3 +47,4 @@

Add `silvermine` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
Add `silvermine` to the plugins section of your `.eslintrc` configuration file. You can
omit the `eslint-plugin-` prefix:

@@ -64,6 +72,6 @@ ```json

- [fluent-chaining](docs/rules/fluent-chaining.md)
- [call-indentation](docs/rules/call-indentation.md)
- [array-indentation](docs/rules/array-indentation.md)
- [no-multiple-inline-functions](docs/rules/no-multiple-inline-functions.md)
* [fluent-chaining](docs/rules/fluent-chaining.md)
* [call-indentation](docs/rules/call-indentation.md)
* [array-indentation](docs/rules/array-indentation.md)
* [no-multiple-inline-functions](docs/rules/no-multiple-inline-functions.md)

@@ -94,1 +102,3 @@

This software is released under the MIT license. See [the license file](LICENSE) for more details.
[1]: <https://github.com/silvermine/eslint-config-silvermine/>

@@ -15,3 +15,4 @@ /**

path = require('path'),
ruleTester = new RuleTester();
ruleTester = new RuleTester(),
es6RuleTester = require('../../ruleTesters').es6();

@@ -79,2 +80,18 @@ // ------------------------------------------------------------------------------

function checkAllowMemberExpressionWithArrayAccess() {
return {
code: formatCode(
'"https://google.com/#home?greeting=hello"',
' .split()[0];'
),
errors: [],
output: [
formatCode(
'"https://google.com/#home?greeting=hello"',
' .split()[0];'
),
],
};
}
function checkNewLineErrorWithTabOption() {

@@ -199,9 +216,25 @@ return {

function chainingIndentationMatchErrorMessage() {
function checkSpacingErrorWhenFunctionIsAwaited() {
return {
message: 'Call expression should be on a new line and indented',
type: 'CallExpression',
code: formatCode(
'(async () => {',
' (await doSomething({',
' prop: true',
' }))',
' .exec();',
'})'
),
errors: [
chainingIndentationMatchErrorMessage('exec', 'AwaitExpression'),
],
};
}
function chainingIndentationMatchErrorMessage(identifier, objectType) {
return {
message: `Expected identifier "${identifier}" to align with preceding ${objectType}`,
type: 'Identifier',
};
}
// Successive calls should not be indented at different levels

@@ -222,3 +255,3 @@ function checkChainingIndentationError1() {

errors: [
chainingIndentationMatchErrorMessage(),
chainingIndentationMatchErrorMessage('spread', 'CallExpression'),
],

@@ -240,3 +273,3 @@ };

errors: [
chainingIndentationMatchErrorMessage(),
chainingIndentationMatchErrorMessage('then', 'CallExpression'),
],

@@ -246,2 +279,49 @@ };

function checkChainingIndentationError3() {
return {
code: formatCode(
'new Class({',
' prop: true',
'})',
' .exec();'
),
errors: [
chainingIndentationMatchErrorMessage('exec', 'NewExpression'),
],
};
}
function checkChainingIndentationError4() {
return {
code: formatCode(
'new Class({',
' items: [',
' 1,',
' 2,',
' ]',
' .filter(isNotNullOrUndefined),',
'});'
),
errors: [
chainingIndentationMatchErrorMessage('filter', 'ArrayExpression'),
],
};
}
function checkChainingIndentationError5() {
return {
code: formatCode(
'var arr = [',
' 1,',
' 2,',
']',
' .filter(isNotNullOrUndefined);'
),
errors: [
chainingIndentationMatchErrorMessage('filter', 'ArrayExpression'),
],
};
}
// ------------------------------------------------------------------------------

@@ -268,2 +348,7 @@ // Tests

ruleTester.run('fluent-chaning - checkAllowMemberExpressionWithArrayAccess', fluentChaining, {
valid: [ checkAllowMemberExpressionWithArrayAccess() ],
invalid: [],
});
ruleTester.run('fluent-chaining - checkNewLineError', fluentChaining, {

@@ -304,2 +389,7 @@ valid: [],

es6RuleTester.run('fluent-chaining - checkSpacingErrorWhenFunctionIsAwaited', fluentChaining, {
valid: [],
invalid: [ checkSpacingErrorWhenFunctionIsAwaited() ],
});
ruleTester.run('fluent-chaining - checkChainingIndentationError1', fluentChaining, {

@@ -314,1 +404,16 @@ valid: [],

});
ruleTester.run('fluent-chaining - checkChainingIndentationError3', fluentChaining, {
valid: [],
invalid: [ checkChainingIndentationError3() ],
});
ruleTester.run('fluent-chaining - checkChainingIndentationError4', fluentChaining, {
valid: [],
invalid: [ checkChainingIndentationError4() ],
});
ruleTester.run('fluent-chaining - checkChainingIndentationError5', fluentChaining, {
valid: [],
invalid: [ checkChainingIndentationError5() ],
});

@@ -0,1 +1,2 @@

/* eslint-disable */
/**

@@ -117,1 +118,8 @@ * @fileoverview This file contains examples of valid chained expressions

});
// VALID - array accessors used on call expressions are an accepted pattern
'https://google.com/#home?greeting=hello'
// Remove any query string:
.split('?')[0]
// Remove any hash:
.split('#')[0];

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc