Skip to content

Commit

Permalink
Merge branch 'puppeteer-main'
Browse files Browse the repository at this point in the history
  • Loading branch information
RomaniukVadim committed Jul 24, 2023
2 parents fd1b571 + d1ba47d commit bdda748
Show file tree
Hide file tree
Showing 1,886 changed files with 43,369 additions and 32,994 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ yarn-error.log*
# ESLint ignores.
assets/
third_party/
sandbox/
ng-schematics/src/**/files/
19 changes: 8 additions & 11 deletions .eslintplugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const prettier = require('prettier');
const prettier = require('@prettier/sync');
const prettierConfig = require('./.prettierrc.cjs');

const cleanupBlockComment = value => {
return value
Expand All @@ -18,12 +19,13 @@ const cleanupBlockComment = value => {
.trim();
};

const format = (value, offset, prettierOptions) => {
const format = (value, offset) => {
return prettier
.format(value, {
...prettierOptions,
...prettierConfig,
parser: 'markdown',
// This is the print width minus 3 (the length of ` * `) and the offset.
printWidth: prettierOptions.printWidth - (offset + 3),
printWidth: 80 - (offset + 3),
})
.trim();
};
Expand Down Expand Up @@ -57,17 +59,12 @@ const rule = {
},

create(context) {
const prettierOptions = {
printWidth: 80,
...prettier.resolveConfig.sync(context.getPhysicalFilename()),
parser: 'markdown',
};
for (const comment of context.getSourceCode().getAllComments()) {
for (const comment of context.sourceCode.getAllComments()) {
switch (comment.type) {
case 'Block': {
const offset = comment.loc.start.column;
const value = cleanupBlockComment(comment.value);
const formattedValue = format(value, offset, prettierOptions);
const formattedValue = format(value, offset);
if (formattedValue !== value) {
context.report({
node: comment,
Expand Down
116 changes: 69 additions & 47 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ module.exports = {

rules: {
// Brackets keep code readable.
curly: [2, 'all'],
curly: ['error', 'all'],
// Brackets keep code readable and `return` intentions clear.
'arrow-body-style': ['error', 'always'],
// Error if files are not formatted with Prettier correctly.
'prettier/prettier': 2,
'prettier/prettier': 'error',
// syntax preferences
'spaced-comment': [
2,
'error',
'always',
{
markers: ['*'],
},
],
eqeqeq: [2],
eqeqeq: ['error'],
'accessor-pairs': [
2,
'error',
{
getWithoutSet: false,
setWithoutGet: false,
},
],
'new-parens': 2,
'func-call-spacing': 2,
'prefer-const': 2,
'new-parens': 'error',
'func-call-spacing': 'error',
'prefer-const': 'error',

'max-len': [
2,
'error',
{
/* this setting doesn't impact things as we use Prettier to format
* our code and hence dictate the line length.
Expand All @@ -58,47 +58,47 @@ module.exports = {
},
],
// anti-patterns
'no-var': 2,
'no-with': 2,
'no-multi-str': 2,
'no-caller': 2,
'no-implied-eval': 2,
'no-labels': 2,
'no-new-object': 2,
'no-octal-escape': 2,
'no-self-compare': 2,
'no-shadow-restricted-names': 2,
'no-cond-assign': 2,
'no-debugger': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-unreachable': 2,
'no-unsafe-negation': 2,
radix: 2,
'valid-typeof': 2,
'no-var': 'error',
'no-with': 'error',
'no-multi-str': 'error',
'no-caller': 'error',
'no-implied-eval': 'error',
'no-labels': 'error',
'no-new-object': 'error',
'no-octal-escape': 'error',
'no-self-compare': 'error',
'no-shadow-restricted-names': 'error',
'no-cond-assign': 'error',
'no-debugger': 'error',
'no-dupe-keys': 'error',
'no-duplicate-case': 'error',
'no-empty-character-class': 'error',
'no-unreachable': 'error',
'no-unsafe-negation': 'error',
radix: 'error',
'valid-typeof': 'error',
'no-unused-vars': [
2,
'error',
{
args: 'none',
vars: 'local',
varsIgnorePattern:
'([fx]?describe|[fx]?it|beforeAll|beforeEach|afterAll|afterEach)',
},
],
'no-implicit-globals': [2],
'no-implicit-globals': ['error'],

// es2015 features
'require-yield': 2,
'template-curly-spacing': [2, 'never'],
'require-yield': 'error',
'template-curly-spacing': ['error', 'never'],

// ensure we don't have any it.only or describe.only in prod
'mocha/no-exclusive-tests': 'error',

'no-restricted-imports': [
'error',
{
patterns: ['*Events'],
patterns: ['*Events', '*.test.js'],
paths: [
{
name: 'mitt',
Expand Down Expand Up @@ -127,40 +127,45 @@ module.exports = {
overrides: [
{
files: ['*.ts'],
parserOptions: {
allowAutomaticSingleRunInference: true,
project: './tsconfig.base.json',
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/stylistic',
],
plugins: ['eslint-plugin-tsdoc', 'local'],
rules: {
// Keeps comments formatted.
'local/prettier-comments': 2,
'local/prettier-comments': 'error',
// Brackets keep code readable.
curly: [2, 'all'],
curly: ['error', 'all'],
// Brackets keep code readable and `return` intentions clear.
'arrow-body-style': ['error', 'always'],
// Error if comments do not adhere to `tsdoc`.
'tsdoc/syntax': 2,
'tsdoc/syntax': 'error',
// Keeps array types simple only when they are simple for readability.
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
'no-unused-vars': 0,
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{argsIgnorePattern: '^_'},
],
'func-call-spacing': 0,
'@typescript-eslint/func-call-spacing': 2,
semi: 0,
'@typescript-eslint/semi': 2,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/no-use-before-define': 0,
'func-call-spacing': 'off',
'@typescript-eslint/func-call-spacing': 'error',
semi: 'off',
'@typescript-eslint/semi': 'error',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-use-before-define': 'off',
// We have to use any on some types so the warning isn't valuable.
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-explicit-any': 'off',
// We don't require explicit return types on basic functions or
// dummy functions in tests, for example
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/explicit-function-return-type': 'off',
// We allow non-null assertions if the value was asserted using `assert` API.
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-non-null-assertion': 'off',
/**
* This is the default options (as per
* https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/docs/rules/ban-types.md),
Expand All @@ -182,15 +187,32 @@ module.exports = {
},
],
// By default this is a warning but we want it to error.
'@typescript-eslint/explicit-module-boundary-types': 2,
'@typescript-eslint/explicit-module-boundary-types': 'error',
'no-restricted-syntax': [
'error',
{
// Never use `require` in TypeScript since they are transpiled out.
selector: "CallExpression[callee.name='require']",
message: '`require` statements are not allowed. Use `import`.',
},
{
// We need this as NodeJS will run until all the timers have resolved
message: 'Use method `Deferred.race()` instead.',
selector:
'MemberExpression[object.name="Promise"][property.name="race"]',
},
{
message:
'Deferred `valueOrThrow` should not be called in `Deferred.race()` pass deferred directly',
selector:
'CallExpression[callee.object.name="Deferred"][callee.property.name="race"] > ArrayExpression > CallExpression[callee.property.name="valueOrThrow"]',
},
],
'@typescript-eslint/no-floating-promises': [
'error',
{ignoreVoid: true, ignoreIIFE: true},
],
'@typescript-eslint/prefer-ts-expect-error': 'error',
},
},
],
Expand Down
Loading

0 comments on commit bdda748

Please sign in to comment.