Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change allowTransparency to allowtransparency #1538

Merged
merged 1 commit into from Dec 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions lib/rules/no-unknown-property.js
Expand Up @@ -6,6 +6,7 @@
'use strict';

const docsUrl = require('../util/docsUrl');
const versionUtil = require('../util/version');

// ------------------------------------------------------------------------------
// Constants
Expand Down Expand Up @@ -117,7 +118,7 @@ const SVGDOM_ATTRIBUTE_NAMES = {

const DOM_PROPERTY_NAMES = [
// Standard
'acceptCharset', 'accessKey', 'allowFullScreen', 'allowTransparency', 'autoComplete', 'autoFocus', 'autoPlay',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, it should be present unless the React version declared in the settings is 16.1+.

'acceptCharset', 'accessKey', 'allowFullScreen', 'autoComplete', 'autoFocus', 'autoPlay',
'cellPadding', 'cellSpacing', 'classID', 'className', 'colSpan', 'contentEditable', 'contextMenu',
'dateTime', 'encType', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget',
'frameBorder', 'hrefLang', 'htmlFor', 'httpEquiv', 'inputMode', 'keyParams', 'keyType', 'marginHeight', 'marginWidth',
Expand All @@ -133,6 +134,13 @@ const DOM_PROPERTY_NAMES = [
'autoSave',
'itemProp', 'itemScope', 'itemType', 'itemRef', 'itemID'
];
function getDOMPropertyNames(context) {
// this was removed in React v16.1+, see https://github.com/facebook/react/pull/10823
if (!versionUtil.testReactVersion(context, '16.1.0')) {
return ['allowTransparency'].concat(DOM_PROPERTY_NAMES);
}
return DOM_PROPERTY_NAMES;
}

// ------------------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -185,21 +193,23 @@ function tagNameHasDot(node) {
/**
* Get the standard name of the attribute.
* @param {String} name - Name of the attribute.
* @param {String} context - eslint context
* @returns {String} The standard name of the attribute.
*/
function getStandardName(name) {
function getStandardName(name, context) {
if (DOM_ATTRIBUTE_NAMES[name]) {
return DOM_ATTRIBUTE_NAMES[name];
}
if (SVGDOM_ATTRIBUTE_NAMES[name]) {
return SVGDOM_ATTRIBUTE_NAMES[name];
}
let i = -1;
const found = DOM_PROPERTY_NAMES.some((element, index) => {
const names = getDOMPropertyNames(context);
const found = names.some((element, index) => {
i = index;
return element.toLowerCase() === name;
});
return found ? DOM_PROPERTY_NAMES[i] : null;
return found ? names[i] : null;
}

// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -262,7 +272,7 @@ module.exports = {
});
}

const standardName = getStandardName(name);
const standardName = getStandardName(name, context);
if (!isTagName(node) || !standardName) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/util/version.js
Expand Up @@ -35,7 +35,7 @@ function detectReactVersion() {
function getReactVersionFromContext(context) {
let confVer = '999.999.999';
// .eslintrc shared settings (http://eslint.org/docs/user-guide/configuring#adding-shared-settings)
if (context.settings.react && context.settings.react.version) {
if (context.settings && context.settings.react && context.settings.react.version) {
let settingsVersion = context.settings.react.version;
if (settingsVersion === 'detect') {
settingsVersion = detectReactVersion();
Expand Down