Skip to content

Commit

Permalink
feat(babel): new way for detecting tags imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Anber committed May 30, 2022
1 parent f59860b commit f133428
Show file tree
Hide file tree
Showing 119 changed files with 5,959 additions and 4,231 deletions.
30 changes: 12 additions & 18 deletions .circleci/config.yml
@@ -1,13 +1,13 @@
version: 2.1

executors:
node-v14:
node-v16:
docker:
- image: circleci/node:14
- image: circleci/node:16
working_directory: ~/linaria
node-v10:
node-v14:
docker:
- image: circleci/node:10
- image: circleci/node:14
working_directory: ~/linaria
commands:
install-dependencies:
Expand Down Expand Up @@ -68,33 +68,29 @@ commands:
yarn --cwd website lint:css
jobs:
install-dependencies:
executor: node-v14
steps:
- install-dependencies
install-dependencies-v10:
executor: node-v10
executor: node-v16
steps:
- install-dependencies
lint-and-typecheck:
executor: node-v14
executor: node-v16
steps:
- lint-and-typecheck
lint-website:
executor: node-v14
executor: node-v16
steps:
- lint-website
unit-tests-and-coverage:
executor: node-v14
executor: node-v16
steps:
- unit-tests-and-coverage
unit-tests-node-v10:
executor: node-v10
unit-tests-node-v14:
executor: node-v14
steps:
- install-dependencies
- unit-tests
workflows:
multiple_builds:
jobs:
- install-dependencies-v10
- install-dependencies
- lint-and-typecheck:
requires:
Expand All @@ -105,6 +101,4 @@ workflows:
- unit-tests-and-coverage:
requires:
- install-dependencies
- unit-tests-node-v10:
requires:
- install-dependencies-v10
- unit-tests-node-v14
29 changes: 0 additions & 29 deletions .eslintrc

This file was deleted.

145 changes: 145 additions & 0 deletions .eslintrc.js
@@ -0,0 +1,145 @@
module.exports = {
plugins: ['prettier', 'import'],
rules: {
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*.test.{js,ts,jsx,tsx}',
'src/{babel,server}/**/*.{js,ts,jsx,tsx}',
],
},
],
'max-len': [
'error',
150,
2,
{
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreUrls: true,
},
],
'prettier/prettier': 'error',
},
globals: {
JSX: 'readonly',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
overrides: [
{
files: ['*.ts', '*.tsx'],
extends: [
'airbnb-base',
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
],
parserOptions: {
project: './tsconfig.eslint.json',
},
rules: {
'import/extensions': 0,
'import/prefer-default-export': 0,
'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports' },
],

// TODO
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/comma-dangle': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-var-requires': 0,
'global-require': 0,
'import/no-dynamic-require': 0,
'no-underscore-dangle': 0,
},
},
{
files: ['*.js', '*.jsx'],
extends: [
'airbnb-base',
'plugin:prettier/recommended',
'plugin:import/recommended',
],
parser: '@babel/eslint-parser',
parserOptions: {
requireConfigFile: false,
},
},
{
files: [
'**/__tests__/**/*.test.ts',
'**/__tests__/**/*.test.tsx',
'**/__utils__/**/*.ts',
],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
{
selector: 'function',
leadingUnderscore: 'allow',
format: ['camelCase', 'PascalCase'],
},
{
selector: 'typeLike',
format: ['PascalCase'],
},
],
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-var-requires': 0,
'global-require': 0,
'no-template-curly-in-string': 0,
},
},
{
files: ['**/__dtslint__/**/*.ts'],
rules: {
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-unused-expressions': 0,
},
},
{
files: ['website/**/*.jsx'],
extends: [
'airbnb',
'plugin:prettier/recommended',
'plugin:import/recommended',
],
parser: '@babel/eslint-parser',
settings: {
react: {
version: 'detect',
},
},
parserOptions: {
requireConfigFile: false,
babelOptions: {
presets: ['@babel/preset-react'],
},
},
rules: {
'global-require': 0,
},
},
],
};
1 change: 1 addition & 0 deletions babel.config.js
Expand Up @@ -71,6 +71,7 @@ module.exports = {
/es\.array\.(?:filter|for-each|index-of|join|reduce|slice)/,
'es.function.name',
'es.object.keys',
'es.object.to-string',
'web.dom-collections.for-each',
],
corejs: 3,
Expand Down
31 changes: 18 additions & 13 deletions package.json
Expand Up @@ -12,7 +12,7 @@
"check:all": "yarn test:dts && yarn typecheck && yarn test && yarn lint",
"clean": "del 'packages/*/{coverage,esm,lib,types,tsconfig.tsbuildinfo}'",
"lint": "eslint --ext .js,.ts,.tsx .",
"prepare": "lerna-to-typescript-project-references --update && yarn lerna run prepare",
"prepare": "yarn lerna run prepare",
"release": "release-it",
"test": "yarn lerna run test",
"test:coverage": "yarn lerna run test -- -- --coverage",
Expand All @@ -24,32 +24,37 @@
"devDependencies": {
"@babel/cli": ">=7",
"@babel/core": ">=7",
"@babel/eslint-parser": "^7.18.2",
"@babel/plugin-proposal-class-properties": ">=7",
"@babel/plugin-syntax-jsx": ">=7",
"@babel/preset-env": ">=7",
"@babel/preset-react": ">=7",
"@babel/preset-typescript": ">=7",
"@callstack/eslint-config": "^10.2.0",
"@commitlint/config-conventional": "^8.3.4",
"@release-it/conventional-changelog": "^1.1.0",
"@types/jest": "^24.9.1",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"all-contributors-cli": "^6.1.1",
"babel-jest": "^27.0.5",
"@types/jest": "^27.5.1",
"@typescript-eslint/eslint-plugin": "^5.26.0",
"@typescript-eslint/parser": "^5.26.0",
"all-contributors-cli": "^6.20.0",
"babel-jest": "^28.1.0",
"codecov": "^3.2.0",
"commitlint": "^8.3.5",
"cross-env": "^7.0.3",
"del-cli": "^1.1.0",
"dtslint": "^4.0.4",
"eslint": "^7.6.0",
"eslint-plugin-prettier": "^3.1.4",
"dtslint": "^4.2.1",
"eslint": "^8.16.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"husky": "^1.3.1",
"jest": "^24.9.0",
"jest": "^28.1.0",
"lerna": "^3.22.1",
"lerna-changelog": "^1.0.1",
"lerna-to-typescript-project-references": "^0.0.6",
"prettier": "^2.0.5",
"prettier": "^2.6.2",
"react": ">=16",
"release-it": "^14.2.1",
"release-it-lerna-changelog": "^3.1.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/atomic/package.json
Expand Up @@ -14,6 +14,12 @@
"lib/",
"esm/"
],
"linaria": {
"tags": {
"css": "./lib/processors/css.js",
"styled": "./lib/processors/styled.js"
}
},
"license": "MIT",
"repository": "git@github.com:callstack/linaria.git",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion packages/atomic/src/atomize.ts
@@ -1,4 +1,5 @@
import postcss, { Document, AtRule, Container, Rule } from 'postcss';
import type { Document, AtRule, Container, Rule } from 'postcss';
import postcss from 'postcss';
import { slugify } from '@linaria/utils';
import stylis from 'stylis';
import { all as knownProperties } from 'known-css-properties';
Expand Down
3 changes: 3 additions & 0 deletions packages/atomic/src/processors/css.ts
@@ -0,0 +1,3 @@
export function getType() {
return 'atomic-css';
}
6 changes: 6 additions & 0 deletions packages/atomic/src/processors/styled.ts
@@ -0,0 +1,6 @@
export function getType(node: unknown) {
return {
component: node,
type: 'atomic-styled',
};
}
6 changes: 1 addition & 5 deletions packages/atomic/src/propertyPriority.ts
Expand Up @@ -202,9 +202,5 @@ export function getPropertyPriority(property: string) {
[]
);

if (longhands.includes(property)) {
return 2;
} else {
return 1;
}
return longhands.includes(property) ? 2 : 1;
}
23 changes: 2 additions & 21 deletions packages/babel/__tests__/__snapshots__/babel.test.ts.snap
@@ -1,24 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`can re-export lib apis using a custom resolver 1`] = `
"import { css } from './my-folder';
const x = \\"x17gu1mi\\";
console.log(x);"
`;

exports[`can re-export lib apis using a custom resolver 2`] = `
CSS:
.x17gu1mi {
background: red;
height: 100px;
}
Dependencies: NA
`;

exports[`compiles atomic css 1`] = `
"/* @flow */
import { css } from '@linaria/atomic';
Expand Down Expand Up @@ -856,12 +837,12 @@ const StyledComponent2 = /*#__PURE__*/reactStyled(StyledComponent)({
name: \\"StyledComponent2\\",
class: \\"sccybe9\\"
});
const AtomicComponent = /*#__PURE__*/reactStyled(\\"div\\")({
const AtomicComponent = /*#__PURE__*/atomicStyled(\\"div\\")({
name: \\"AtomicComponent\\",
class: \\"atm_26_5scuol aw1s2ox\\",
atomic: true
});
const AtomicComponent2 = /*#__PURE__*/reactStyled(AtomicComponent)({
const AtomicComponent2 = /*#__PURE__*/atomicStyled(AtomicComponent)({
name: \\"AtomicComponent2\\",
class: \\"atm_26_13q2bts a1080ijw\\",
atomic: true
Expand Down

0 comments on commit f133428

Please sign in to comment.