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

eslint-plugin-beautiful-sort

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-beautiful-sort - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "eslint-plugin-beautiful-sort",
"version": "1.0.2",
"version": "1.0.3",
"description": "eslint plugin for import sort",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -11,3 +11,5 @@ # eslint-plugin-beautiful-sort

import {a,b,c} from 'a';
import C, {h} from 'j';
import A from 'g';
import * as Meme from 'meme';
import React from 'react';

@@ -17,6 +19,8 @@ ```

```js
import React from 'react';
import A from 'g';
import {a,b,c} from 'a';
import './Test.css';
import React from 'react'; // special
import * as Meme from 'meme'; // namespace
import A from 'g'; // default
import C, {h} from 'j'; // defaultObj
import {a,b,c} from 'a'; // obj
import './Test.css'; // none
```

@@ -36,3 +40,3 @@

"special": ["react"],
"order": ["special", "default", "defaultObj", "obj", "none"]
"order": ["special", "namespace", "default", "defaultObj", "obj", "none"]
}]

@@ -39,0 +43,0 @@ }

const TYPES = require('./types');
const AST_TYPES = {
default: "ImportDefaultSpecifier",
obj: "ImportSpecifier"
default: 'ImportDefaultSpecifier',
obj: 'ImportSpecifier',
namespace: 'ImportNamespaceSpecifier',
}

@@ -29,2 +30,5 @@

break;
case this.isNamespace(node):
this.type = TYPES.namespace;
break;
case this.isNone(node):

@@ -68,4 +72,10 @@ this.type = TYPES.none;

isNone = (node) => node.specifiers.length === 0;
isNamespace = (node) => {
if( !node.specifiers.length ) return;
return node.specifiers[0].type === AST_TYPES.namespace;
}
}
module.exports = ImportWrap;

@@ -48,2 +48,3 @@ const eslint = require('eslint');

TYPES.special,
TYPES.namespace,
TYPES.default,

@@ -81,3 +82,4 @@ TYPES.defaultObj,

const test = importsState.special.sort((a, b) => {
// mutate importsState.special
importsState.special.sort((a, b) => {
const aIndex = specialState[a.node.source.value];

@@ -84,0 +86,0 @@ const bIndex = specialState[b.node.source.value];

@@ -83,4 +83,19 @@ const { RuleTester } = require('eslint');

errors: 4
},
{
code: combineCodeArr([
"import 'Test.scss';",
"import A from 'a';",
"import * as Kek from 'kek';",
"import React from 'react';",
]),
output: combineCodeArr([
"import React from 'react';",
"import * as Kek from 'kek';",
"import A from 'a';",
"import 'Test.scss';",
]),
errors: 4
}
]
})

@@ -6,2 +6,3 @@ const TYPES = {

obj: 'obj',
namespace: 'namespace',
none: 'none'

@@ -8,0 +9,0 @@ };

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