Chore: Make sure we run prettier on cjs files (#103903)
This commit is contained in:
+3
-3
@@ -39,9 +39,9 @@
|
||||
"packages:prepare": "lerna version --no-push --no-git-tag-version --force-publish --exact",
|
||||
"packages:pack": "mkdir -p ./npm-artifacts && lerna exec --no-private -- yarn pack --out \"../../npm-artifacts/%s-%v.tgz\"",
|
||||
"packages:typecheck": "nx run-many -t typecheck --projects='tag:scope:package'",
|
||||
"prettier:check": "prettier --check --list-different=false --log-level=warn \"**/*.{ts,tsx,scss,md,mdx,json,js}\"",
|
||||
"prettier:checkDocs": "prettier --check --list-different=false --log-level=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx,json}\"",
|
||||
"prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx,json}\" --write",
|
||||
"prettier:check": "prettier --check --list-different=false --log-level=warn \"**/*.{ts,tsx,scss,md,mdx,json,js,cjs}\"",
|
||||
"prettier:checkDocs": "prettier --check --list-different=false --log-level=warn \"docs/**/*.md\" \"*.md\" \"packages/**/*.{ts,tsx,scss,md,mdx,json,js,cjs}\"",
|
||||
"prettier:write": "prettier --list-different \"**/*.{js,ts,tsx,scss,md,mdx,json,cjs}\" --write",
|
||||
"start": "NODE_ENV=dev nx exec -- webpack --config scripts/webpack/webpack.dev.js --watch",
|
||||
"start:liveReload": "yarn start -- --env liveReload=1",
|
||||
"start:noTsCheck": "yarn start -- --env noTsCheck=1",
|
||||
|
||||
@@ -15,7 +15,9 @@ const { ESLintUtils } = require('@typescript-eslint/utils');
|
||||
|
||||
const GRAFANA_E2E_PACKAGE_NAME = '@grafana/e2e-selectors';
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`);
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
(name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`
|
||||
);
|
||||
|
||||
// A relative simple lint rule that will look of the `selectors` export from @grafana/e2e-selectors
|
||||
// is used in an aria-label
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// @ts-check
|
||||
const { ESLintUtils, AST_NODE_TYPES } = require('@typescript-eslint/utils');
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`);
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
(name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`
|
||||
);
|
||||
|
||||
const borderRadiusRule = createRule({
|
||||
create(context) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// @ts-check
|
||||
const { ESLintUtils, AST_NODE_TYPES } = require('@typescript-eslint/utils');
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`);
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
(name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`
|
||||
);
|
||||
|
||||
const restrictedProperties = ['animation', 'transition'];
|
||||
|
||||
@@ -13,16 +15,13 @@ const rule = createRule({
|
||||
create(context) {
|
||||
return {
|
||||
CallExpression(node) {
|
||||
if (
|
||||
node.callee.type === AST_NODE_TYPES.Identifier &&
|
||||
node.callee.name === 'css'
|
||||
) {
|
||||
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === 'css') {
|
||||
const cssObjects = node.arguments.flatMap((node) => {
|
||||
switch (node.type) {
|
||||
case AST_NODE_TYPES.ObjectExpression:
|
||||
return [node];
|
||||
case AST_NODE_TYPES.ArrayExpression:
|
||||
return node.elements.filter(v => v?.type === AST_NODE_TYPES.ObjectExpression);
|
||||
return node.elements.filter((v) => v?.type === AST_NODE_TYPES.ObjectExpression);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -55,7 +54,8 @@ const rule = createRule({
|
||||
description: 'Check if animation or transition properties are used directly.',
|
||||
},
|
||||
messages: {
|
||||
noUnreducedMotion: 'Avoid direct use of `animation*` or `transition*` properties. Use the `handleMotion` utility function from theme.transitions or wrap in a `prefers-reduced-motion` media query.',
|
||||
noUnreducedMotion:
|
||||
'Avoid direct use of `animation*` or `transition*` properties. Use the `handleMotion` utility function from theme.transitions or wrap in a `prefers-reduced-motion` media query.',
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
|
||||
@@ -35,7 +35,8 @@ const noUntranslatedStrings = createRule({
|
||||
const isUntranslatedProp =
|
||||
(node.value.type === 'Literal' && node.value.value !== '') ||
|
||||
(node.value.type === AST_NODE_TYPES.JSXExpressionContainer &&
|
||||
((isStringLiteral(node.value.expression) && node.value.expression.value !== '') || node.value.expression.type === 'TemplateLiteral'));
|
||||
((isStringLiteral(node.value.expression) && node.value.expression.value !== '') ||
|
||||
node.value.expression.type === 'TemplateLiteral'));
|
||||
|
||||
if (isUntranslatedProp) {
|
||||
const errorShouldBeFixed = shouldBeFixed(context);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
// @ts-check
|
||||
const { ESLintUtils, AST_NODE_TYPES } = require('@typescript-eslint/utils');
|
||||
|
||||
const createRule = ESLintUtils.RuleCreator((name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`);
|
||||
const createRule = ESLintUtils.RuleCreator(
|
||||
(name) => `https://github.com/grafana/grafana/blob/main/packages/grafana-eslint-rules/README.md#${name}`
|
||||
);
|
||||
|
||||
const themeTokenUsage = createRule({
|
||||
create(context) {
|
||||
|
||||
@@ -26,11 +26,8 @@ const elementIsTrans = (node) => {
|
||||
* @param {Node} node
|
||||
*/
|
||||
const isStringLiteral = (node) => {
|
||||
return (
|
||||
node.type === AST_NODE_TYPES.Literal &&
|
||||
typeof node.value === 'string'
|
||||
);
|
||||
}
|
||||
return node.type === AST_NODE_TYPES.Literal && typeof node.value === 'string';
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts a string to kebab case
|
||||
@@ -309,10 +306,7 @@ function getNodeValue(node) {
|
||||
if (node.type === AST_NODE_TYPES.JSXAttribute && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
|
||||
// this condition is basically `isStringLiteral`, but we can't use the function
|
||||
// else it doesn't narrow the type correctly :(
|
||||
if (
|
||||
node.value.expression.type === AST_NODE_TYPES.Literal &&
|
||||
typeof node.value.expression.value === 'string'
|
||||
) {
|
||||
if (node.value.expression.type === AST_NODE_TYPES.Literal && typeof node.value.expression.value === 'string') {
|
||||
return node.value.expression.value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user