forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl10n-helper.js
30 lines (23 loc) · 956 Bytes
/
l10n-helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
function isUIStringsIdentifier(node) {
return node.type === 'Identifier' && node.name === 'UIStrings';
}
function isModuleScope(context, node) {
const sourceCode = context.sourceCode ?? context.getSourceCode();
return ((sourceCode.getScope ? sourceCode.getScope(node) : context.getScope()).type === 'module');
}
function isUIStringsVariableDeclarator(context, variableDeclarator) {
if (!isModuleScope(context, variableDeclarator)) {
return false;
}
if (!isUIStringsIdentifier(variableDeclarator.id)) {
return false;
}
return variableDeclarator.init?.type === 'ObjectExpression';
}
exports.isUIStringsIdentifier = isUIStringsIdentifier;
exports.isUIStringsVariableDeclarator = isUIStringsVariableDeclarator;
exports.isModuleScope = isModuleScope;