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

chore: run migration for @fluentui/make-styles #20742

Merged
merged 7 commits into from
Nov 26, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "handle `common` directory as test files",
"packageName": "@fluentui/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "update tooling config",
"packageName": "@fluentui/make-styles",
"email": "[email protected]",
"dependentChangeType": "none"
}
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/utils/configHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const jju = require('jju');
const testFiles = [
'**/*{.,-}test.{ts,tsx}',
'**/*.stories.tsx',
'**/{test,tests,stories}/**',
'**/{common,test,tests,stories}/**',
Copy link
Member Author

@layershifter layershifter Nov 26, 2021

Choose a reason for hiding this comment

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

Had to add this to solve lint issue:

image

If it's not acceptable, I can add override in local eslintrc. @Hotell WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think its ok. how did you get this error ? on CI when running lint task for make-styles?

Copy link
Member Author

Choose a reason for hiding this comment

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

On CI with lint command, was able to repro it locally, too

'**/testUtilities.{ts,tsx}',
'**/common/isConformant.{ts,tsx}',
];
Expand Down
1 change: 0 additions & 1 deletion packages/make-styles/.npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.cache/
.storybook/
.vscode/
bundle-size/
Expand Down
2 changes: 1 addition & 1 deletion packages/make-styles/config/api-extractor.local.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "./api-extractor.json",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts"
"mainEntryPointFilePath": "<projectFolder>/dist/packages/<unscopedPackageName>/src/index.d.ts"
}
1 change: 1 addition & 0 deletions packages/make-styles/config/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/** Jest test setup file. */
3 changes: 2 additions & 1 deletion packages/make-styles/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ module.exports = {
preset: '../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.json',
tsConfig: '<rootDir>/tsconfig.spec.json',
diagnostics: false,
},
},
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
coverageDirectory: './coverage',
setupFilesAfterEnv: ['./config/tests.js'],
};
3 changes: 2 additions & 1 deletion packages/make-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"lint": "just-scripts lint",
"test": "jest",
"docs": "api-extractor run --config=config/api-extractor.local.json --local",
"build:local": "tsc -p . --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output dist/ && yarn docs"
"build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/make-styles/src && yarn docs",
"type-check": "tsc -b tsconfig.json"
},
"devDependencies": {
"@fluentui/eslint-plugin": "*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as prettier from 'prettier';

import { resolveStyleRules } from '../../runtime/resolveStyleRules';
import { MakeStylesRenderer, CSSRulesByBucket, StyleBucketName } from '../../types';
import { resolveStyleRules } from '../runtime/resolveStyleRules';
import { MakeStylesRenderer, CSSRulesByBucket, StyleBucketName } from '../types';

export const makeStylesRendererSerializer: jest.SnapshotSerializerPlugin = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/make-styles/src/makeStaticStyles.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createDOMRenderer } from './renderer/createDOMRenderer';
import { makeStylesRendererSerializer } from './utils/test/snapshotSerializer';
import { makeStylesRendererSerializer } from './common/snapshotSerializers';
import { makeStaticStyles } from './makeStaticStyles';
import { makeStyles } from './makeStyles';
import { MakeStylesRenderer } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/make-styles/src/makeStyles.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createDOMRenderer } from './renderer/createDOMRenderer';
import { makeStylesRendererSerializer } from './utils/test/snapshotSerializer';
import { makeStylesRendererSerializer } from './common/snapshotSerializers';
import { makeStyles } from './makeStyles';
import { MakeStylesRenderer } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { MakeStylesRenderer, StyleBucketName } from '../types';

// Regexps to extract names of classes and animations
// https://github.com/styletron/styletron/blob/e0fcae826744eb00ce679ac613a1b10d44256660/packages/styletron-engine-atomic/src/client/client.js#L8
// eslint-disable-next-line @fluentui/max-len
Copy link
Member Author

Choose a reason for hiding this comment

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

Was not used ¯_(ツ)_/¯

const KEYFRAMES_HYDRATOR = /@(-webkit-)?keyframes ([^{]+){((?:(?:from|to|(?:\d+\.?\d*%))\{(?:[^}])*})*)}/g;
const AT_RULES_HYDRATOR = /@(media|supports)[^{]+\{([\s\S]+?})\s*}/g;
const STYLES_HYDRATOR = /\.([^{:]+)(:[^{]+)?{(?:[^}]*;)?([^}]*?)}/g;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeStylesRulesSerializer } from '../utils/test/snapshotSerializer';
import { makeStylesRulesSerializer } from '../common/snapshotSerializers';
import { resolveStyleRules } from './resolveStyleRules';
import { CSSClassesMap, CSSClasses, CSSRulesByBucket } from '../types';

Expand Down
27 changes: 16 additions & 11 deletions packages/make-styles/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"target": "ES5",
"module": "CommonJS",
"lib": ["ES2015", "dom"],
"outDir": "dist",
"jsx": "react",
"declaration": true,
"experimentalDecorators": true,
"target": "ES2019",
"noEmit": true,
"isolatedModules": true,
"importHelpers": true,
"jsx": "react",
"noUnusedLocals": true,
"preserveConstEnums": true,
"types": ["jest", "custom-global", "inline-style-expand-shorthand"]
}
"preserveConstEnums": true
},
"include": [],
"files": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
20 changes: 20 additions & 0 deletions packages/make-styles/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"lib": ["ES2019", "dom"],
"outDir": "dist",
"declaration": true,
"types": ["static-assets", "environment", "inline-style-expand-shorthand"]
},
"exclude": [
"./src/common/**.ts",
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.test.ts",
"**/*.test.tsx",
"**/*.stories.ts",
"**/*.stories.tsx"
],
"include": ["./src/**/*.ts", "./src/**/*.tsx"]
}
9 changes: 9 additions & 0 deletions packages/make-styles/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"outDir": "dist",
"types": ["jest", "node", "inline-style-expand-shorthand"]
},
"include": ["./src/common/**.ts", "**/*.spec.ts", "**/*.spec.tsx", "**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
}