From 32c0d9a0b901a7478380d324efb8cbf825d3dab8 Mon Sep 17 00:00:00 2001 From: Haakan Sjoelin Date: Sun, 10 Dec 2017 18:11:00 +1100 Subject: [PATCH 1/3] Updates to react and react-a11y to comply with errors seen in vscode: - ecmaFeatures config being deprecated - jsx-a11y/label-has-for requiring ['label'] to be an object - jsx-a11y/heading-has-content requiring [''] to be an object --- rules/react-a11y.js | 7 ++----- rules/react.js | 3 --- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/rules/react-a11y.js b/rules/react-a11y.js index 9e1c664..5b23c21 100644 --- a/rules/react-a11y.js +++ b/rules/react-a11y.js @@ -3,9 +3,6 @@ module.exports = { 'jsx-a11y', 'react' ], - ecmaFeatures: { - jsx: true - }, rules: { // Enforce that anchors have content // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/anchor-has-content.md @@ -43,7 +40,7 @@ module.exports = { // require that JSX labels use "htmlFor" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/label-has-for.md - 'jsx-a11y/label-has-for': [2, ['label']], + 'jsx-a11y/label-has-for': [2, { "components": ["label"] }], // require that mouseover/out come with focus/blur, for keyboard-only users // TODO: evaluate @@ -84,7 +81,7 @@ module.exports = { // ensure tags have content and are not aria-hidden // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md - 'jsx-a11y/heading-has-content': [2, ['']], + 'jsx-a11y/heading-has-content': [2, { "components": [''] }], // require HTML elements to have a "lang" prop // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/html-has-lang.md diff --git a/rules/react.js b/rules/react.js index 53961c3..7065c70 100644 --- a/rules/react.js +++ b/rules/react.js @@ -7,9 +7,6 @@ module.exports = { jsx: true, }, }, - ecmaFeatures: { - jsx: true - }, // View link below for react rules documentation // https://github.com/yannickcr/eslint-plugin-react#list-of-supported-rules From 781e072a5dcd7fb374048bf58d1c0a1b5601645c Mon Sep 17 00:00:00 2001 From: Haakan Sjoelin Date: Sun, 10 Dec 2017 18:30:39 +1100 Subject: [PATCH 2/3] fix deprecating rule (see documentation for removed rule) --- rules/react.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rules/react.js b/rules/react.js index 7065c70..5f01db1 100644 --- a/rules/react.js +++ b/rules/react.js @@ -178,8 +178,12 @@ module.exports = { 'react/self-closing-comp': 2, // Enforce spaces before the closing bracket of self-closing JSX elements - // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-space-before-closing.md - 'react/jsx-space-before-closing': [2, 'always'], + // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md + 'react/jsx-tag-spacing': { + "closingSlash": "never", + "beforeSelfClosing": "always", + "afterOpening": "never" + }, // Enforce component methods order // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md From 6f1f6babbe7b8c2f645a43fa14d04634228eab75 Mon Sep 17 00:00:00 2001 From: Haakan Sjoelin Date: Sun, 10 Dec 2017 18:44:47 +1100 Subject: [PATCH 3/3] fixed jsx-tag-spacing, and removed couple of rules no longer available in newer versions of react and react-a11y --- rules/react-a11y.js | 6 +++--- rules/react.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/rules/react-a11y.js b/rules/react-a11y.js index 5b23c21..ba07d18 100644 --- a/rules/react-a11y.js +++ b/rules/react-a11y.js @@ -28,11 +28,11 @@ module.exports = { // disallow href "#" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/href-no-hash.md - 'jsx-a11y/href-no-hash': [2, ['a']], + //'jsx-a11y/href-no-hash': [2, ['a']], // Require to have a non-empty `alt` prop, or role="presentation" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-has-alt.md - 'jsx-a11y/img-has-alt': 2, + //'jsx-a11y/img-has-alt': 2, // Prevent img alt text from containing redundant words like "image", "picture", or "photo" // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/img-redundant-alt.md @@ -93,7 +93,7 @@ module.exports = { // prevent marquee elements // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-marquee.md - 'jsx-a11y/no-marquee': 2, + //'jsx-a11y/no-marquee': 2, // only allow to have the "scope" attr // https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/scope.md diff --git a/rules/react.js b/rules/react.js index 5f01db1..853b9d3 100644 --- a/rules/react.js +++ b/rules/react.js @@ -167,7 +167,7 @@ module.exports = { // Restrict file extensions that may be required // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md - 'react/require-extension': [2, { extensions: ['.jsx', '.js'] }], + //'react/require-extension': [2, { extensions: ['.jsx', '.js'] }], // Require render() methods to return something // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-render-return.md @@ -179,11 +179,11 @@ module.exports = { // Enforce spaces before the closing bracket of self-closing JSX elements // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-tag-spacing.md - 'react/jsx-tag-spacing': { - "closingSlash": "never", - "beforeSelfClosing": "always", - "afterOpening": "never" - }, + 'react/jsx-tag-spacing': [2, { + closingSlash: "never", + beforeSelfClosing: "always", + afterOpening: "never" + }], // Enforce component methods order // https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md