Skip to content

feat: add support for formatting and linting TypeScript #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"description": "Liferay's Frontend Infrastructure Team monorepo",
"devDependencies": {
"@typescript-eslint/parser": "4.2.0",
"@typescript-eslint/parser": "4.3.0",
"babel-eslint": "10.1.0",
"eslint": "7.9.0",
"jest": "26.4.2",
Expand All @@ -19,10 +19,10 @@
"repository": "https://github.com/liferay/liferay-frontend-projects",
"scripts": {
"ci": "yarn format:check && yarn lint && yarn test",
"format": "prettier --write \"**/*.{js,json,md,yml}\" \"**/.*.{js,yml}\"",
"format:check": "prettier --list-different \"**/*.{js,json,md,yml}\" \"**/.*.{js,yml}\"",
"lint": "eslint \"**/*.js\" \"**/.*.js\"",
"lint:fix": "eslint --fix \"**/*.js\" \"**/.*.js\"",
"format": "prettier --write \"**/*.{js,json,md,ts,yml}\" \"**/.*.{js,ts,yml}\"",
"format:check": "prettier --list-different \"**/*.{js,json,md,ts,yml}\" \"**/.*.{js,ts,yml}\"",
"lint": "eslint \"**/*.{js,ts}\" \"**/.*.{js,ts}\"",
"lint:fix": "eslint --fix \"**/*.{js,ts}\" \"**/.*.{js,ts}\"",
"test": "jest"
},
"version": "0.0.1",
Expand Down
10 changes: 10 additions & 0 deletions projects/eslint-config/fixtures/sample.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* SPDX-FileCopyrightText: © 2020 Liferay, Inc. <https://liferay.com>
* SPDX-License-Identifier: MIT
*/

/**
* This file exists to show that we can format and lint TypeScript files.
*/

const x = 1; // eslint-disable-line @typescript-eslint/no-unused-vars
31 changes: 31 additions & 0 deletions projects/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,43 @@ const config = {
es6: true,
},
extends: ['eslint:recommended', require.resolve('eslint-config-prettier')],
overrides: [
{
files: ['*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_|^this$',
varsIgnorePattern: '^_',
},
],

// These rules can be turned off because the corresponding
// errors are caught by the TypeScript compiler itself.

'no-redeclare': 'off',
'no-undef': 'off',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
},
},
],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
plugins: [
local('@liferay/liferay'),
'@typescript-eslint/eslint-plugin',
'no-for-of-loops',
'no-only-tests',
'notice',
Expand Down
5 changes: 0 additions & 5 deletions projects/eslint-config/metal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

const config = {
extends: [require.resolve('./react')],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react'],
rules: {
/**
Expand Down
2 changes: 2 additions & 0 deletions projects/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"author": "Liferay Frontend Infrastructure Team <[email protected]>",
"dependencies": {
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"eslint-config-prettier": "^6.5.0",
"eslint-plugin-no-for-of-loops": "^1.0.0",
"eslint-plugin-no-only-tests": "^2.1.0",
Expand Down
5 changes: 0 additions & 5 deletions projects/eslint-config/portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ const local = require('./utils/local');

const config = {
extends: [require.resolve('./react')],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
plugins: [local('@liferay/portal')],
rules: {
'@liferay/portal/deprecation': 'error',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ module.exports = {
jest: true,
node: true,
},
files: ['**/test/**/*.js'],
files: ['**/test/**/*.{js,ts}'],
},
],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const liferay = require('./dependencies/liferay');
const metal = require('./dependencies/metal');

const CHECK_AND_FIX_GLOBS = [
'/*.{js,json}',
'/{src,test}/**/*.{js,scss}',
'/*.{js,json,ts}',
'/{src,test}/**/*.{js,scss,ts,tsx}',
'/src/**/*.{jsp,jspf}',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DEFAULT_OPTIONS = {
/**
* File extensions that we want Prettier to process.
*/
const EXTENSIONS = ['.js', '.json', '.jsp', '.jspf', '.scss'];
const EXTENSIONS = ['.js', '.json', '.jsp', '.jspf', '.scss', '.ts', '.tsx'];

const IGNORE_FILE = '.prettierignore';

Expand Down
87 changes: 56 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,7 @@
dependencies:
"@types/istanbul-lib-report" "*"

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

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

"@typescript-eslint/scope-manager@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.2.0.tgz#d10e6854a65e175b22a28265d372a97c8cce4bfc"
integrity sha512-Tb402cxxObSxWIVT+PnBp5ruT2V/36yj6gG4C9AjkgRlZpxrLAzWDk3neen6ToMBGeGdxtnfFLoJRUecGz9mYQ==
"@typescript-eslint/experimental-utils@4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.3.0.tgz#3f3c6c508e01b8050d51b016e7f7da0e3aefcb87"
integrity sha512-cmmIK8shn3mxmhpKfzMMywqiEheyfXLV/+yPDnOTvQX/ztngx7Lg/OD26J8gTZfkLKUmaEBxO2jYP3keV7h2OQ==
dependencies:
"@typescript-eslint/types" "4.2.0"
"@typescript-eslint/visitor-keys" "4.2.0"
"@types/json-schema" "^7.0.3"
"@typescript-eslint/scope-manager" "4.3.0"
"@typescript-eslint/types" "4.3.0"
"@typescript-eslint/typescript-estree" "4.3.0"
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/[email protected]":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.2.0.tgz#6f6b094329e72040f173123832397c7c0b910fc8"
integrity sha512-xkv5nIsxfI/Di9eVwN+G9reWl7Me9R5jpzmZUch58uQ7g0/hHVuGUbbn4NcxcM5y/R4wuJIIEPKPDb5l4Fdmwg==
"@typescript-eslint/[email protected]":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.3.0.tgz#684fc0be6551a2bfcb253991eec3c786a8c063a3"
integrity sha512-JyfRnd72qRuUwItDZ00JNowsSlpQGeKfl9jxwO0FHK1qQ7FbYdoy5S7P+5wh1ISkT2QyAvr2pc9dAemDxzt75g==
dependencies:
"@typescript-eslint/scope-manager" "4.3.0"
"@typescript-eslint/types" "4.3.0"
"@typescript-eslint/typescript-estree" "4.3.0"
debug "^4.1.1"

"@typescript-eslint/[email protected]":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.2.0.tgz#9d746240991c305bf225ad5e96cbf57e7fea0551"
integrity sha512-iWDLCB7z4MGkLipduF6EOotdHNtgxuNKnYD54nMS/oitFnsk4S3S/TE/UYXQTra550lHtlv9eGmp+dvN9pUDtA==
"@typescript-eslint/[email protected]":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.3.0.tgz#c743227e087545968080d2362cfb1273842cb6a7"
integrity sha512-cTeyP5SCNE8QBRfc+Lgh4Xpzje46kNUhXYfc3pQWmJif92sjrFuHT9hH4rtOkDTo/si9Klw53yIr+djqGZS1ig==
dependencies:
"@typescript-eslint/types" "4.3.0"
"@typescript-eslint/visitor-keys" "4.3.0"

"@typescript-eslint/[email protected]":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.3.0.tgz#1f0b2d5e140543e2614f06d48fb3ae95193c6ddf"
integrity sha512-Cx9TpRvlRjOppGsU6Y6KcJnUDOelja2NNCX6AZwtVHRzaJkdytJWMuYiqi8mS35MRNA3cJSwDzXePfmhU6TANw==

"@typescript-eslint/[email protected]":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.3.0.tgz#0edc1068e6b2e4c7fdc54d61e329fce76241cee8"
integrity sha512-ZAI7xjkl+oFdLV/COEz2tAbQbR3XfgqHEGy0rlUXzfGQic6EBCR4s2+WS3cmTPG69aaZckEucBoTxW9PhzHxxw==
dependencies:
"@typescript-eslint/types" "4.2.0"
"@typescript-eslint/visitor-keys" "4.2.0"
"@typescript-eslint/types" "4.3.0"
"@typescript-eslint/visitor-keys" "4.3.0"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
lodash "^4.17.15"
semver "^7.3.2"
tsutils "^3.17.1"

"@typescript-eslint/visitor-keys@4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.2.0.tgz#ae13838e3a260b63ae51021ecaf1d0cdea8dbba5"
integrity sha512-WIf4BNOlFOH2W+YqGWa6YKLcK/EB3gEj2apCrqLw6mme1RzBy0jtJ9ewJgnrZDB640zfnv8L+/gwGH5sYp/rGw==
"@typescript-eslint/visitor-keys@4.3.0":
version "4.3.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.3.0.tgz#0e5ab0a09552903edeae205982e8521e17635ae0"
integrity sha512-xZxkuR7XLM6RhvLkgv9yYlTcBHnTULzfnw4i6+z2TGBLy9yljAypQaZl9c3zFvy7PNI7fYWyvKYtohyF8au3cw==
dependencies:
"@typescript-eslint/types" "4.2.0"
"@typescript-eslint/types" "4.3.0"
eslint-visitor-keys "^2.0.0"

"@webassemblyjs/[email protected]":
Expand Down Expand Up @@ -6566,7 +6591,7 @@ eslint-utils@^1.4.3:
dependencies:
eslint-visitor-keys "^1.1.0"

eslint-utils@^2.1.0:
eslint-utils@^2.0.0, eslint-utils@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27"
integrity sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==
Expand Down Expand Up @@ -13921,7 +13946,7 @@ regexpp@^2.0.1:
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
integrity sha512-lv0M6+TkDVniA3aD1Eg0DVpfU/booSu7Eev3TDO/mZKHBfVjgCGTV4t4buppESEYDtkArYFOxTJWv6S5C+iaNw==

regexpp@^3.1.0:
regexpp@^3.0.0, regexpp@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
integrity sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==
Expand Down