Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

eslint-config-squarespace

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-config-squarespace - npm Package Compare versions

Comparing version
1.0.1
to
2.0.0
test/__snapshots__/test.js.snap

Sorry, the diff of this file is not supported yet

+46
const path = require('path');
const fs = require('fs');
const { CLIEngine } = require('eslint');
function lintFixtures(config, fixturePath) {
const newConfig = {
root: true,
useEslintrc: false,
baseConfig: config,
};
const cli = new CLIEngine(newConfig);
const fixtures = fs
.readdirSync(fixturePath)
.filter((filename) => /\.js|\.ts$/.test(filename));
return fixtures.map((fileName) => {
const code = fs.readFileSync(path.join(fixturePath, fileName)).toString();
const result = cli.executeOnText(code);
return { fileName, result };
});
}
describe('eslintConfig', function () {
const rootPath = path.join(__dirname, '__fixtures__');
const newConfig = Object.assign(require('../index.js'));
const fixtures = lintFixtures(newConfig, rootPath);
fixtures.forEach(({ fileName, result }) => {
test(fileName, function () {
const numOfErrors = result.errorCount + result.warningCount;
const shouldReportErrors =
fileName.indexOf('bad.js') === -1 && numOfErrors > 0;
if (shouldReportErrors) {
result.results.forEach(({ messages }) => {
console.log('messages', messages);
});
}
if (fileName.indexOf('bad.js') !== -1) {
expect(numOfErrors).toBeGreaterThan(0);
}
expect(numOfErrors).toMatchSnapshot();
});
});
});
+91
-10

@@ -1,10 +0,91 @@

var vanilla = require('./vanilla');
var react = require('./react');
var eslintrc = JSON.parse(JSON.stringify(vanilla));
eslintrc.plugins = react.plugins;
Object.keys(react.rules).forEach(function assignRule(ruleId) {
eslintrc.rules[ruleId] = react.rules[ruleId];
});
module.exports = eslintrc;
module.exports = {
'extends': 'eslint:recommended',
'parserOptions': {
'ecmaVersion': 2018,
'requireConfigFile': false
},
'env': {
'browser': true,
'node': true,
'es6': true
},
'rules': {
'no-extra-boolean-cast': 'error',
'no-extra-semi': 'error',
'brace-style': ['warn', '1tbs', { 'allowSingleLine': true }],
'object-curly-spacing': ['warn', 'always'],
'wrap-iife': ['error', 'any'],
'camelcase': 'error',
'comma-dangle': 'off',
'comma-spacing': 'warn',
'complexity': ['warn', { 'max': 8 }],
'comma-style': ['error', 'last'],
'consistent-return': 'off',
'curly': 'error',
'dot-notation': ['error', { 'allowKeywords': true }],
'eol-last': 'off',
'eqeqeq': 'error',
'indent': ['warn', 2],
'key-spacing': ['error', { 'beforeColon': false, 'afterColon': true }],
'keyword-spacing': 'warn',
'max-depth': ['warn', { 'max': 4 }],
'max-len': ['warn', { 'code': 120, 'tabWidth': 2 }],
'max-params': ['warn', { 'max': 4 }],
'new-cap': 'off',
'new-parens': 'error',
'no-alert': 'error',
'no-array-constructor': 'error',
'no-caller': 'error',
'no-catch-shadow': 'error',
'no-console': 'off',
'no-else-return': 'warn',
'no-empty': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'warn',
'no-extra-parens': 'off',
'no-implied-eval': 'error',
'no-invalid-regexp': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-lonely-if': 'warn',
'no-loop-func': 'error',
'no-multi-spaces': 'warn',
'no-multi-str': 'error',
'no-native-reassign': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-wrappers': 'error',
'no-new': 'error',
'no-octal-escape': 'error',
'no-process-exit': 'error',
'no-proto': 'error',
'no-redeclare': 'off',
'no-return-assign': 'error',
'no-script-url': 'error',
'no-sequences': 'error',
'no-shadow-restricted-names': 'error',
'no-shadow': 'error',
'no-spaced-func': 'error',
'no-trailing-spaces': 'warn',
'no-undef-init': 'error',
'no-underscore-dangle': 'off',
'no-unused-expressions': 'warn',
'no-unused-vars': ['warn', { 'args': 'none' }],
'no-use-before-define': 'error',
'no-whitespace-before-property': 'error',
'no-with': 'error',
'one-var-declaration-per-line': ['warn', 'always'],
'operator-linebreak': ['error', 'after'],
'quote-props': 'off',
'quotes': ['error', 'single', 'avoid-escape'],
'semi-spacing': ['error', { 'before': false, 'after': true }],
'semi': ['warn', 'always'],
'space-infix-ops': 'warn',
'space-unary-ops': ['error', { 'words': true, 'nonwords': false }],
'strict': 'off',
'yoda': ['error', 'never', { 'exceptRange': true }]
}
};
+7
-10
{
"name": "eslint-config-squarespace",
"description": "Eslint shareable configuration for Squarespace",
"version": "1.0.1",
"version": "2.0.0",
"author": "Squarespace",

@@ -9,4 +9,3 @@ "license": "Apache-2.0",

"scripts": {
"test": "mocha ./test/runTests.js",
"lint": "eslint"
"test": "jest ./test/*"
},

@@ -34,11 +33,9 @@ "repository": {

"peerDependencies": {
"eslint": ">=3.0.1"
"eslint": ">=3.0.0"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"chai": "^3.5.0",
"eslint": "^3.12.2",
"eslint-plugin-react": "^6.8.0",
"mocha": "^3.2.0"
}
"eslint": "^7.19.0",
"jest": "^26.6.3"
},
"dependencies": {}
}
# eslint-config-squarespace
Provides the universal configuration for [eslint](https://github.com/eslint) at [Squarespace](https://www.squarespace.com).
Provides the [eslint](https://github.com/eslint) configuration for linting [Squarespace](https://www.squarespace.com) publicly available projects.
## Installation
### Without React
````sh
$ npm install --save-dev eslint-config-squarespace babel-eslint
$ npm install --save-dev eslint-config-squarespace
````

@@ -15,11 +13,11 @@

add "extends": "eslint-config-squarespace" to your .eslintrc
add `"extends": "eslint-config-squarespace"` to your `.eslintrc`
#### Example .eslintrc
### Example .eslintrc
````json
{
"extends": "eslint-config-squarespace/vanilla",
"extends": "eslint-config-squarespace",
"env": {
"browser": true,
"mocha": true,
"jest": true,
"node": true

@@ -30,84 +28,4 @@ }

### With React
````sh
$ npm install --save-dev eslint-config-squarespace babel-eslint eslint-plugin-react
````
## License
#### Example .eslintrc
````json
{
"extends": "squarespace",
"env": {
"browser": true,
"mocha": true,
"node": true
},
"plugins": [
"react"
]
}
````
### Integrating with Webpack
You may add eslint config to a webpack build process by using a preloader and
some eslint config. There should be no need to reference this config file provided
the .eslintrc 'extends' property is set.
````sh
$ npm install --save eslint-loader
````
````js
// webpack.config.js
module: {
eslint: {
configFile: path.join(pathsToESlint, '.eslintrc'),
failOnError: true
},
module: {
preLoaders: [
{
test: /\.jsx?$/,
loader: 'eslint',
include: pathsToFiles
}
],
..
}
````
### Troubleshooting
#### Webpack
The webpack plugin for pre-linting is notoriously slow, because it can not leverage
and form of caching available to either eslint _or_ webpack. If it is too slow, try moving it to the npm command that starts the webpack build.
#### Global Eslint
Global CLI installations of eslint cannot find local modules. This is [expected behavior](https://github.com/eslint/eslint/issues/1238). Tools or scripts that
rely on such global installations must be rewritten or modified to find the
correct node_modules folder.
#### Fix Syntastic for Vim
If you are using syntastic, adding the following to your `.vimrc` should fix eslint.
````vimrc
" Kludge to fix global/local.
let g:syntastic_javascript_checkers = ['eslint']
let local_eslint = finddir('node_modules', '.;') . '/.bin/eslint'
if matchstr(local_eslint, "^\/\\w") == ''
let local_eslint = getcwd() . "/" . local_eslint
endif
if executable(local_eslint)
let g:syntastic_javascript_eslint_exec = local_eslint
endif
````
### License
Apache-2 copyright Squarespace
{
"extends": [
"./vanilla/.eslintrc",
"./react/.eslintrc"
],
"rules": {
"comma-dangle": "off"
},
"env": {
"browser": true,
"node": true,
"mocha": true
},
"globals": {
"__DEV__": true
}
}

Sorry, the diff of this file is not supported yet

{
"extends": "plugin:react/recommended",
"plugins": [
"react"
],
"rules": {
"jsx-quotes": "warn",
"react/display-name": "off",
"react/jsx-pascal-case": "warn",
"react/jsx-uses-react": "warn",
"react/jsx-uses-vars": "warn",
"react/jsx-no-undef": "error",
"react/no-danger": "off",
"react/no-deprecated": "off",
"react/no-did-mount-set-state": "warn",
"react/no-did-update-set-state": "warn",
"react/no-direct-mutation-state": "warn",
"react/no-is-mounted": "warn",
"react/no-multi-comp": ["warn", {"ignoreStateless": true}],
"react/no-unknown-property": "warn",
"react/prop-types": ["warn", {
"ignore": ["className", "children", "style"]
}],
"react/react-in-jsx-scope": "warn",
"react/self-closing-comp": "warn",
"react/jsx-wrap-multilines": "warn",
"react/sort-comp": ["warn", {
"order": [
"displayName",
"propTypes",
"contextTypes",
"childContextTypes",
"mixins",
"statics",
"defaultProps",
"constructor",
"getDefaultProps",
"getInitialState",
"getChildContext",
"componentWillMount",
"componentDidMount",
"componentWillReceiveProps",
"shouldComponentUpdate",
"componentWillUpdate",
"componentDidUpdate",
"componentWillUnmount",
"/^on.+$/",
"/^handle.+$/",
"/^get.+$/",
"/^(?!render).+$/",
"/^render.+$/",
"render"
]
}]
}
}
var fs = require('fs');
var path = require('path');
module.exports = JSON.parse(fs.readFileSync(path.join(__dirname, '.eslintrc')));
const React = require('react');
const ListItem = props => {
return <li> {props.item} </li>;
};
const ShoppingList = React.createComponent({
render() {
return <div className="shopping-list" onClick={this.props.onClick}>
<h1>Shopping List for {this.props.name}</h1>
<ul>
<ListItem item="Instagram" />
<ListItem item="WhatsApp" />
<ListItem item="Oculus" />
</ul>
</div>;
},
handleClick(e) {
this.props.onClick();
},
getDefaultProps() {
return {
name: 'Johnathan Doe',
};
},
});
module.exports = ShoppingList;
const React = require('react');
const ListItem = props => (
<li>
{props.item}
</li>
);
ListItem.propTypes = {
item: React.PropTypes.string,
};
class ShoppingList extends React.Component {
getDefaultProps() {
return {
name: 'Johnathan Doe',
};
}
handleClick(e) {
this.props.onClick();
}
render() {
return (
<div className="shopping-list" onClick={this.props.onClick}>
<h1>Shopping List for {this.props.name}</h1>
<ul>
<ListItem item="Instagram" />
<ListItem item="WhatsApp" />
<ListItem item="Oculus" />
</ul>
</div>
);
}
}
ShoppingList.propTypes = {
name: React.PropTypes.string,
onClick: React.PropTypes.func.required,
};
module.exports = ShoppingList;
var eslint = require('eslint');
var CLIEngine = eslint.CLIEngine;
var chai = require('chai');
var fs = require('fs');
var path = require('path');
var expect = chai.expect;
describe('eslintConfig', function() {
var rootPath = path.join(__dirname, '__fixtures__');
var fixtures = fs.readdirSync(rootPath);
var cli = new CLIEngine(Object.assign(require('../index.js'), {
useEslintrc: false,
}));
fixtures.forEach(function(p) {
var code = fs.readFileSync(path.join(rootPath, p)).toString();
var result = cli.executeOnText(code);
it(p, function() {
if (p.indexOf('bad.js') !== -1) {
expect(result.errorCount + result.warningCount).to.not.equal(0);
} else {
expect(result.errorCount + result.warningCount).to.equal(0);
if (result.errorCount + result.warningCount > 0) {
console.log(result);
}
}
});
});
});
{
"extends": "eslint:recommended",
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"no-extra-boolean-cast": "error",
"no-extra-semi": "error",
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
"object-curly-spacing": ["warn", "always"],
"wrap-iife": ["error", "any"],
"camelcase": "error",
"comma-dangle": "off",
"comma-spacing": "warn",
"complexity": ["warn", { "max": 8 }],
"comma-style": ["error", "last"],
"consistent-return": "off",
"curly": "error",
"dot-notation": ["error", { "allowKeywords": true }],
"eol-last": "off",
"eqeqeq": "error",
"indent": ["warn", 2],
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
"keyword-spacing": "warn",
"max-depth": ["warn", { "max": 4 }],
"max-len": ["warn", { "code": 120, "tabWidth": 2 }],
"max-params": ["warn", { "max": 4 }],
"new-cap": "off",
"new-parens": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-console": "off",
"no-else-return": "warn",
"no-empty": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "warn",
"no-extra-parens": "off",
"no-implied-eval": "error",
"no-invalid-regexp": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "warn",
"no-loop-func": "error",
"no-multi-spaces": "warn",
"no-multi-str": "error",
"no-native-reassign": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-wrappers": "error",
"no-new": "error",
"no-octal-escape": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-redeclare": "off",
"no-return-assign": "error",
"no-script-url": "error",
"no-sequences": "error",
"no-shadow-restricted-names": "error",
"no-shadow": "error",
"no-spaced-func": "error",
"no-trailing-spaces": "warn",
"no-undef-init": "error",
"no-underscore-dangle": "off",
"no-unused-expressions": "warn",
"no-unused-vars": ["warn", {"args": "none"}],
"no-use-before-define": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"one-var-declaration-per-line": ["warn", "always"],
"operator-linebreak": ["error", "after"],
"quote-props": "off",
"quotes": ["error", "single", "avoid-escape"],
"semi-spacing": ["error", {"before": false, "after": true}],
"semi": ["warn", "always"],
"space-infix-ops": "warn",
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
"strict": "off",
"yoda": ["error", "never", { "exceptRange": true }]
}
}
var fs = require('fs');
var path = require('path');
module.exports = JSON.parse(fs.readFileSync(path.join(__dirname, '.eslintrc')));