From 9b21d5fd19d913d95cdc4e786defdc41b11415d1 Mon Sep 17 00:00:00 2001 From: Nick Hwang Date: Tue, 15 Dec 2015 22:22:54 -0500 Subject: [PATCH] Update eslint plugin --- packages/eslint-config-hubspot/CHANGELOG.md | 63 +++++++++++++++++++ packages/eslint-config-hubspot/README.md | 42 ------------- packages/eslint-config-hubspot/base.js | 2 +- packages/eslint-config-hubspot/index.js | 2 +- packages/eslint-config-hubspot/legacy.js | 2 +- packages/eslint-config-hubspot/package.json | 6 +- packages/eslint-config-hubspot/rules/es6.js | 6 +- packages/eslint-config-hubspot/rules/react.js | 36 +++++++++-- packages/eslint-config-hubspot/rules/style.js | 11 ++-- 9 files changed, 112 insertions(+), 58 deletions(-) create mode 100644 packages/eslint-config-hubspot/CHANGELOG.md diff --git a/packages/eslint-config-hubspot/CHANGELOG.md b/packages/eslint-config-hubspot/CHANGELOG.md new file mode 100644 index 0000000000..bc269e9222 --- /dev/null +++ b/packages/eslint-config-hubspot/CHANGELOG.md @@ -0,0 +1,63 @@ +2.1.1 / 2015-12-15 +================== + - [fix] Remove deprecated react/jsx-quotes (#622) + +2.1.0 / 2015-12-15 +================== + - [fix] use `require.resolve` to allow nested `extend`s (#582) + - [new] enable `object-shorthand` rule (#621) + - [new] enable `arrow-spacing` rule (#517) + - [docs] flesh out react rule defaults (#618) + +2.0.0 / 2015-12-03 +================== + - [breaking] `space-before-function-paren`: require function spacing: `function (` (#605) + - [breaking] `indent`: Fix switch statement indentation rule (#606) + - [breaking] `array-bracket-spacing`, `computed-property-spacing`: disallow spacing inside brackets (#594) + - [breaking] `object-curly-spacing`: require padding inside curly braces (#594) + - [breaking] `space-in-parens`: disallow spaces in parens (#594) + +1.0.2 / 2015-11-25 +================== + - [breaking] `no-multiple-empty-lines`: only allow 1 blank line at EOF (#578) + - [new] `restParams`: enable rest params (#592) + +1.0.1 / 2015-11-25 +================== + - *erroneous publish* + +1.0.0 / 2015-11-08 +================== + - require `eslint` `v1.0.0` or higher + - remove `babel-eslint` dependency + +0.1.1 / 2015-11-05 +================== + - remove id-length rule (#569) + - enable `no-mixed-spaces-and-tabs` (#539) + - enable `no-const-assign` (#560) + - enable `space-before-keywords` (#554) + +0.1.0 / 2015-11-05 +================== + - switch to modular rules files courtesy the [eslint-config-default][ecd] project and [@taion][taion]. [PR][pr-modular] + - export `eslint-config-airbnb/legacy` for ES5-only users. `eslint-config-airbnb/legacy` does not require the `babel-eslint` parser. [PR][pr-legacy] + +0.0.9 / 2015-09-24 +================== +- add rule `no-undef` +- add rule `id-length` + +0.0.8 / 2015-08-21 +================== + - now has a changelog + - now is modular (see instructions above for with react and without react versions) + +0.0.7 / 2015-07-30 +================== + - TODO: fill in + +[ecd]: https://github.com/walmartlabs/eslint-config-defaults +[taion]: https://github.com/taion +[pr-modular]: https://github.com/airbnb/javascript/pull/526 +[pr-legacy]: https://github.com/airbnb/javascript/pull/527 diff --git a/packages/eslint-config-hubspot/README.md b/packages/eslint-config-hubspot/README.md index 4c2316f3f7..181b8ce34f 100644 --- a/packages/eslint-config-hubspot/README.md +++ b/packages/eslint-config-hubspot/README.md @@ -46,45 +46,3 @@ programming to structure our README as test cases for our .eslintrc? You can run tests with `npm test`. You can make sure this module lints with itself using `npm run lint`. - -## Changelog - -### 1.0.2 -- enable rest params in linter, derp. (#592) -- enforce rule 18.5, ensuring files end with a single newline character. (#578) - -### 1.0.1 - -oops - -### 1.0.0 -- require `eslint` `v1.0.0` or higher -- removes `babel-eslint` dependency - -### 0.1.1 -- remove id-length rule (#569) -- enable `no-mixed-spaces-and-tabs` (#539) -- enable `no-const-assign` (#560) -- enable `space-before-keywords` (#554) - -### 0.1.0 - -- switch to modular rules files courtesy the [eslint-config-default][ecd] - project and [@taion][taion]. [PR][pr-modular] -- export `eslint-config-airbnb/legacy` for ES5-only users. - `eslint-config-airbnb/legacy` does not require the `babel-eslint` parser. - [PR][pr-legacy] - -[ecd]: https://github.com/walmartlabs/eslint-config-defaults -[taion]: https://github.com/taion -[pr-modular]: https://github.com/airbnb/javascript/pull/526 -[pr-legacy]: https://github.com/airbnb/javascript/pull/527 - -### 0.0.9 - -- add rule no-undef -- add rule id-length - -### 0.0.8 - - now has a changelog - - now is modular (see instructions above for with react and without react versions) diff --git a/packages/eslint-config-hubspot/base.js b/packages/eslint-config-hubspot/base.js index 9af22602e8..0dc72dfe10 100644 --- a/packages/eslint-config-hubspot/base.js +++ b/packages/eslint-config-hubspot/base.js @@ -2,6 +2,6 @@ module.exports = { extends: [ 'eslint-config-hubspot/legacy', 'eslint-config-hubspot/rules/es6', - ], + ].map(require.resolve), rules: {} }; diff --git a/packages/eslint-config-hubspot/index.js b/packages/eslint-config-hubspot/index.js index a89c69aab8..fc0dcf2d07 100644 --- a/packages/eslint-config-hubspot/index.js +++ b/packages/eslint-config-hubspot/index.js @@ -2,6 +2,6 @@ module.exports = { extends: [ 'eslint-config-hubspot/base', 'eslint-config-hubspot/rules/react', - ], + ].map(require.resolve), rules: {} }; diff --git a/packages/eslint-config-hubspot/legacy.js b/packages/eslint-config-hubspot/legacy.js index 8992fcd2df..08c5661fa5 100644 --- a/packages/eslint-config-hubspot/legacy.js +++ b/packages/eslint-config-hubspot/legacy.js @@ -7,7 +7,7 @@ module.exports = { 'eslint-config-hubspot/rules/strict', 'eslint-config-hubspot/rules/style', 'eslint-config-hubspot/rules/variables' - ], + ].map(require.resolve), env: { browser: true, node: true, diff --git a/packages/eslint-config-hubspot/package.json b/packages/eslint-config-hubspot/package.json index d00807ab9a..182c47db1f 100644 --- a/packages/eslint-config-hubspot/package.json +++ b/packages/eslint-config-hubspot/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-hubspot", - "version": "1.0.7", + "version": "2.0.0", "description": "HubSpot's ESLint config, following our styleguide", "main": "index.js", "scripts": { @@ -32,8 +32,8 @@ "homepage": "https://github.com/HubSpot/javascript", "devDependencies": { "babel-tape-runner": "1.2.0", - "eslint": "^1.10.2", - "eslint-plugin-react": "^3.11.1", + "eslint": "^1.10.3", + "eslint-plugin-react": "^3.11.3", "faucet": "0.0.1", "react": "^0.13.3", "tape": "^4.2.2" diff --git a/packages/eslint-config-hubspot/rules/es6.js b/packages/eslint-config-hubspot/rules/es6.js index 1509ad9424..35d190d36b 100644 --- a/packages/eslint-config-hubspot/rules/es6.js +++ b/packages/eslint-config-hubspot/rules/es6.js @@ -26,7 +26,8 @@ module.exports = { // require parens in arrow function arguments 'arrow-parens': 0, // require space before/after arrow function's arrow - 'arrow-spacing': 0, + // https://github.com/eslint/eslint/blob/master/docs/rules/arrow-spacing.md + 'arrow-spacing': [2, { 'before': true, 'after': true }], // verify super() callings in constructors 'constructor-super': 0, // enforce the spacing around the * in generator functions @@ -40,7 +41,8 @@ module.exports = { // require let or const instead of var 'no-var': 2, // require method and property shorthand syntax for object literals - 'object-shorthand': 0, + // https://github.com/eslint/eslint/blob/master/docs/rules/object-shorthand.md + 'object-shorthand': [2, 'always'], // suggest using of const declaration for variables that are never modified after declared 'prefer-const': 2, // suggest using the spread operator instead of .apply() diff --git a/packages/eslint-config-hubspot/rules/react.js b/packages/eslint-config-hubspot/rules/react.js index 5ac5380513..4d41cdb006 100644 --- a/packages/eslint-config-hubspot/rules/react.js +++ b/packages/eslint-config-hubspot/rules/react.js @@ -7,44 +7,67 @@ module.exports = { }, 'rules': { // Prevent missing displayName in a React component definition + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md 'react/display-name': 0, // Enforce boolean attributes notation in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md 'react/jsx-boolean-value': [2, 'always'], + // Validate closing bracket location in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-closing-bracket-location.md + 'react/jsx-closing-bracket-location': [2, {'selfClosing': 'tag-aligned', 'nonEmpty': 'after-props'}], // Enforce or disallow spaces inside of curly braces in JSX attributes + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md 'react/jsx-curly-spacing': 0, + // Validate props indentation in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-indent-props.md + 'react/jsx-indent-props': [2, 2], // Prevent duplicate props in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md 'react/jsx-no-duplicate-props': 0, // Disallow undeclared variables in JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-undef.md 'react/jsx-no-undef': 2, - // Enforce quote style for JSX attributes - 'react/jsx-quotes': 0, // Enforce propTypes declarations alphabetical sorting + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-prop-types.md 'react/jsx-sort-prop-types': 0, // Enforce props alphabetical sorting + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-sort-props.md 'react/jsx-sort-props': 0, // Prevent React to be incorrectly marked as unused + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md 'react/jsx-uses-react': 2, // Prevent variables used in JSX to be incorrectly marked as unused + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md 'react/jsx-uses-vars': 2, // Prevent usage of dangerous JSX properties + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-danger.md 'react/no-danger': 0, // Prevent usage of setState in componentDidMount + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md 'react/no-did-mount-set-state': [2, 'allow-in-func'], // Prevent usage of setState in componentDidUpdate - 'react/no-did-update-set-state': 2, + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md + 'react/no-did-update-set-state': [2, 'allow-in-func'], // Prevent multiple component definition per file + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md 'react/no-multi-comp': 2, // Prevent usage of unknown DOM property + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md 'react/no-unknown-property': 2, // Prevent missing props validation in a React component definition + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md 'react/prop-types': 2, // Prevent missing React when using JSX + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md 'react/react-in-jsx-scope': 2, // Restrict file extensions that may be required + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md 'react/require-extension': 0, // Prevent extra closing tags for components without children + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md 'react/self-closing-comp': 2, // Enforce component methods order + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md 'react/sort-comp': [2, { 'order': [ 'lifecycle', @@ -75,6 +98,11 @@ module.exports = { } }], // Prevent missing parentheses around multilines JSX - 'react/wrap-multilines': 2 + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/wrap-multilines.md + 'react/wrap-multilines': [2, { + declaration: true, + assignment: true, + return: true + }] } }; diff --git a/packages/eslint-config-hubspot/rules/style.js b/packages/eslint-config-hubspot/rules/style.js index 8518d496ac..4ad35174d6 100644 --- a/packages/eslint-config-hubspot/rules/style.js +++ b/packages/eslint-config-hubspot/rules/style.js @@ -1,7 +1,7 @@ module.exports = { 'rules': { // enforce spacing inside array brackets - 'array-bracket-spacing': 0, + 'array-bracket-spacing': [2, 'never'], // enforce one true brace style 'brace-style': [2, '1tbs', {'allowSingleLine': true }], // require camel case names @@ -11,7 +11,7 @@ module.exports = { // enforce one true comma style 'comma-style': [2, 'last'], // require or disallow padding inside computed properties - 'computed-property-spacing': 0, + 'computed-property-spacing': [2, 'never'], // enforces consistent naming when capturing the current execution context 'consistent-this': 0, // enforce newline at the end of file, with no multiple empty lines @@ -23,8 +23,10 @@ module.exports = { // this option enforces minimum and maximum identifier lengths (variable names, property names etc.) 'id-length': 0, // this option sets a specific tab width for your code - 'indent': [2, 2], + // https://github.com/eslint/eslint/blob/master/docs/rules/indent.md + 'indent': [2, 2, { 'SwitchCase': 1, 'VariableDeclarator': 1 }], // specify whether double or single quotes should be used in JSX attributes + // http://eslint.org/docs/rules/jsx-quotes 'jsx-quotes': [2, 'prefer-double'], // enforces spacing between keys and values in object literal properties 'key-spacing': [2, {'beforeColon': false, 'afterColon': true}], @@ -95,9 +97,10 @@ module.exports = { // require or disallow space before blocks 'space-before-blocks': 2, // require or disallow space before function opening parenthesis + // https://github.com/eslint/eslint/blob/master/docs/rules/space-before-function-paren.md 'space-before-function-paren': [2, 'never'], // require or disallow spaces inside parentheses - 'space-in-parens': 0, + 'space-in-parens': [2, 'never'], // require spaces around operators 'space-infix-ops': 2, // require a space after return, throw, and case