✨ 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
118 lines
3.7 KiB
JavaScript
118 lines
3.7 KiB
JavaScript
/**
|
|
* @fileoverview Prevent string definitions for references and prevent referencing this.refs
|
|
* @author Tom Hastjarjanto
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const componentUtil = require('../util/componentUtil');
|
|
const docsUrl = require('../util/docsUrl');
|
|
const report = require('../util/report');
|
|
const testReactVersion = require('../util/version').testReactVersion;
|
|
|
|
// ------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
// ------------------------------------------------------------------------------
|
|
|
|
const messages = {
|
|
thisRefsDeprecated: 'Using this.refs is deprecated.',
|
|
stringInRefDeprecated: 'Using string literals in ref attributes is deprecated.',
|
|
};
|
|
|
|
/** @type {import('eslint').Rule.RuleModule} */
|
|
module.exports = {
|
|
meta: {
|
|
docs: {
|
|
description: 'Disallow using string references',
|
|
category: 'Best Practices',
|
|
recommended: true,
|
|
url: docsUrl('no-string-refs'),
|
|
},
|
|
|
|
messages,
|
|
|
|
schema: [{
|
|
type: 'object',
|
|
properties: {
|
|
noTemplateLiterals: {
|
|
type: 'boolean',
|
|
},
|
|
},
|
|
additionalProperties: false,
|
|
}],
|
|
},
|
|
|
|
create(context) {
|
|
const checkRefsUsage = testReactVersion(context, '< 18.3.0'); // `this.refs` is writable in React 18.3.0 and later, see https://github.com/facebook/react/pull/28867
|
|
const detectTemplateLiterals = context.options[0] ? context.options[0].noTemplateLiterals : false;
|
|
/**
|
|
* Checks if we are using refs
|
|
* @param {ASTNode} node The AST node being checked.
|
|
* @returns {boolean} True if we are using refs, false if not.
|
|
*/
|
|
function isRefsUsage(node) {
|
|
return !!(
|
|
(componentUtil.getParentES6Component(context, node) || componentUtil.getParentES5Component(context, node))
|
|
&& node.object.type === 'ThisExpression'
|
|
&& node.property.name === 'refs'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Checks if we are using a ref attribute
|
|
* @param {ASTNode} node The AST node being checked.
|
|
* @returns {boolean} True if we are using a ref attribute, false if not.
|
|
*/
|
|
function isRefAttribute(node) {
|
|
return node.type === 'JSXAttribute'
|
|
&& !!node.name
|
|
&& node.name.name === 'ref';
|
|
}
|
|
|
|
/**
|
|
* Checks if a node contains a string value
|
|
* @param {ASTNode} node The AST node being checked.
|
|
* @returns {boolean} True if the node contains a string value, false if not.
|
|
*/
|
|
function containsStringLiteral(node) {
|
|
return !!node.value
|
|
&& node.value.type === 'Literal'
|
|
&& typeof node.value.value === 'string';
|
|
}
|
|
|
|
/**
|
|
* Checks if a node contains a string value within a jsx expression
|
|
* @param {ASTNode} node The AST node being checked.
|
|
* @returns {boolean} True if the node contains a string value within a jsx expression, false if not.
|
|
*/
|
|
function containsStringExpressionContainer(node) {
|
|
return !!node.value
|
|
&& node.value.type === 'JSXExpressionContainer'
|
|
&& node.value.expression
|
|
&& ((node.value.expression.type === 'Literal' && typeof node.value.expression.value === 'string')
|
|
|| (node.value.expression.type === 'TemplateLiteral' && detectTemplateLiterals));
|
|
}
|
|
|
|
return {
|
|
MemberExpression(node) {
|
|
if (checkRefsUsage && isRefsUsage(node)) {
|
|
report(context, messages.thisRefsDeprecated, 'thisRefsDeprecated', {
|
|
node,
|
|
});
|
|
}
|
|
},
|
|
|
|
JSXAttribute(node) {
|
|
if (
|
|
isRefAttribute(node)
|
|
&& (containsStringLiteral(node) || containsStringExpressionContainer(node))
|
|
) {
|
|
report(context, messages.stringInRefDeprecated, 'stringInRefDeprecated', {
|
|
node,
|
|
});
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|