New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-ember-suave

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ember-suave - npm Package Compare versions

Comparing version 0.1.2 to 1.0.0

.eslintrc.js

72

config/recommended.js

@@ -1,3 +0,1 @@

'use strict';
module.exports = {

@@ -9,3 +7,2 @@ root: true,

},
parser: 'babel-eslint',
env: {

@@ -17,70 +14,21 @@ 'browser': true

],
extends: require.resolve('./base.js'),
rules: {
// Built-in Rules
'array-bracket-spacing': ['error', 'never'],
// ES6
'arrow-parens': ['error', 'always'],
'brace-style': ['error', '1tbs', {
'allowSingleLine': false
'generator-star-spacing': ['error', {
'before': false,
'after': true
}],
'camelcase': ['error', {
'properties': 'always'
}],
'comma-dangle': ['error', 'never'],
'comma-spacing': ['error', { 'before': false, 'after': true }],
'comma-style': ['error', 'last'],
'curly': ['error', 'all'],
'dot-notation': 'error',
'dot-location': ['error', 'property'],
'generator-star-spacing': ['error', {'before': false}],
'indent': ['error', 2, {
'SwitchCase': 1
}],
'key-spacing': ['error', {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': ['error', {'overrides': {'catch': {'after': false}}}],
'max-statements-per-line': ['error', { 'max': 1 }],
'new-cap': ['error', {
// Capital variables that can be used without `new`
'capIsNewExceptions': [
'A' // Ember.A
]
}],
'no-empty': 'error',
'no-multiple-empty-lines': ['error', {
'max': 1
}],
'no-spaced-func': 'error',
'no-trailing-spaces': 'error',
'no-useless-concat': 'error',
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'object-shorthand': ['error', 'always'],
'one-var': ['error', {
'uninitialized': 'always',
'initialized': 'never'
}],
'operator-linebreak': ['error', 'before'],
'prefer-spread': 'error',
'prefer-template': 'error',
'quotes': ['error', 'single', {
'avoidEscape': true
// Overrides for Ember
'new-cap': ['error', {
'capIsNewExceptions': ['A']
}],
'semi': ['error', 'always'],
'semi-spacing': ['error', {
'before': false,
'after': true
}],
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': ['error', 'never'],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'space-unary-ops': ['error', {
'words': false,
'nonwords': false
}],
'spaced-comment': ['error', 'always'],
// Ember Suave rules
// Custom rules
'ember-suave/no-const-outside-module-scope': 'error',

@@ -87,0 +35,0 @@ 'ember-suave/no-direct-property-access': 'error',

@@ -5,20 +5,11 @@ /**

*/
"use strict";
'use strict';
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
var requireIndex = require('requireindex');
var resolve = require('path').resolve;
var requireIndex = require("requireindex");
var resolve = require("path").resolve;
//------------------------------------------------------------------------------
// Plugin Definition
//------------------------------------------------------------------------------
// import all rules in lib/rules
module.exports.rules = requireIndex(__dirname + "/rules");
module.exports.rules = requireIndex(__dirname + '/rules');
// import all configurations in ../config
module.exports.configs = requireIndex(resolve(__dirname, "../config"));
module.exports.configs = requireIndex(resolve(__dirname, '../config'));

@@ -5,10 +5,6 @@ /**

*/
"use strict";
'use strict';
var MESSAGE = '`const` should only be used in module scope (not inside functions/blocks).';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {

@@ -20,9 +16,2 @@ meta: {

create: function(context) {
// variables should be defined here
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
// declaration is a `export const foo = 'asdf'` in root of the module

@@ -55,6 +44,2 @@ function isModuleExport(node) {

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {

@@ -61,0 +46,0 @@ VariableDeclaration: checkNode

@@ -5,8 +5,4 @@ /**

*/
"use strict";
'use strict';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {

@@ -24,12 +20,8 @@ meta: {

create: function(context) {
var protectedVariables = context.options[0];
var protectedVariables = context.options[0];
if (!Boolean(protectedVariables) || protectedVariables.length == 0) {
protectedVariables = ["Ember", "DS"];
if (!protectedVariables || protectedVariables.length == 0) {
protectedVariables = ['Ember', 'DS'];
}
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
function objectIsProtected(item) {

@@ -54,6 +46,2 @@ return protectedVariables.indexOf(item) >= 0;

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {

@@ -60,0 +48,0 @@ MemberExpression: checkMemberExpression

@@ -5,8 +5,4 @@ /**

*/
"use strict";
'use strict';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {

@@ -29,3 +25,2 @@ meta: {

create: function(context) {
var checkArrays = true;

@@ -35,3 +30,3 @@ var checkObjects = true;

if (Boolean(options)) {
if (options) {
if (options.hasOwnProperty('array')) {

@@ -46,6 +41,2 @@ checkArrays = options.array;

//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
function isArrayIndexAccess(node) {

@@ -57,3 +48,3 @@ return Number.isInteger(node.property.value);

// Skip if variable is declared without assignment
if (!Boolean(node.init)) {
if (!node.init) {
return;

@@ -102,6 +93,2 @@ }

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {

@@ -108,0 +95,0 @@ VariableDeclarator: checkVariableDeclarator

@@ -5,11 +5,6 @@ /**

*/
"use strict";
'use strict';
var MESSAGE = 'You must supply `@public`, `@private`, or `@protected` for block comments.';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {

@@ -21,9 +16,2 @@ meta: {

create: function(context) {
// variables should be defined here
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
function isDocComment(comment) {

@@ -46,6 +34,2 @@ return comment.value[0] === '*';

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {

@@ -52,0 +36,0 @@ BlockComment: checkNode

@@ -5,10 +5,6 @@ /**

*/
"use strict";
'use strict';
var MESSAGE = "Always use `const` when making variables from Ember properties";
var MESSAGE = 'Always use `const` when making variables from Ember properties';
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {

@@ -19,9 +15,2 @@ meta: {

create: function(context) {
// variables should be defined here
//--------------------------------------------------------------------------
// Helpers
//--------------------------------------------------------------------------
function checkVariableDeclaration(node) {

@@ -35,9 +24,7 @@ var declaration = node.declarations[0];

/**
* Check whether the variables is being created from the Ember global
*/
function hasEmberIdentifier(declaration) {
// Check whether the variable is being created from the Ember global
var init = declaration.init;
if (!Boolean(init)) {
if (!init) {
return false;

@@ -61,6 +48,2 @@ }

//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {

@@ -67,0 +50,0 @@ VariableDeclaration: checkVariableDeclaration

{
"name": "eslint-plugin-ember-suave",
"version": "0.1.2",
"description": "Make your Ember App Stylish",
"version": "1.0.0",
"description": "DockYard's ESLint plugin for Ember apps",
"keywords": [

@@ -24,6 +24,5 @@ "eslint",

"scripts": {
"test": "mocha tests tests/lib/rules/*.js tests/config/*.js"
"test": "mocha tests tests/lib/rules/*.js tests/**/*-test.js"
},
"dependencies": {
"babel-eslint": "^6.1.2",
"requireindex": "~1.1.0"

@@ -34,8 +33,8 @@ },

"eslint": "^3.0.0",
"mocha": "^2.5.3"
"mocha": "^2.5.3",
"mocha-eslint": "^3.0.1"
},
"engines": {
"node": ">=0.10.0"
},
"license": "ISC"
}
}

@@ -1,57 +0,77 @@

# eslint-plugin-ember-suave [![Build Status](https://travis-ci.org/DockYard/eslint-plugin-ember-suave.svg?branch=master)](https://travis-ci.org/DockYard/eslint-plugin-ember-suave)
Make your Ember App Stylish
# eslint-plugin-ember-suave
**THIS PROJECT IS A WORK IN PROGRESS:** Ember Suave is being ported to ESLint, and this repo is porting the rules to the new platform. See [this Github issue](https://github.com/DockYard/ember-suave/issues/113) for more information.
[![Build Status](https://travis-ci.org/DockYard/eslint-plugin-ember-suave.svg?branch=master)](https://travis-ci.org/DockYard/eslint-plugin-ember-suave)
## Installation
This ESLint plugin exports custom linting rules and a `recommended` configuration based on [DockYard's styleguide](https://github.com/DockYard/styleguides/tree/master/engineering). It is tailored for Ember apps specifically, and may be used in conjunction with [ember-cli-eslint](https://github.com/ember-cli/ember-cli-eslint), or with the ESLint [CLI](http://eslint.org/docs/user-guide/command-line-interface).
You'll first need to install [ESLint](http://eslint.org):
## Using the plugin with Ember CLI
### Installation
Install the plugin as a dev dependency in your Ember CLI project.
```bash
npm install --save-dev eslint-plugin-ember-suave
```
$ npm i eslint --save-dev
This will make the plugin available to ESLint.
Next, install the [ember-cli-eslint](https://github.com/ember-cli/ember-cli-eslint) addon so that your app can be linted during development and testing. _This will also uninstall [ember-cli-jshint](https://github.com/ember-cli/ember-cli-jshint) since there is no need to have both linters running at the same time._
```bash
ember install ember-cli-eslint
```
Next, install `eslint-plugin-ember-suave`:
### Configuration
The `ember-cli-eslint` addon blueprint generates a `.eslintrc.js` configuration file at the root of the project. By default, it is set to extend ESLint's recommended subset of [core linting rules](http://eslint.org/docs/rules/).
Add the plugin's
[`recommended`](https://github.com/DockYard/eslint-plugin-ember-suave/blob/master/config/recommended.js) configuration to the list of extensions:
```js
// .eslintrc.js
module.exports = {
// ...
extends: [
'eslint:recommended',
'plugin:ember-suave/recommended'
],
rules: {
}
};
```
$ npm install eslint-plugin-ember-suave --save-dev
```
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-ember-suave` globally.
### Overriding Rules
## Usage
Both core rules (provided by ESLint) and custom rules (prefixed by `ember-suave/`) from the plugin's `recommended` configuration can be turned off or modified, if desired.
There are a few ways to add the rules from `ember-suave` to your ESLint project. The easiest way is to extend your configuration from the one provided, like so:
```js
// .eslintrc.js
```json
{
"extends": [
"plugin:ember-suave/recommended"
]
}
module.exports = {
// ...
extends: [
'eslint:recommended',
'plugin:ember-suave/recommended'
],
rules: {
'quotes': ['error', 'double'],
'ember-suave/no-const-outside-module-scope': 'off'
}
};
```
Note that the first extension is placed there by default by `ember-cli-eslint`; you might not have it if you're not using that plugin, or if you've decided not to take their presets. Once you've extended from the recommended settings, you can turn them off or configure them as you like.
If you want more control over your linting, or would prefer adding rules one at a time, you can also include the plugin manually and individually enable rules. Add `ember-suave` to the `plugins` section of your `.eslintrc` configuration file, and then configure individual rules under the `rules` section. Note that rules will be disabled by default; you'll need to turn on each one that you want to use.
## Working with Editors and the CLI
```json
{
"plugins": [
"ember-suave"
],
"rules": {
"ember-suave/no-const-outside-module-scope": "error",
"ember-suave/no-direct-property-access": "error",
"ember-suave/prefer-destructuring": "error",
"ember-suave/require-access-in-comments": "error",
"ember-suave/require-const-for-ember-properties": "error"
}
}
If you use ESLint in an editor or from the command line, you'll need to install `eslint-plugin-ember-suave` globally too.
```bash
npm install -g eslint-plugin-ember-suave
```
Details about rules and their configuration options are provided below.
## Rules
A list of supported rules and documentation can be found [here](docs/rules).
A list of custom rules and documentation can be found [here](docs/rules).

@@ -62,3 +82,3 @@ ## Development

Tests can be run using `npm test`. If you want to debug your rules within Mocha, you can use `npm run test:debug` to step inside your tests. Additionally, [AST Explorer](https://astexplorer.net/) is a great way to look into the structure of a node to determine what to expect.
Tests can be run using `npm test`. Additionally, [AST Explorer](https://astexplorer.net/) is a great way to look into the structure of a node to determine what to expect.

@@ -65,0 +85,0 @@ ## Authors

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