Skip to content

Commit bd75572

Browse files
committed
style: fix types
1 parent 66c0de6 commit bd75572

7 files changed

+32
-23
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": [
3-
"canonical"
3+
"canonical",
4+
"canonical/flowtype"
45
],
56
"root": true
67
}

src/conditionalClassMerge.js

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import {
66
stringLiteral
77
} from 'babel-types';
88

9+
/* eslint-disable flowtype/no-weak-types */
10+
911
export default (
1012
classNameExpression: any,
1113
styleNameExpression: any,

src/index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default ({
104104
}
105105
};
106106

107-
const getTargetResourcePath = (path: Object, stats:Object) => {
107+
const getTargetResourcePath = (path: *, stats: *) => {
108108
const targetFileDirectoryPath = dirname(stats.file.opts.filename);
109109

110110
if (path.node.source.value.startsWith('.')) {
@@ -114,7 +114,7 @@ export default ({
114114
return require.resolve(path.node.source.value);
115115
};
116116

117-
const notForPlugin = (path: Object, stats: Object) => {
117+
const notForPlugin = (path: *, stats: *) => {
118118
stats.opts.filetypes = stats.opts.filetypes || {};
119119

120120
const extension = path.node.source.value.lastIndexOf('.') > -1 ? path.node.source.value.substr(path.node.source.value.lastIndexOf('.')) : null;
@@ -133,7 +133,7 @@ export default ({
133133
return {
134134
inherits: babelPluginJsxSyntax,
135135
visitor: {
136-
ImportDeclaration (path: Object, stats: Object): void {
136+
ImportDeclaration (path: *, stats: *): void {
137137
if (notForPlugin(path, stats)) {
138138
return;
139139
}
@@ -169,7 +169,7 @@ export default ({
169169
path.remove();
170170
}
171171
},
172-
JSXElement (path: Object, stats: Object): void {
172+
JSXElement (path: *, stats: *): void {
173173
const filename = stats.file.opts.filename;
174174
const styleNameAttribute = path.node.openingElement.attributes
175175
.find((attribute) => {
@@ -203,7 +203,7 @@ export default ({
203203
);
204204
}
205205
},
206-
Program (path: Object, stats: Object): void {
206+
Program (path: *, stats: *): void {
207207
if (!validate(stats.opts)) {
208208
// eslint-disable-next-line no-console
209209
console.error(validate.errors);

src/replaceJsxExpressionContainer.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import conditionalClassMerge from './conditionalClassMerge';
1313

1414
export default (
1515
t: BabelTypes,
16+
// eslint-disable-next-line flowtype/no-weak-types
1617
path: Object,
1718
styleNameAttribute: JSXAttribute,
1819
importedHelperIndentifier: Identifier,

src/requireCssModule.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,24 @@ import type {
1818
StyleModuleMapType
1919
} from './types';
2020

21-
type FileTypeOptions = {|
21+
type FiletypeOptionsType = {|
2222
+syntax: string,
23-
// eslint-disable-next-line no-undef
2423
+plugins?: $ReadOnlyArray<string>
2524
|};
2625

27-
const getFiletypeOptions = (cssSourceFilePath: string, filetypes: {[key: string]: FileTypeOptions}): ?FileTypeOptions => {
26+
type FiletypesConfigurationType = {
27+
[key: string]: FiletypeOptionsType
28+
};
29+
30+
const getFiletypeOptions = (cssSourceFilePath: string, filetypes: FiletypesConfigurationType): ?FiletypeOptionsType => {
2831
const extension = cssSourceFilePath.substr(cssSourceFilePath.lastIndexOf('.'));
2932
const filetype = filetypes ? filetypes[extension] : null;
3033

3134
return filetype;
3235
};
3336

34-
const getSyntax = (filetypeOptions: FileTypeOptions): ?(Function|Object) => {
37+
// eslint-disable-next-line flowtype/no-weak-types
38+
const getSyntax = (filetypeOptions: FiletypeOptionsType): ?(Function | Object) => {
3539
if (!filetypeOptions || !filetypeOptions.syntax) {
3640
return null;
3741
}
@@ -40,8 +44,8 @@ const getSyntax = (filetypeOptions: FileTypeOptions): ?(Function|Object) => {
4044
return require(filetypeOptions.syntax);
4145
};
4246

43-
// eslint-disable-next-line no-undef
44-
const getExtraPlugins = (filetypeOptions: ?FileTypeOptions): $ReadOnlyArray<any> => {
47+
// eslint-disable-next-line flowtype/no-weak-types
48+
const getExtraPlugins = (filetypeOptions: ?FiletypeOptionsType): $ReadOnlyArray<*> => {
4549
if (!filetypeOptions || !filetypeOptions.plugins) {
4650
return [];
4751
}
@@ -52,7 +56,8 @@ const getExtraPlugins = (filetypeOptions: ?FileTypeOptions): $ReadOnlyArray<any>
5256
});
5357
};
5458

55-
const getTokens = (runner, cssSourceFilePath: string, filetypeOptions: ?FileTypeOptions): StyleModuleMapType => {
59+
const getTokens = (runner, cssSourceFilePath: string, filetypeOptions: ?FiletypeOptionsType): StyleModuleMapType => {
60+
// eslint-disable-next-line flowtype/no-weak-types
5661
const options: Object = {
5762
from: cssSourceFilePath
5863
};
@@ -75,8 +80,8 @@ const getTokens = (runner, cssSourceFilePath: string, filetypeOptions: ?FileType
7580
};
7681

7782
type OptionsType = {|
78-
filetypes: Object,
7983
generateScopedName?: string,
84+
filetypes: FiletypesConfigurationType,
8085
context?: string
8186
|};
8287

src/resolveStringLiteral.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
/**
1616
* Updates the className value of a JSX element using a provided styleName attribute.
1717
*/
18-
export default (path: Object, styleModuleImportMap: StyleModuleImportMapType, styleNameAttribute: JSXAttribute): void => {
18+
export default (path: *, styleModuleImportMap: StyleModuleImportMapType, styleNameAttribute: JSXAttribute): void => {
1919
const classNameAttribute = path.node.openingElement.attributes
2020
.find((attribute) => {
2121
return typeof attribute.name !== 'undefined' && attribute.name.name === 'className';

src/schemas/optionsSchema.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
"additionalProperties": false,
1212
"patternProperties": {
1313
"\\..*": {
14-
"type": "object",
1514
"additionalProperties": false,
1615
"properties": {
17-
"syntax": {
18-
"type": "string"
19-
},
2016
"plugins": {
21-
"type": "array",
2217
"items": {
2318
"type": "string"
24-
}
19+
},
20+
"type": "array"
21+
},
22+
"syntax": {
23+
"type": "string"
2524
}
26-
}
25+
},
26+
"type": "object"
2727
}
2828
},
2929
"type": "object"
@@ -39,4 +39,4 @@
3939
}
4040
},
4141
"type": "object"
42-
}
42+
}

0 commit comments

Comments
 (0)