✨ MAJOR FEATURES: • Auto-zoom intelligence với smart bounds fitting • Enhanced 3D GPS markers với pulsing effects • Professional route display với 6-layer rendering • Status-based parking icons với availability indicators • Production-ready build optimizations 🗺️ AUTO-ZOOM FEATURES: • Smart bounds fitting cho GPS + selected parking • Adaptive padding (50px) cho visual balance • Max zoom control (level 16) để tránh quá gần • Dynamic centering khi không có selection 🎨 ENHANCED VISUALS: • 3D GPS marker với multi-layer pulse effects • Advanced parking icons với status colors • Selection highlighting với animation • Dimming system cho non-selected items 🛣️ ROUTE SYSTEM: • OpenRouteService API integration • Multi-layer route rendering (glow, shadow, main, animated) • Real-time distance & duration calculation • Visual route info trong popup 📱 PRODUCTION READY: • SSR safe với dynamic imports • Build errors resolved • Global deployment via Vercel • Optimized performance 🌍 DEPLOYMENT: • Vercel: https://whatever-ctk2auuxr-phong12hexdockworks-projects.vercel.app • Bundle size: 22.8 kB optimized • Global CDN distribution • HTTPS enabled 💾 VERSION CONTROL: • MapView-v2.0.tsx backup created • MAPVIEW_VERSIONS.md documentation • Full version history tracking
163 lines
4.9 KiB
JavaScript
163 lines
4.9 KiB
JavaScript
/**
|
|
* @fileoverview Prefer exact proptype definitions
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const Components = require('../util/Components');
|
|
const docsUrl = require('../util/docsUrl');
|
|
const astUtil = require('../util/ast');
|
|
const propsUtil = require('../util/props');
|
|
const propWrapperUtil = require('../util/propWrapper');
|
|
const variableUtil = require('../util/variable');
|
|
const report = require('../util/report');
|
|
const getText = require('../util/eslint').getText;
|
|
|
|
// -----------------------------------------------------------------------------
|
|
// Rule Definition
|
|
// -----------------------------------------------------------------------------
|
|
|
|
const messages = {
|
|
propTypes: 'Component propTypes should be exact by using {{exactPropWrappers}}.',
|
|
flow: 'Component flow props should be set with exact objects.',
|
|
};
|
|
|
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: 'Prefer exact proptype definitions',
|
|
category: 'Possible Errors',
|
|
recommended: false,
|
|
url: docsUrl('prefer-exact-props'),
|
|
},
|
|
messages,
|
|
schema: [],
|
|
},
|
|
|
|
create: Components.detect((context, components, utils) => {
|
|
const typeAliases = {};
|
|
const exactWrappers = propWrapperUtil.getExactPropWrapperFunctions(context);
|
|
|
|
function getPropTypesErrorMessage() {
|
|
const formattedWrappers = propWrapperUtil.formatPropWrapperFunctions(exactWrappers);
|
|
const message = exactWrappers.size > 1 ? `one of ${formattedWrappers}` : formattedWrappers;
|
|
return { exactPropWrappers: message };
|
|
}
|
|
|
|
function isNonExactObjectTypeAnnotation(node) {
|
|
return (
|
|
node
|
|
&& node.type === 'ObjectTypeAnnotation'
|
|
&& node.properties.length > 0
|
|
&& !node.exact
|
|
);
|
|
}
|
|
|
|
function hasNonExactObjectTypeAnnotation(node) {
|
|
const typeAnnotation = node.typeAnnotation;
|
|
return (
|
|
typeAnnotation
|
|
&& typeAnnotation.typeAnnotation
|
|
&& isNonExactObjectTypeAnnotation(typeAnnotation.typeAnnotation)
|
|
);
|
|
}
|
|
|
|
function hasGenericTypeAnnotation(node) {
|
|
const typeAnnotation = node.typeAnnotation;
|
|
return (
|
|
typeAnnotation
|
|
&& typeAnnotation.typeAnnotation
|
|
&& typeAnnotation.typeAnnotation.type === 'GenericTypeAnnotation'
|
|
);
|
|
}
|
|
|
|
function isNonEmptyObjectExpression(node) {
|
|
return (
|
|
node
|
|
&& node.type === 'ObjectExpression'
|
|
&& node.properties.length > 0
|
|
);
|
|
}
|
|
|
|
function isNonExactPropWrapperFunction(node) {
|
|
return (
|
|
astUtil.isCallExpression(node)
|
|
&& !propWrapperUtil.isExactPropWrapperFunction(context, getText(context, node.callee))
|
|
);
|
|
}
|
|
|
|
function reportPropTypesError(node) {
|
|
report(context, messages.propTypes, 'propTypes', {
|
|
node,
|
|
data: getPropTypesErrorMessage(),
|
|
});
|
|
}
|
|
|
|
function reportFlowError(node) {
|
|
report(context, messages.flow, 'flow', {
|
|
node,
|
|
});
|
|
}
|
|
|
|
return {
|
|
TypeAlias(node) {
|
|
// working around an issue with eslint@3 and babel-eslint not finding the TypeAlias in scope
|
|
typeAliases[node.id.name] = node;
|
|
},
|
|
|
|
'ClassProperty, PropertyDefinition'(node) {
|
|
if (!propsUtil.isPropTypesDeclaration(node)) {
|
|
return;
|
|
}
|
|
|
|
if (hasNonExactObjectTypeAnnotation(node)) {
|
|
reportFlowError(node);
|
|
} else if (exactWrappers.size > 0 && isNonEmptyObjectExpression(node.value)) {
|
|
reportPropTypesError(node);
|
|
} else if (exactWrappers.size > 0 && isNonExactPropWrapperFunction(node.value)) {
|
|
reportPropTypesError(node);
|
|
}
|
|
},
|
|
|
|
Identifier(node) {
|
|
if (!utils.getStatelessComponent(node.parent)) {
|
|
return;
|
|
}
|
|
|
|
if (hasNonExactObjectTypeAnnotation(node)) {
|
|
reportFlowError(node);
|
|
} else if (hasGenericTypeAnnotation(node)) {
|
|
const identifier = node.typeAnnotation.typeAnnotation.id.name;
|
|
const typeAlias = typeAliases[identifier];
|
|
const propsDefinition = typeAlias ? typeAlias.right : null;
|
|
if (isNonExactObjectTypeAnnotation(propsDefinition)) {
|
|
reportFlowError(node);
|
|
}
|
|
}
|
|
},
|
|
|
|
MemberExpression(node) {
|
|
if (!propsUtil.isPropTypesDeclaration(node) || exactWrappers.size === 0) {
|
|
return;
|
|
}
|
|
|
|
const right = node.parent.right;
|
|
if (isNonEmptyObjectExpression(right)) {
|
|
reportPropTypesError(node);
|
|
} else if (isNonExactPropWrapperFunction(right)) {
|
|
reportPropTypesError(node);
|
|
} else if (right.type === 'Identifier') {
|
|
const identifier = right.name;
|
|
const propsDefinition = variableUtil.findVariableByName(context, node, identifier);
|
|
if (isNonEmptyObjectExpression(propsDefinition)) {
|
|
reportPropTypesError(node);
|
|
} else if (isNonExactPropWrapperFunction(propsDefinition)) {
|
|
reportPropTypesError(node);
|
|
}
|
|
}
|
|
},
|
|
};
|
|
}),
|
|
};
|