Skip to content

Commit 2e10c02

Browse files
authored
Merge pull request #97 from liferay/wincent/typescript-eslint
feat: add support for formatting and linting TypeScript
2 parents 0bfa624 + abf1b97 commit 2e10c02

File tree

10 files changed

+108
-51
lines changed

10 files changed

+108
-51
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"description": "Liferay's Frontend Infrastructure Team monorepo",
77
"devDependencies": {
8-
"@typescript-eslint/parser": "4.2.0",
8+
"@typescript-eslint/parser": "4.3.0",
99
"babel-eslint": "10.1.0",
1010
"eslint": "7.9.0",
1111
"jest": "26.4.2",
@@ -19,10 +19,10 @@
1919
"repository": "https://github.com/liferay/liferay-frontend-projects",
2020
"scripts": {
2121
"ci": "yarn format:check && yarn lint && yarn test",
22-
"format": "prettier --write \"**/*.{js,json,md,yml}\" \"**/.*.{js,yml}\"",
23-
"format:check": "prettier --list-different \"**/*.{js,json,md,yml}\" \"**/.*.{js,yml}\"",
24-
"lint": "eslint \"**/*.js\" \"**/.*.js\"",
25-
"lint:fix": "eslint --fix \"**/*.js\" \"**/.*.js\"",
22+
"format": "prettier --write \"**/*.{js,json,md,ts,yml}\" \"**/.*.{js,ts,yml}\"",
23+
"format:check": "prettier --list-different \"**/*.{js,json,md,ts,yml}\" \"**/.*.{js,ts,yml}\"",
24+
"lint": "eslint \"**/*.{js,ts}\" \"**/.*.{js,ts}\"",
25+
"lint:fix": "eslint --fix \"**/*.{js,ts}\" \"**/.*.{js,ts}\"",
2626
"test": "jest"
2727
},
2828
"version": "0.0.1",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com>
3+
* SPDX-License-Identifier: MIT
4+
*/
5+
6+
/**
7+
* This file exists to show that we can format and lint TypeScript files.
8+
*/
9+
10+
const x = 1; // eslint-disable-line @typescript-eslint/no-unused-vars

projects/eslint-config/index.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,43 @@ const config = {
1212
es6: true,
1313
},
1414
extends: ['eslint:recommended', require.resolve('eslint-config-prettier')],
15+
overrides: [
16+
{
17+
files: ['*.{ts,tsx}'],
18+
parser: '@typescript-eslint/parser',
19+
rules: {
20+
'@typescript-eslint/no-unused-vars': [
21+
'error',
22+
{
23+
argsIgnorePattern: '^_|^this$',
24+
varsIgnorePattern: '^_',
25+
},
26+
],
27+
28+
// These rules can be turned off because the corresponding
29+
// errors are caught by the TypeScript compiler itself.
30+
31+
'no-redeclare': 'off',
32+
'no-undef': 'off',
33+
'no-unused-expressions': 'off',
34+
'no-unused-vars': 'off',
35+
},
36+
},
37+
{
38+
files: ['*.d.ts'],
39+
rules: {
40+
'@typescript-eslint/no-unused-vars': 'off',
41+
},
42+
},
43+
],
44+
parser: 'babel-eslint',
1545
parserOptions: {
1646
ecmaVersion: 2018,
1747
sourceType: 'module',
1848
},
1949
plugins: [
2050
local('@liferay/liferay'),
51+
'@typescript-eslint/eslint-plugin',
2152
'no-for-of-loops',
2253
'no-only-tests',
2354
'notice',

projects/eslint-config/metal.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77

88
const config = {
99
extends: [require.resolve('./react')],
10-
parserOptions: {
11-
ecmaFeatures: {
12-
jsx: true,
13-
},
14-
},
1510
plugins: ['react'],
1611
rules: {
1712
/**

projects/eslint-config/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"author": "Liferay Frontend Infrastructure Team <[email protected]>",
33
"dependencies": {
4+
"@typescript-eslint/eslint-plugin": "4.3.0",
5+
"@typescript-eslint/parser": "4.3.0",
46
"eslint-config-prettier": "^6.5.0",
57
"eslint-plugin-no-for-of-loops": "^1.0.0",
68
"eslint-plugin-no-only-tests": "^2.1.0",

projects/eslint-config/portal.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ const local = require('./utils/local');
99

1010
const config = {
1111
extends: [require.resolve('./react')],
12-
parserOptions: {
13-
ecmaFeatures: {
14-
jsx: true,
15-
},
16-
},
1712
plugins: [local('@liferay/portal')],
1813
rules: {
1914
'@liferay/portal/deprecation': 'error',

projects/npm-tools/packages/npm-scripts/src/config/eslint.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ module.exports = {
4242
jest: true,
4343
node: true,
4444
},
45-
files: ['**/test/**/*.js'],
45+
files: ['**/test/**/*.{js,ts}'],
4646
},
4747
],
48-
parser: 'babel-eslint',
4948
parserOptions: {
5049
ecmaFeatures: {
5150
jsx: true,

projects/npm-tools/packages/npm-scripts/src/presets/standard/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const liferay = require('./dependencies/liferay');
88
const metal = require('./dependencies/metal');
99

1010
const CHECK_AND_FIX_GLOBS = [
11-
'/*.{js,json}',
12-
'/{src,test}/**/*.{js,scss}',
11+
'/*.{js,json,ts}',
12+
'/{src,test}/**/*.{js,scss,ts,tsx}',
1313
'/src/**/*.{jsp,jspf}',
1414
];
1515

projects/npm-tools/packages/npm-scripts/src/scripts/format.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const DEFAULT_OPTIONS = {
2020
/**
2121
* File extensions that we want Prettier to process.
2222
*/
23-
const EXTENSIONS = ['.js', '.json', '.jsp', '.jspf', '.scss'];
23+
const EXTENSIONS = ['.js', '.json', '.jsp', '.jspf', '.scss', '.ts', '.tsx'];
2424

2525
const IGNORE_FILE = '.prettierignore';
2626

yarn.lock

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2594,7 +2594,7 @@
25942594
dependencies:
25952595
"@types/istanbul-lib-report" "*"
25962596

2597-
"@types/json-schema@^7.0.5":
2597+
"@types/json-schema@^7.0.3", "@types/json-schema@^7.0.5":
25982598
version "7.0.6"
25992599
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.6.tgz#f4c7ec43e81b319a9815115031709f26987891f0"
26002600
integrity sha512-3c+yGKvVP5Y9TYBEibGNR+kLtijnj7mYrXRg+WpFb2X9xm04g/DXYkfg4hmzJQosc9snFNUPkbYIhu+KAm6jJw==
@@ -2787,49 +2787,74 @@
27872787
dependencies:
27882788
"@types/yargs-parser" "*"
27892789

2790-
"@typescript-eslint/parser@4.2.0":
2791-
version "4.2.0"
2792-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.2.0.tgz#1879ef400abd73d972e20f14c3522e5b343d1d1b"
2793-
integrity sha512-54jJ6MwkOtowpE48C0QJF9iTz2/NZxfKVJzv1ha5imigzHbNSLN9yvbxFFH1KdlRPQrlR8qxqyOvLHHxd397VA==
2790+
"@typescript-eslint/eslint-plugin@4.3.0":
2791+
version "4.3.0"
2792+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.3.0.tgz#1a23d904bf8ea248d09dc3761af530d90f39c8fa"
2793+
integrity sha512-RqEcaHuEKnn3oPFislZ6TNzsBLqpZjN93G69SS+laav/I8w/iGMuMq97P0D2/2/kW4SCebHggqhbcCfbDaaX+g==
27942794
dependencies:
2795-
"@typescript-eslint/scope-manager" "4.2.0"
2796-
"@typescript-eslint/types" "4.2.0"
2797-
"@typescript-eslint/typescript-estree" "4.2.0"
2795+
"@typescript-eslint/experimental-utils" "4.3.0"
2796+
"@typescript-eslint/scope-manager" "4.3.0"
27982797
debug "^4.1.1"
2798+
functional-red-black-tree "^1.0.1"
2799+
regexpp "^3.0.0"
2800+
semver "^7.3.2"
2801+
tsutils "^3.17.1"
27992802

2800-
"@typescript-eslint/scope-manager@4.2.0":
2801-
version "4.2.0"
2802-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz#d10e6854a65e175b22a28265d372a97c8cce4bfc"
2803-
integrity sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==
2803+
"@typescript-eslint/experimental-utils@4.3.0":
2804+
version "4.3.0"
2805+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.3.0.tgz#3f3c6c508e01b8050d51b016e7f7da0e3aefcb87"
2806+
integrity sha512-cmmIK8shn3mxmhpKfzMMywqiEheyfXLV/+yPDnOTvQX/ztngx7Lg/OD26J8gTZfkLKUmaEBxO2jYP3keV7h2OQ==
28042807
dependencies:
2805-
"@typescript-eslint/types" "4.2.0"
2806-
"@typescript-eslint/visitor-keys" "4.2.0"
2808+
"@types/json-schema" "^7.0.3"
2809+
"@typescript-eslint/scope-manager" "4.3.0"
2810+
"@typescript-eslint/types" "4.3.0"
2811+
"@typescript-eslint/typescript-estree" "4.3.0"
2812+
eslint-scope "^5.0.0"
2813+
eslint-utils "^2.0.0"
28072814

2808-
"@typescript-eslint/[email protected]":
2809-
version "4.2.0"
2810-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.2.0.tgz#6f6b094329e72040f173123832397c7c0b910fc8"
2811-
integrity sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==
2815+
"@typescript-eslint/[email protected]":
2816+
version "4.3.0"
2817+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.3.0.tgz#684fc0be6551a2bfcb253991eec3c786a8c063a3"
2818+
integrity sha512-JyfRnd72qRuUwItDZ00JNowsSlpQGeKfl9jxwO0FHK1qQ7FbYdoy5S7P+5wh1ISkT2QyAvr2pc9dAemDxzt75g==
2819+
dependencies:
2820+
"@typescript-eslint/scope-manager" "4.3.0"
2821+
"@typescript-eslint/types" "4.3.0"
2822+
"@typescript-eslint/typescript-estree" "4.3.0"
2823+
debug "^4.1.1"
28122824

2813-
"@typescript-eslint/[email protected]":
2814-
version "4.2.0"
2815-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.2.0.tgz#9d746240991c305bf225ad5e96cbf57e7fea0551"
2816-
integrity sha512-iWDLCB7z4MGkLipduF6EOotdHNtgxuNKnYD54nMS/oitFnsk4S3S/TE/UYXQTra550lHtlv9eGmp+dvN9pUDtA==
2825+
"@typescript-eslint/[email protected]":
2826+
version "4.3.0"
2827+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.3.0.tgz#c743227e087545968080d2362cfb1273842cb6a7"
2828+
integrity sha512-cTeyP5SCNE8QBRfc+Lgh4Xpzje46kNUhXYfc3pQWmJif92sjrFuHT9hH4rtOkDTo/si9Klw53yIr+djqGZS1ig==
2829+
dependencies:
2830+
"@typescript-eslint/types" "4.3.0"
2831+
"@typescript-eslint/visitor-keys" "4.3.0"
2832+
2833+
"@typescript-eslint/[email protected]":
2834+
version "4.3.0"
2835+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.3.0.tgz#1f0b2d5e140543e2614f06d48fb3ae95193c6ddf"
2836+
integrity sha512-Cx9TpRvlRjOppGsU6Y6KcJnUDOelja2NNCX6AZwtVHRzaJkdytJWMuYiqi8mS35MRNA3cJSwDzXePfmhU6TANw==
2837+
2838+
"@typescript-eslint/[email protected]":
2839+
version "4.3.0"
2840+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.3.0.tgz#0edc1068e6b2e4c7fdc54d61e329fce76241cee8"
2841+
integrity sha512-ZAI7xjkl+oFdLV/COEz2tAbQbR3XfgqHEGy0rlUXzfGQic6EBCR4s2+WS3cmTPG69aaZckEucBoTxW9PhzHxxw==
28172842
dependencies:
2818-
"@typescript-eslint/types" "4.2.0"
2819-
"@typescript-eslint/visitor-keys" "4.2.0"
2843+
"@typescript-eslint/types" "4.3.0"
2844+
"@typescript-eslint/visitor-keys" "4.3.0"
28202845
debug "^4.1.1"
28212846
globby "^11.0.1"
28222847
is-glob "^4.0.1"
28232848
lodash "^4.17.15"
28242849
semver "^7.3.2"
28252850
tsutils "^3.17.1"
28262851

2827-
"@typescript-eslint/visitor-keys@4.2.0":
2828-
version "4.2.0"
2829-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz#ae13838e3a260b63ae51021ecaf1d0cdea8dbba5"
2830-
integrity sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==
2852+
"@typescript-eslint/visitor-keys@4.3.0":
2853+
version "4.3.0"
2854+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.3.0.tgz#0e5ab0a09552903edeae205982e8521e17635ae0"
2855+
integrity sha512-xZxkuR7XLM6RhvLkgv9yYlTcBHnTULzfnw4i6+z2TGBLy9yljAypQaZl9c3zFvy7PNI7fYWyvKYtohyF8au3cw==
28312856
dependencies:
2832-
"@typescript-eslint/types" "4.2.0"
2857+
"@typescript-eslint/types" "4.3.0"
28332858
eslint-visitor-keys "^2.0.0"
28342859

28352860
"@webassemblyjs/[email protected]":
@@ -6566,7 +6591,7 @@ eslint-utils@^1.4.3:
65666591
dependencies:
65676592
eslint-visitor-keys "^1.1.0"
65686593

6569-
eslint-utils@^2.1.0:
6594+
eslint-utils@^2.0.0, eslint-utils@^2.1.0:
65706595
version "2.1.0"
65716596
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
65726597
integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
@@ -13921,7 +13946,7 @@ regexpp@^2.0.1:
1392113946
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
1392213947
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==
1392313948

13924-
regexpp@^3.1.0:
13949+
regexpp@^3.0.0, regexpp@^3.1.0:
1392513950
version "3.1.0"
1392613951
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
1392713952
integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==

0 commit comments

Comments
 (0)