Skip to content

Commit 21b71a7

Browse files
committed
Bump TypeScript and migrate to Npm and ESLint
1 parent 4af33d0 commit 21b71a7

36 files changed

+12798
-4215
lines changed

.eslintrc.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
plugins: ['@typescript-eslint', 'prettier'],
5+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
6+
ignorePatterns: ['**/*.d.ts'],
7+
rules: {
8+
'@typescript-eslint/ban-types': 0,
9+
'@typescript-eslint/explicit-module-boundary-types': 0,
10+
'@typescript-eslint/no-empty-interface': 0,
11+
'@typescript-eslint/no-explicit-any': 0,
12+
'@typescript-eslint/no-non-null-assertion': 0,
13+
'@typescript-eslint/no-var-requires': 0,
14+
'no-empty-pattern': 0,
15+
'no-inner-declarations': 0,
16+
'no-undef': 0,
17+
'prettier/prettier': 2,
18+
},
19+
};

.vscode/settings.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
2-
"javascript.validate.enable": false,
3-
"files.eol": "\n",
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
},
45
"editor.formatOnSave": true,
6+
"eslint.alwaysShowStatus": true,
7+
"eslint.validate": ["javascript", "javascriptreact", "html", "typescript", "typescriptreact"],
8+
"files.eol": "\n",
59
"typescript.tsdk": "node_modules/typescript/lib"
610
}

README.md

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ _Further examples below will be in TypeScript!_
3333

3434
```sh
3535
$ npm install csstype
36-
$ # or
37-
$ yarn add csstype
3836
```
3937

4038
## Table of content
@@ -267,7 +265,7 @@ _If you're using CSS Custom Properties you can step directly to step 3._
267265

268266
### Commands
269267

270-
- `yarn build` Generates typings and type checks them
271-
- `yarn watch` Runs build on each save
272-
- `yarn test` Runs the tests
273-
- `yarn lazy` Type checks, lints and formats everything
268+
- `npm run build` Generates typings and type checks them
269+
- `npm run watch` Runs build on each save
270+
- `npm run test` Runs the tests
271+
- `npm run lazy` Type checks, lints and formats everything

__tests__/__fixtures__/package-lock.json

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/__fixtures__/typecheck.js

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow strict
22
import * as CSS from '../../index.js.flow';
33

4+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45
const css: CSS.Properties<> = {
56
flexGrow: 1,
67
flexShrink: 1,
@@ -17,6 +18,7 @@ const css: CSS.Properties<> = {
1718
lineHeightStep: '2em',
1819
};
1920

21+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2022
const cssWithFallbackValues: CSS.PropertiesFallback<> = {
2123
flexGrow: [1],
2224
flexShrink: [1],
@@ -26,6 +28,7 @@ const cssWithFallbackValues: CSS.PropertiesFallback<> = {
2628
msOverflowStyle: ['scrollbar'],
2729
};
2830

31+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2932
const cssWithHyphenProperties: CSS.PropertiesHyphen<> = {
3033
'flex-grow': 1,
3134
'flex-shrink': 0,
@@ -35,20 +38,24 @@ const cssWithHyphenProperties: CSS.PropertiesHyphen<> = {
3538
'-ms-overflow-style': 'scrollbar',
3639
};
3740

41+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3842
const cssWithDifferentLength: CSS.Properties<number> = {
3943
width: 1,
4044
};
4145

46+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4247
const unknownProperty: CSS.Properties<> = {
4348
unknownProperty: 1,
4449
};
4550

4651
// Should fail but doesn't
52+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4753
const cssWithDisallowedValue: CSS.Properties<> = {
4854
order: '0',
4955
};
5056

5157
// Should fail but doesn't
58+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5259
const cssWithDisallowedFallbackValues: CSS.Properties<> = {
5360
bottom: [0],
5461
order: [0],

__tests__/__fixtures__/typecheck.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// tslint:disable no-unused-expression
21
import * as CSS from '../..';
32

43
// Old CSSType import needs to be AFTER the current one
5-
// tslint:disable-next-line ordered-imports
64
import * as OldCSS from 'csstype';
75

86
const css: CSS.Properties = {
@@ -145,6 +143,7 @@ propertyValueWithAutocompleteHack([1]); // Should fail
145143

146144
const differentMajorVersions: CSS.Properties = {} as OldCSS.Properties;
147145

146+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
148147
type DataTypeShouldNotBeExposed = CSS.DataType.Color;
149148

150149
css;

__tests__/__fixtures__/yarn.lock

-8
This file was deleted.
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`it detects errors 1`] = `"42:43 - Cannot assign object literal to \`unknownProperty\` because property \`unknownProperty\` is missing in \`Properties\` [1] but exists in object literal [2]. [prop-missing]"`;
3+
exports[`it detects errors 1`] = `"47:43 - Cannot assign object literal to \`unknownProperty\` because property \`unknownProperty\` is missing in \`Properties\` [1] but exists in object literal [2]. [prop-missing]"`;
44

5-
exports[`it detects errors 2`] = `"48:10 - Cannot assign object literal to \`cssWithDisallowedValue\` because in property \`order\`: [incompatible-type] Either string [1] is incompatible with literal union [2]. Or string [1] is incompatible with number [3]."`;
5+
exports[`it detects errors 2`] = `"54:10 - Cannot assign object literal to \`cssWithDisallowedValue\` because in property \`order\`: [incompatible-type] Either string [1] is incompatible with literal union [2]. Or string [1] is incompatible with number [3]."`;
66

7-
exports[`it detects errors 3`] = `"53:11 - Cannot assign object literal to \`cssWithDisallowedFallbackValues\` because in property \`bottom\`: [incompatible-type] Either array literal [1] is incompatible with string literal \`-moz-initial\` [2]. Or array literal [1] is incompatible with string literal \`inherit\` [3]. Or array literal [1] is incompatible with string literal \`initial\` [4]. Or array literal [1] is incompatible with string literal \`revert\` [5]. Or array literal [1] is incompatible with string literal \`unset\` [6]. Or array literal [1] is incompatible with string [7]. Or array literal [1] is incompatible with number literal \`0\` [8]. Or array literal [1] is incompatible with string literal \`auto\` [9]. Or array literal [1] is incompatible with string [10]."`;
7+
exports[`it detects errors 3`] = `"60:11 - Cannot assign object literal to \`cssWithDisallowedFallbackValues\` because in property \`bottom\`: [incompatible-type] Either array literal [1] is incompatible with string literal \`-moz-initial\` [2]. Or array literal [1] is incompatible with string literal \`inherit\` [3]. Or array literal [1] is incompatible with string literal \`initial\` [4]. Or array literal [1] is incompatible with string literal \`revert\` [5]. Or array literal [1] is incompatible with string literal \`unset\` [6]. Or array literal [1] is incompatible with string [7]. Or array literal [1] is incompatible with number literal \`0\` [8]. Or array literal [1] is incompatible with string literal \`auto\` [9]. Or array literal [1] is incompatible with string [10]."`;
88

9-
exports[`it detects errors 4`] = `"54:10 - Cannot assign object literal to \`cssWithDisallowedFallbackValues\` because in property \`order\`: [incompatible-type] Either array literal [1] is incompatible with string literal \`-moz-initial\` [2]. Or array literal [1] is incompatible with string literal \`inherit\` [3]. Or array literal [1] is incompatible with string literal \`initial\` [4]. Or array literal [1] is incompatible with string literal \`revert\` [5]. Or array literal [1] is incompatible with string literal \`unset\` [6]. Or array literal [1] is incompatible with number [7]."`;
9+
exports[`it detects errors 4`] = `"61:10 - Cannot assign object literal to \`cssWithDisallowedFallbackValues\` because in property \`order\`: [incompatible-type] Either array literal [1] is incompatible with string literal \`-moz-initial\` [2]. Or array literal [1] is incompatible with string literal \`inherit\` [3]. Or array literal [1] is incompatible with string literal \`initial\` [4]. Or array literal [1] is incompatible with string literal \`revert\` [5]. Or array literal [1] is incompatible with string literal \`unset\` [6]. Or array literal [1] is incompatible with number [7]."`;
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Typescript 3.5 detects errors 1`] = `
4-
"46:2 - Type '{ unknownProperty: number; }' is not assignable to type 'Properties<0 | (string & {}), string & {}>'.
4+
"44:2 - Type '{ unknownProperty: number; }' is not assignable to type 'Properties<0 | (string & {}), string & {}>'.
55
Object literal may only specify known properties, and 'unknownProperty' does not exist in type 'Properties<0 | (string & {}), string & {}>'."
66
`;
77

88
exports[`Typescript 3.5 detects errors 2`] = `
9-
"50:2 - Type 'number[]' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | undefined'.
9+
"48:2 - Type 'number[]' is not assignable to type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | undefined'.
1010
Type 'number[]' is not assignable to type '\\"unset\\"'."
1111
`;
1212

1313
exports[`Typescript 3.5 detects errors 3`] = `
14-
"51:2 - Type 'number[]' is not assignable to type '\\"inherit\\" | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | (number & {}) | undefined'.
14+
"49:2 - Type 'number[]' is not assignable to type '\\"inherit\\" | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | (number & {}) | undefined'.
1515
Type 'number[]' is not assignable to type '\\"unset\\"'."
1616
`;
1717

1818
exports[`Typescript 3.5 detects errors 4`] = `
19-
"56:6 - Type '{}' is not assignable to type 'string & {}'.
19+
"54:6 - Type '{}' is not assignable to type 'string & {}'.
2020
Type '{}' is not assignable to type 'string'."
2121
`;
2222

2323
exports[`Typescript 3.5 detects errors 5`] = `
24-
"61:10 - Type '\\"auto\\" | (string & {})' is not assignable to type '\\"auto\\"'.
24+
"59:10 - Type '\\"auto\\" | (string & {})' is not assignable to type '\\"auto\\"'.
2525
Type 'string & {}' is not assignable to type '\\"auto\\"'."
2626
`;
2727

28-
exports[`Typescript 3.5 detects errors 6`] = `"68:6 - Type '1' is not assignable to type 'string | 0'."`;
28+
exports[`Typescript 3.5 detects errors 6`] = `"66:6 - Type '1' is not assignable to type 'string | 0'."`;
2929

30-
exports[`Typescript 3.5 detects errors 7`] = `"80:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
30+
exports[`Typescript 3.5 detects errors 7`] = `"78:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
3131

32-
exports[`Typescript 3.5 detects errors 8`] = `"94:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
32+
exports[`Typescript 3.5 detects errors 8`] = `"92:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
3333

34-
exports[`Typescript 3.5 detects errors 9`] = `"104:14 - Argument of type '1' is not assignable to parameter of type 'string | 0 | (string | 0)[]'."`;
34+
exports[`Typescript 3.5 detects errors 9`] = `"102:14 - Argument of type '1' is not assignable to parameter of type 'string | 0 | (string | 0)[]'."`;
3535

3636
exports[`Typescript 3.5 detects errors 10`] = `
37-
"105:14 - Argument of type '1[]' is not assignable to parameter of type 'string | 0 | (string | 0)[]'.
37+
"103:14 - Argument of type '1[]' is not assignable to parameter of type 'string | 0 | (string | 0)[]'.
3838
Type '1[]' is not assignable to type '(string | 0)[]'.
3939
Type '1' is not assignable to type 'string | 0'."
4040
`;
4141

42-
exports[`Typescript 3.5 detects errors 11`] = `"118:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
42+
exports[`Typescript 3.5 detects errors 11`] = `"116:23 - This condition will always return 'false' since the types 'string | 0 | (string | 0)[]' and '1' have no overlap."`;
4343

44-
exports[`Typescript 3.5 detects errors 12`] = `"132:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
44+
exports[`Typescript 3.5 detects errors 12`] = `"130:25 - This condition will always return 'false' since the types 'string | 0' and '1' have no overlap."`;
4545

46-
exports[`Typescript 3.5 detects errors 13`] = `"142:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`;
46+
exports[`Typescript 3.5 detects errors 13`] = `"140:34 - Argument of type '1' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'."`;
4747

4848
exports[`Typescript 3.5 detects errors 14`] = `
49-
"143:34 - Argument of type '[1]' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'.
49+
"141:34 - Argument of type '[1]' is not assignable to parameter of type '0 | \\"auto\\" | \\"inherit\\" | (string & {}) | \\"-moz-initial\\" | \\"initial\\" | \\"revert\\" | \\"unset\\" | \\"-moz-fit-content\\" | \\"-moz-max-content\\" | \\"-moz-min-content\\" | \\"fit-content\\" | \\"max-content\\" | ... 5 more ... | [...]'.
5050
Type '[1]' is not assignable to type '[Width<0 | (string & {})>]'.
5151
Type '1' is not assignable to type 'Width<0 | (string & {})>'."
5252
`;
5353

54-
exports[`Typescript 3.5 detects errors 15`] = `"147:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`;
54+
exports[`Typescript 3.5 detects errors 15`] = `"146:38 - Namespace '\\"index\\"' has no exported member 'DataType'."`;

0 commit comments

Comments
 (0)