Skip to content

Commit

Permalink
chore: support ts, bump lint and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Hellstrand committed May 2, 2024
1 parent 7a2fe14 commit b36b2c0
Show file tree
Hide file tree
Showing 36 changed files with 464 additions and 58 deletions.
12 changes: 11 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
"extends": ["./linting/eslint-config-ffe/index.js", "prettier"],
"parser": "babel-eslint",
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"settings": {
"react": {
"version": "detect"
}
},
"rules": {
"no-use-before-define": 0,
"@typescript-eslint/no-use-before-define": [2]
},
"overrides": [
{
"files": ["**/*.spec.js", "**/*.spec.tsx", "**/*.spec.ts"],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dist/
packages/*/lib/
tmp/
es/
build/
types/

# Editors
Expand Down
9 changes: 9 additions & 0 deletions buildtool/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"jsx": "react",
"lib": ["dom", "es2019"]
}
}
14 changes: 14 additions & 0 deletions buildtool/src/commands/tscCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const { spawn } = require('child_process');

module.exports = function (args) {
const arg = ['tsc', '--project', './tsconfig.json', ...args];

return spawn('npx', arg, {
cwd: process.cwd(),
stdio: 'inherit',
}).on('exit', code => {
if (code) {
process.exit(code);
}
});
};
10 changes: 9 additions & 1 deletion buildtool/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const babelCommand = require('./commands/babelCommand');
const copyfileCommand = require('./commands/copyfileCommand');
const jestCommand = require('./commands/jestCommand');
const stylelintCommand = require('./commands/stylelintCommand');
const tscCommand = require('./commands/tscCommand');

const program = new Command();

Expand Down Expand Up @@ -35,7 +36,7 @@ program

program
.command('babel-watch')
.description('continously compile code with babel')
.description('continuously compile code with babel')
.argument('[source]', 'directory with source code', 'src')
.option('--es <esDir>', 'where to output es modules', 'es')
.action((source, options) => {
Expand Down Expand Up @@ -66,6 +67,13 @@ program
stylelintCommand(args);
});

program
.command('tsc')
.description('compile code with babel')
.action((options, { args }) => {
tscCommand(args);
});

program.parse(process.argv);

if (!process.argv.slice(2).length) {
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'ffe-account-selector-react',
'ffe-buttons',
'ffe-buttons-react',
'ffe-buttons-react-ts',
'ffe-cards',
'ffe-cards-react',
'ffe-chart-donut-react',
Expand Down
35 changes: 19 additions & 16 deletions component-overview/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
{
"extends": ["../.eslintrc"],
"overrides": [
{
"files": ["examples/**/*.jsx"],
"globals": {
"React": false
},
"rules": {
"no-unused-expressions": "off",
"no-unused-vars": "warn",
"react/react-in-jsx-scope": "off",
"react/jsx-boolean-value": "warn",
"react/prop-types": "off"
}
}
]
"extends": [
"../.eslintrc"
],
"overrides": [
{
"files": [
"examples/**/*.jsx"
],
"globals": {
"React": false
},
"rules": {
"no-unused-expressions": "off",
"no-unused-vars": "warn",
"react/react-in-jsx-scope": "off",
"react/jsx-boolean-value": "warn"
}
}
]
}
5 changes: 2 additions & 3 deletions linting/eslint-config-ffe-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
"unused": "eslint-find-rules -u"
},
"devDependencies": {
"eslint": "^5.9.0",
"eslint-find-rules": "^3.1.1",
"eslint-plugin-import": "^2.20.1"
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1"
},
"peerDependencies": {
"eslint": ">=2",
Expand Down
8 changes: 4 additions & 4 deletions linting/eslint-config-ffe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"@sb1/eslint-config-ffe-base": "^3.0.4"
},
"devDependencies": {
"eslint": "^5.9.0",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-react": "^7.0.0",
"eslint-plugin-react-hooks": "^2.0.1"
"eslint-plugin-react-hooks": "^4.6.2"
},
"peerDependencies": {
"eslint": "*",
Expand Down
4 changes: 0 additions & 4 deletions linting/eslint-config-ffe/rules/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ module.exports = {
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': [2],

// Prevent missing props validation in a React component definition
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': [2],

// Prevent breaking rules of hooks
// https://reactjs.org/docs/hooks-rules.html
'react-hooks/rules-of-hooks': 'error',
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,22 @@
"@testing-library/dom": "^7.30.3",
"@testing-library/react": "^9.3.1",
"@testing-library/user-event": "^13.1.5",
"babel-eslint": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"case": "^1.5.5",
"eslint": "^5.9.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^4.1.0",
"husky": "^7.0.4",
"lerna": "^5.5.1",
"mkdirp": "^1.0.4",
"npm-run-all": "^4.1.5",
"prettier": "^1.15.2",
"pretty-quick": "^1.8.0",
"prettier": "^3.2.5",
"pretty-quick": "^4.0.0",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"regenerator-runtime": "^0.13.2",
"rimraf": "^3.0.2",
"stylelint-config-prettier": "^9.0.3"
"stylelint-config-prettier": "^9.0.3",
"typescript": "^5.4.3"
}
}
2 changes: 1 addition & 1 deletion packages/ffe-account-selector-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"devDependencies": {
"@sb1/ffe-buildtool": "^0.5.1",
"eslint": "^5.9.0",
"eslint": "^8.57.0",
"react": "^16.9.0",
"react-dom": "^16.9.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/ffe-buttons-react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
},
"scripts": {
"build": "ffe-buildtool tsc",
"watch": "ffe-buildtool babel-watch",
"lint": "eslint src/ --ext ts,tsx",
"test": "ffe-buildtool jest",
"test:watch": "ffe-buildtool jest --watch"
Expand All @@ -32,7 +31,7 @@
"classnames": "^2.3.1"
},
"devDependencies": {
"@sb1/ffe-buildtool": "file:../../buildtool",
"@sb1/ffe-buildtool": "^0.5.1",
"eslint": "^8.57.0",
"react": "^16.9.0",
"react-dom": "^16.9.0"
Expand Down
113 changes: 113 additions & 0 deletions packages/ffe-buttons-react-ts/src/ActionButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
'use strict';
var __assign =
(this && this.__assign) ||
function () {
__assign =
Object.assign ||
function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (
!desc ||
('get' in desc
? !m.__esModule
: desc.writable || desc.configurable)
) {
desc = {
enumerable: true,
get: function () {
return m[k];
},
};
}
Object.defineProperty(o, k2, desc);
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __setModuleDefault =
(this && this.__setModuleDefault) ||
(Object.create
? function (o, v) {
Object.defineProperty(o, 'default', {
enumerable: true,
value: v,
});
}
: function (o, v) {
o['default'] = v;
});
var __importStar =
(this && this.__importStar) ||
function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (
k !== 'default' &&
Object.prototype.hasOwnProperty.call(mod, k)
)
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __rest =
(this && this.__rest) ||
function (s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
for (
var i = 0, p = Object.getOwnPropertySymbols(s);
i < p.length;
i++
) {
if (
e.indexOf(p[i]) < 0 &&
Object.prototype.propertyIsEnumerable.call(s, p[i])
)
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, '__esModule', { value: true });
exports.App = exports.ActionButton = void 0;
var react_1 = __importStar(require('react'));
var BaseButton_1 = require('./BaseButton');
function ActionButton(props, ref) {
// eslint-disable-next-line no-unused-vars
var _ = props.ref,
rest = __rest(props, ['ref']);
return react_1.default.createElement(
BaseButton_1.BaseButton,
__assign({ buttonType: 'action' }, rest, { ref: ref }),
);
}
exports.ActionButton = ActionButton;
function App() {
var ref = (0, react_1.useRef)(null);
return react_1.default.createElement(ActionButton, {
as: 'a',
ref: ref,
leftIcon: react_1.default.createElement('div', null, 'icon her'),
});
}
exports.App = App;
Loading

0 comments on commit b36b2c0

Please sign in to comment.