Upgrade to SPFx 1.20.0

Fixes bug when using custom template, webpart went in a render loop and tab freezes
This commit is contained in:
D'Andrea Nello 2024-10-31 09:00:46 +01:00
parent e793b7d8e3
commit 0a522ce6d3
12 changed files with 245 additions and 442 deletions

View File

@ -1,7 +1,7 @@
// For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer // For more information on how to run this SPFx project in a VS Code Remote Container, please visit https://aka.ms/spfx-devcontainer
{ {
"name": "SPFx 1.18.2", "name": "SPFx 1.20.0",
"image": "docker.io/m365pnp/spfx:1.18.2", "image": "docker.io/m365pnp/spfx:1.20.0",
// Set *default* container specific settings.json values on container create. // Set *default* container specific settings.json values on container create.
"settings": {}, "settings": {},
// Add the IDs of extensions you want installed when the container is created. // Add the IDs of extensions you want installed when the container is created.

View File

@ -1,95 +1,64 @@
require('@rushstack/eslint-config/patch/modern-module-resolution'); require("@rushstack/eslint-config/patch/modern-module-resolution");
module.exports = { module.exports = {
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'], extends: ["@microsoft/eslint-config-spfx/lib/profiles/react"],
parserOptions: { tsconfigRootDir: __dirname }, parserOptions: { tsconfigRootDir: __dirname },
overrides: [ overrides: [
{ {
files: ['*.ts', '*.tsx'], files: ["*.ts", "*.tsx"],
parser: '@typescript-eslint/parser', parser: "@typescript-eslint/parser",
'parserOptions': { parserOptions: {
'project': './tsconfig.json', project: "./tsconfig.json",
'ecmaVersion': 2018, ecmaVersion: 2018,
'sourceType': 'module' sourceType: "module",
}, },
rules: { rules: {
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin // Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/no-new-null': 1, "@rushstack/no-new-null": 1,
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin // Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
'@rushstack/hoist-jest-mock': 1, "@rushstack/hoist-jest-mock": 1,
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security // Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
'@rushstack/security/no-unsafe-regexp': 0, "@rushstack/security/no-unsafe-regexp": 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/adjacent-overload-signatures': 1, "@typescript-eslint/adjacent-overload-signatures": 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// //
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
'@typescript-eslint/ban-types': [
1,
{
'extendDefaults': false,
'types': {
'String': {
'message': 'Use \'string\' instead',
'fixWith': 'string'
},
'Boolean': {
'message': 'Use \'boolean\' instead',
'fixWith': 'boolean'
},
'Number': {
'message': 'Use \'number\' instead',
'fixWith': 'number'
},
'Object': {
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
},
'Symbol': {
'message': 'Use \'symbol\' instead',
'fixWith': 'symbol'
},
'Function': {
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
}
}
}
],
// RATIONALE: Code is more readable when the type of every variable is immediately obvious. // RATIONALE: Code is more readable when the type of every variable is immediately obvious.
// Even if the compiler may be able to infer a type, this inference will be unavailable // Even if the compiler may be able to infer a type, this inference will be unavailable
// to a person who is reviewing a GitHub diff. This rule makes writing code harder, // to a person who is reviewing a GitHub diff. This rule makes writing code harder,
// but writing code is a much less important activity than reading it. // but writing code is a much less important activity than reading it.
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/explicit-function-return-type': [ "@typescript-eslint/explicit-function-return-type": [
1, 1,
{ {
'allowExpressions': true, allowExpressions: true,
'allowTypedFunctionExpressions': true, allowTypedFunctionExpressions: true,
'allowHigherOrderFunctions': false allowHigherOrderFunctions: false,
} },
], ],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style. // Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
// Set to 1 (warning) or 2 (error) to enable. // Set to 1 (warning) or 2 (error) to enable.
'@typescript-eslint/explicit-member-accessibility': 0, "@typescript-eslint/explicit-member-accessibility": 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-array-constructor': 1, "@typescript-eslint/no-array-constructor": 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// //
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript. // RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
// This rule should be suppressed only in very special cases such as JSON.stringify() // This rule should be suppressed only in very special cases such as JSON.stringify()
// where the type really can be anything. Even if the type is flexible, another type // where the type really can be anything. Even if the type is flexible, another type
// may be more appropriate such as "unknown", "{}", or "Record<k,V>". // may be more appropriate such as "unknown", "{}", or "Record<k,V>".
'@typescript-eslint/no-explicit-any': 0, "@typescript-eslint/no-explicit-any": 0,
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch() // RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
// handler. Thus wherever a Promise arises, the code must either append a catch handler, // handler. Thus wherever a Promise arises, the code must either append a catch handler,
// or else return the object to a caller (who assumes this responsibility). Unterminated // or else return the object to a caller (who assumes this responsibility). Unterminated
// promise chains are a serious issue. Besides causing errors to be silently ignored, // promise chains are a serious issue. Besides causing errors to be silently ignored,
// they can also cause a NodeJS process to terminate unexpectedly. // they can also cause a NodeJS process to terminate unexpectedly.
'@typescript-eslint/no-floating-promises': 0, "@typescript-eslint/no-floating-promises": 0,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'@typescript-eslint/no-for-in-array': 2, "@typescript-eslint/no-for-in-array": 2,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-misused-new': 2, "@typescript-eslint/no-misused-new": 2,
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks // RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler // a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
// optimizations. If you are declaring loose functions/variables, it's better to make them // optimizations. If you are declaring loose functions/variables, it's better to make them
@ -102,12 +71,12 @@ module.exports = {
// dependencies are tracked more conscientiously. // dependencies are tracked more conscientiously.
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-namespace': [ "@typescript-eslint/no-namespace": [
1, 1,
{ {
'allowDeclarations': false, allowDeclarations: false,
'allowDefinitionFiles': false allowDefinitionFiles: false,
} },
], ],
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)" // RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes // that avoids the effort of declaring "title" as a field. This TypeScript feature makes
@ -118,236 +87,233 @@ module.exports = {
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Set to 1 (warning) or 2 (error) to enable the rule // Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/parameter-properties': 0, "@typescript-eslint/parameter-properties": 0,
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code // RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
// may impact performance. // may impact performance.
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-unused-vars': [ "@typescript-eslint/no-unused-vars": [
0, 0,
{ {
'vars': 'all', vars: "all",
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code, // Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures // the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
// that are overriding a base class method or implementing an interface. // that are overriding a base class method or implementing an interface.
'args': 'none' args: "none",
} },
], ],
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/no-use-before-define': [ "@typescript-eslint/no-use-before-define": [
2, 2,
{ {
'functions': false, functions: false,
'classes': true, classes: true,
'variables': true, variables: true,
'enums': true, enums: true,
'typedefs': true typedefs: true,
} },
], ],
// Disallows require statements except in import statements. // Disallows require statements except in import statements.
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports. // In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
'@typescript-eslint/no-var-requires': 'error', "@typescript-eslint/no-var-requires": "error",
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries. // RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'@typescript-eslint/prefer-namespace-keyword': 1, "@typescript-eslint/prefer-namespace-keyword": 1,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: it's up to developer to decide if he wants to add type annotations // Rationale to disable: it's up to developer to decide if he wants to add type annotations
// Set to 1 (warning) or 2 (error) to enable the rule // Set to 1 (warning) or 2 (error) to enable the rule
'@typescript-eslint/no-inferrable-types': 0, "@typescript-eslint/no-inferrable-types": 0,
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios // Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
'@typescript-eslint/no-empty-interface': 0, "@typescript-eslint/no-empty-interface": 0,
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake. // RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
'accessor-pairs': 1, "accessor-pairs": 1,
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking. // RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
'dot-notation': [ "dot-notation": [
1, 1,
{ {
'allowPattern': '^_' allowPattern: "^_",
} },
], ],
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
'eqeqeq': 1, eqeqeq: 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'for-direction': 1, "for-direction": 1,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'guard-for-in': 2, "guard-for-in": 2,
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time // RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
// to split up your code. // to split up your code.
'max-lines': ['warn', { max: 2000 }], "max-lines": ["warn", { max: 2000 }],
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-async-promise-executor': 0, "no-async-promise-executor": 0,
// RATIONALE: Deprecated language feature. // RATIONALE: Deprecated language feature.
'no-caller': 2, "no-caller": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-compare-neg-zero': 2, "no-compare-neg-zero": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-cond-assign': 2, "no-cond-assign": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-constant-condition': 1, "no-constant-condition": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-control-regex': 2, "no-control-regex": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-debugger': 1, "no-debugger": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-delete-var': 2, "no-delete-var": 2,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-duplicate-case': 2, "no-duplicate-case": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty': 1, "no-empty": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-character-class': 2, "no-empty-character-class": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-empty-pattern': 1, "no-empty-pattern": 1,
// RATIONALE: Eval is a security concern and a performance concern. // RATIONALE: Eval is a security concern and a performance concern.
'no-eval': 1, "no-eval": 1,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-ex-assign': 2, "no-ex-assign": 2,
// RATIONALE: System types are global and should not be tampered with in a scalable code base. // RATIONALE: System types are global and should not be tampered with in a scalable code base.
// If two different libraries (or two versions of the same library) both try to modify // If two different libraries (or two versions of the same library) both try to modify
// a type, only one of them can win. Polyfills are acceptable because they implement // a type, only one of them can win. Polyfills are acceptable because they implement
// a standardized interoperable contract, but polyfills are generally coded in plain // a standardized interoperable contract, but polyfills are generally coded in plain
// JavaScript. // JavaScript.
'no-extend-native': 1, "no-extend-native": 1,
// Disallow unnecessary labels // Disallow unnecessary labels
'no-extra-label': 1, "no-extra-label": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-fallthrough': 2, "no-fallthrough": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-func-assign': 1, "no-func-assign": 1,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-implied-eval': 2, "no-implied-eval": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-invalid-regexp': 2, "no-invalid-regexp": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-label-var': 2, "no-label-var": 2,
// RATIONALE: Eliminates redundant code. // RATIONALE: Eliminates redundant code.
'no-lone-blocks': 1, "no-lone-blocks": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-misleading-character-class': 2, "no-misleading-character-class": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-multi-str': 2, "no-multi-str": 2,
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to // RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()", // a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
// or else implies that the constructor is doing nontrivial computations, which is often // or else implies that the constructor is doing nontrivial computations, which is often
// a poor class design. // a poor class design.
'no-new': 1, "no-new": 1,
// RATIONALE: Obsolete language feature that is deprecated. // RATIONALE: Obsolete language feature that is deprecated.
'no-new-func': 2, "no-new-func": 2,
// RATIONALE: Obsolete language feature that is deprecated. // RATIONALE: Obsolete language feature that is deprecated.
'no-new-object': 2, "no-new-object": 2,
// RATIONALE: Obsolete notation. // RATIONALE: Obsolete notation.
'no-new-wrappers': 1, "no-new-wrappers": 1,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-octal': 2, "no-octal": 2,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
'no-octal-escape': 2, "no-octal-escape": 2,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-regex-spaces': 2, "no-regex-spaces": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-return-assign': 0, "no-return-assign": 0,
// RATIONALE: Security risk. // RATIONALE: Security risk.
'no-script-url': 1, "no-script-url": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-self-assign': 2, "no-self-assign": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-self-compare': 2, "no-self-compare": 2,
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use // RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
// commas to create compound expressions. In general code is more readable if each // commas to create compound expressions. In general code is more readable if each
// step is split onto a separate line. This also makes it easier to set breakpoints // step is split onto a separate line. This also makes it easier to set breakpoints
// in the debugger. // in the debugger.
'no-sequences': 1, "no-sequences": 1,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-shadow-restricted-names': 2, "no-shadow-restricted-names": 2,
// RATIONALE: Obsolete language feature that is deprecated. // RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-sparse-arrays': 2, "no-sparse-arrays": 2,
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception, // RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
// such flexibility adds pointless complexity, by requiring every catch block to test // such flexibility adds pointless complexity, by requiring every catch block to test
// the type of the object that it receives. Whereas if catch blocks can always assume // the type of the object that it receives. Whereas if catch blocks can always assume
// that their object implements the "Error" contract, then the code is simpler, and // that their object implements the "Error" contract, then the code is simpler, and
// we generally get useful additional information like a call stack. // we generally get useful additional information like a call stack.
'no-throw-literal': 2, "no-throw-literal": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-unmodified-loop-condition': 1, "no-unmodified-loop-condition": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unsafe-finally': 2, "no-unsafe-finally": 2,
// RATIONALE: Catches a common coding mistake. // RATIONALE: Catches a common coding mistake.
'no-unused-expressions': 1, "no-unused-expressions": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-unused-labels': 1, "no-unused-labels": 1,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-useless-catch': 0, "no-useless-catch": 0,
// RATIONALE: Avoids a potential performance problem. // RATIONALE: Avoids a potential performance problem.
'no-useless-concat': 1, "no-useless-concat": 1,
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior. // RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
// Always use "let" or "const" instead. // Always use "let" or "const" instead.
// //
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json // STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
'no-var': 2, "no-var": 2,
// RATIONALE: Generally not needed in modern code. // RATIONALE: Generally not needed in modern code.
'no-void': 1, "no-void": 1,
// RATIONALE: Obsolete language feature that is deprecated. // RATIONALE: Obsolete language feature that is deprecated.
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'no-with': 2, "no-with": 2,
// RATIONALE: Makes logic easier to understand, since constants always have a known value // RATIONALE: Makes logic easier to understand, since constants always have a known value
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js // @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
'prefer-const': 1, "prefer-const": 1,
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused. // RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
'promise/param-names': 2, "promise/param-names": 2,
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-atomic-updates': 2, "require-atomic-updates": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'require-yield': 1, "require-yield": 1,
// "Use strict" is redundant when using the TypeScript compiler. // "Use strict" is redundant when using the TypeScript compiler.
'strict': [ strict: [2, "never"],
2,
'never'
],
// RATIONALE: Catches code that is likely to be incorrect // RATIONALE: Catches code that is likely to be incorrect
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
'use-isnan': 2, "use-isnan": 2,
// STANDARDIZED BY: eslint\conf\eslint-recommended.js // STANDARDIZED BY: eslint\conf\eslint-recommended.js
// Set to 1 (warning) or 2 (error) to enable. // Set to 1 (warning) or 2 (error) to enable.
// Rationale to disable: !!{} // Rationale to disable: !!{}
'no-extra-boolean-cast': 0, "no-extra-boolean-cast": 0,
// ==================================================================== // ====================================================================
// @microsoft/eslint-plugin-spfx // @microsoft/eslint-plugin-spfx
// ==================================================================== // ====================================================================
'@microsoft/spfx/import-requires-chunk-name': 1, "@microsoft/spfx/import-requires-chunk-name": 1,
'@microsoft/spfx/no-require-ensure': 2, "@microsoft/spfx/no-require-ensure": 2,
'@microsoft/spfx/pair-react-dom-render-unmount': 1, "@microsoft/spfx/pair-react-dom-render-unmount": 1,
'react/self-closing-comp': 'off' "react/self-closing-comp": "off",
} },
}, },
{ {
// For unit tests, we can be a little bit less strict. The settings below revise the // For unit tests, we can be a little bit less strict. The settings below revise the
// defaults specified in the extended configurations, as well as above. // defaults specified in the extended configurations, as well as above.
files: [ files: [
// Test files // Test files
'*.test.ts', "*.test.ts",
'*.test.tsx', "*.test.tsx",
'*.spec.ts', "*.spec.ts",
'*.spec.tsx', "*.spec.tsx",
// Facebook convention // Facebook convention
'**/__mocks__/*.ts', "**/__mocks__/*.ts",
'**/__mocks__/*.tsx', "**/__mocks__/*.tsx",
'**/__tests__/*.ts', "**/__tests__/*.ts",
'**/__tests__/*.tsx', "**/__tests__/*.tsx",
// Microsoft convention // Microsoft convention
'**/test/*.ts', "**/test/*.ts",
'**/test/*.tsx' "**/test/*.tsx",
],
rules: {},
},
], ],
rules: {}
}
]
}; };

View File

@ -1 +1 @@
v18.18.0 v18.20.4

View File

@ -2,7 +2,7 @@
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"isCreatingSolution": true, "isCreatingSolution": true,
"environment": "spo", "environment": "spo",
"version": "1.18.2", "version": "1.20.0",
"libraryName": "react-rssreader", "libraryName": "react-rssreader",
"libraryId": "fcb53167-e0d5-4ed1-9648-149146649aa1", "libraryId": "fcb53167-e0d5-4ed1-9648-149146649aa1",
"packageManager": "npm", "packageManager": "npm",
@ -10,7 +10,7 @@
"componentType": "webpart", "componentType": "webpart",
"nodeVersion": "18.17.1", "nodeVersion": "18.17.1",
"sdkVersions": { "sdkVersions": {
"@microsoft/teams-js": "2.12.0", "@microsoft/teams-js": "2.24.0",
"@microsoft/microsoft-graph-client": "3.0.2" "@microsoft/microsoft-graph-client": "3.0.2"
} }
} }

View File

@ -4,7 +4,7 @@
A RSS Reader original based [on work by Olivier Carpentier](https://github.com/OlivierCC/spfx-40-fantastics/tree/master/src/webparts/rssReader), part of the [SPFx Fantastic 40 Web Parts](https://github.com/OlivierCC/spfx-40-fantastics) A RSS Reader original based [on work by Olivier Carpentier](https://github.com/OlivierCC/spfx-40-fantastics/tree/master/src/webparts/rssReader), part of the [SPFx Fantastic 40 Web Parts](https://github.com/OlivierCC/spfx-40-fantastics)
This RSS Reader utilizes SharePoint Framework v1.18.2 with no dependency on jQuery or a RSS Feed library. This project does utilize [ This RSS Reader utilizes SharePoint Framework v1.20.0 with no dependency on jQuery or a RSS Feed library. This project does utilize [
@pnp/spfx-property-controls](https://sharepoint.github.io/sp-dev-fx-property-controls/), and Moment React for date manipulation. Handlebar template option derived from React Search Refiners ([PnP Modern Search](https://microsoft-search.github.io/pnp-modern-search/)). Use NodeJS version 18 (validated using v18.17.1) to compile or rebuild the SPFx solution. @pnp/spfx-property-controls](https://sharepoint.github.io/sp-dev-fx-property-controls/), and Moment React for date manipulation. Handlebar template option derived from React Search Refiners ([PnP Modern Search](https://microsoft-search.github.io/pnp-modern-search/)). Use NodeJS version 18 (validated using v18.17.1) to compile or rebuild the SPFx solution.
Main features include: Main features include:
@ -27,7 +27,7 @@ Main features include:
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.| | Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. | |Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
![SPFx 1.18.2](https://img.shields.io/badge/SPFx-1.18.2-green.svg) ![SPFx 1.20](https://img.shields.io/badge/SPFx-1.20.0-green.svg)
![Node.js v18](https://img.shields.io/badge/Node.js-v18-green.svg) ![Node.js v18](https://img.shields.io/badge/Node.js-v18-green.svg)
![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg) ![Compatible with SharePoint Online](https://img.shields.io/badge/SharePoint%20Online-Compatible-green.svg)
![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower") ![Does not work with SharePoint 2019](https://img.shields.io/badge/SharePoint%20Server%202019-Incompatible-red.svg "SharePoint Server 2019 requires SPFx 1.4.1 or lower")
@ -36,7 +36,7 @@ Main features include:
![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg) ![Hosted Workbench Compatible](https://img.shields.io/badge/Hosted%20Workbench-Compatible-green.svg)
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg) ![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
Tested with: Node.js v18.17.1 Tested with: Node.js v18.20.4
## Applies to ## Applies to
@ -60,6 +60,7 @@ Version|Date|Comments
1.0.3 | April 21, 2023 | Added theme awareness 1.0.3 | April 21, 2023 | Added theme awareness
1.0.4 | May 25, 2023 | Fixed direct request issues 1.0.4 | May 25, 2023 | Fixed direct request issues
1.1.0 | February 6, 2024 | Upgraded to SPFx 1.18.2 1.1.0 | February 6, 2024 | Upgraded to SPFx 1.18.2
1.2.0 | October 30, 2024 | Upgraded to SPFx 1.20.0
## Minimal Path to Awesome ## Minimal Path to Awesome

View File

@ -9,7 +9,7 @@
"A RSS Reader original based on work completed by Olivier Carpentier\u0027s" "A RSS Reader original based on work completed by Olivier Carpentier\u0027s"
], ],
"creationDateTime": "2020-11-22", "creationDateTime": "2020-11-22",
"updateDateTime": "2023-08-18", "updateDateTime": "2024-10-30",
"products": [ "products": [
"SharePoint" "SharePoint"
], ],
@ -20,7 +20,7 @@
}, },
{ {
"key": "SPFX-VERSION", "key": "SPFX-VERSION",
"value": "1.18.2" "value": "1.20.0"
} }
], ],
"thumbnails": [ "thumbnails": [

View File

@ -16,21 +16,22 @@ build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not came
********************************************************************************************/ ********************************************************************************************/
build.configureWebpack.mergeConfig({ build.configureWebpack.mergeConfig({
additionalConfiguration: (generatedConfiguration) => { additionalConfiguration: (generatedConfiguration) => {
generatedConfiguration.resolve.alias = { handlebars: 'handlebars/dist/handlebars.min.js' }; generatedConfiguration.resolve.fallback = {
fs: false, // Use "false" as fs cannot be polyfilled for browser environments
stream: require.resolve('stream-browserify'),
timers: require.resolve('timers-browserify'),
readline: false
};
generatedConfiguration.module.rules.push( generatedConfiguration.resolve.alias = {
{ handlebars: 'handlebars/dist/handlebars.min.js'
};
generatedConfiguration.module.rules.push({
test: /utils\.js$/, test: /utils\.js$/,
loader: 'unlazy-loader', loader: 'unlazy-loader',
include: [ include: [/node_modules/]
/node_modules/, });
]
}
);
generatedConfiguration.node = {
fs: 'empty'
}
const lastDirName = path.basename(__dirname); const lastDirName = path.basename(__dirname);
const dropPath = path.join(__dirname, 'temp', 'stats'); const dropPath = path.join(__dirname, 'temp', 'stats');
@ -47,6 +48,8 @@ build.configureWebpack.mergeConfig({
} }
}); });
var getTasks = build.rig.getTasks; var getTasks = build.rig.getTasks;
build.rig.getTasks = function () { build.rig.getTasks = function () {
var result = getTasks.call(build.rig); var result = getTasks.call(build.rig);

View File

@ -1,12 +1,9 @@
{ {
"name": "react-rssreader", "name": "react-rssreader",
"version": "1.1.0", "version": "1.2.0",
"private": true, "private": true,
"engines": { "engines": {
"node": "18.17.1" "node": ">=18.17.1 <19.0.0"
},
"resolutions": {
"@types/react": "16.8.8"
}, },
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
@ -16,19 +13,18 @@
}, },
"dependencies": { "dependencies": {
"@fluentui/react": "8.106.4", "@fluentui/react": "8.106.4",
"@microsoft/sp-core-library": "1.18.2", "@microsoft/sp-adaptive-card-extension-base": "1.20.0",
"@microsoft/sp-lodash-subset": "1.18.2", "@microsoft/sp-core-library": "1.20.0",
"@microsoft/sp-office-ui-fabric-core": "1.18.2", "@microsoft/sp-lodash-subset": "1.20.0",
"@microsoft/sp-property-pane": "1.18.2", "@microsoft/sp-office-ui-fabric-core": "1.20.0",
"@microsoft/sp-webpart-base": "1.18.2", "@microsoft/sp-property-pane": "1.20.0",
"@pnp/logging": "3.22.0", "@microsoft/sp-webpart-base": "1.20.0",
"@pnp/spfx-controls-react": "^3.17.0", "@pnp/logging": "4.6.0",
"@pnp/spfx-property-controls": "3.16.0", "@pnp/spfx-controls-react": "3.19.0",
"@types/handlebars": "4.0.39", "@pnp/spfx-property-controls": "3.18.0",
"ace-builds": "1.32.5", "ace-builds": "1.32.5",
"common-tags": "1.8.0", "common-tags": "1.8.0",
"handlebars": "4.7.7", "handlebars": "4.7.8",
"handlebars-helpers": "^0.8.4",
"moment": "2.29.0", "moment": "2.29.0",
"react": "17.0.1", "react": "17.0.1",
"react-ace": "10.1.0", "react-ace": "10.1.0",
@ -36,24 +32,30 @@
"react-moment": "1.1.3", "react-moment": "1.1.3",
"ts-md5": "1.2.4", "ts-md5": "1.2.4",
"tslib": "2.3.1", "tslib": "2.3.1",
"util": "^0.12.5",
"xml2js": "0.4.19" "xml2js": "0.4.19"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/eslint-config-spfx": "1.18.2", "@microsoft/eslint-config-spfx": "1.20.2",
"@microsoft/eslint-plugin-spfx": "1.18.2", "@microsoft/eslint-plugin-spfx": "1.20.2",
"@microsoft/rush-stack-compiler-4.7": "0.1.0", "@microsoft/rush-stack-compiler-4.7": "0.1.0",
"@microsoft/sp-build-web": "1.18.2", "@microsoft/sp-build-web": "1.20.2",
"@microsoft/sp-module-interfaces": "1.18.2", "@microsoft/sp-module-interfaces": "1.20.2",
"@rushstack/eslint-config": "2.5.1", "@rushstack/eslint-config": "4.0.1",
"@types/react": "17.0.45", "@types/react": "17.0.45",
"@types/react-dom": "17.0.17", "@types/react-dom": "17.0.17",
"@types/webpack-env": "1.15.2", "@types/webpack-env": "1.15.2",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"ajv": "6.12.5", "ajv": "6.12.5",
"eslint": "8.7.0", "eslint": "8.57.0",
"eslint-plugin-react-hooks": "4.3.0", "eslint-plugin-react-hooks": "4.3.0",
"gulp": "4.0.2", "gulp": "4.0.2",
"stream-browserify": "^3.0.0",
"timers-browserify": "^2.0.12",
"typescript": "4.7.4", "typescript": "4.7.4",
"unlazy-loader": "0.1.3", "unlazy-loader": "0.1.3",
"webpack-bundle-analyzer": "^3.0.3" "url": "^0.11.4",
"webpack-bundle-analyzer": "^4.10.2"
} }
} }

View File

@ -1,28 +1,17 @@
import { html } from 'common-tags'; import { html } from 'common-tags';
import * as Handlebars from 'handlebars'; import * as Handlebars from 'handlebars';
import * as HandlebarsHelpers from 'handlebars-helpers';
// import 'core-js/modules/es7.array.includes.js';
// import 'core-js/modules/es6.string.includes.js';
// import 'core-js/modules/es6.number.is-nan.js';
import templateStyles from './BaseTemplateService.module.scss'; import templateStyles from './BaseTemplateService.module.scss';
import { format } from 'date-fns'; // For date formatting
import * as _ from 'lodash';
abstract class BaseTemplateService { abstract class BaseTemplateService {
private _helper: any = null;
public CurrentLocale: string = "en"; public CurrentLocale: string = "en";
constructor() { constructor() {
// Registers all helpers // Register custom helpers
this.registerTemplateServices(); this.registerTemplateServices();
} }
private async LoadHandlebarsHelpers(): Promise<void> {
this._helper = HandlebarsHelpers({
handlebars: Handlebars
});
}
/** /**
* Gets the default Handlebars list item template used in list layout * Gets the default Handlebars list item template used in list layout
* @returns the template HTML markup * @returns the template HTML markup
@ -37,7 +26,7 @@ abstract class BaseTemplateService {
<a href="{{channel/item/link}}" target="_blank">{{channel/item/title}}</a> <a href="{{channel/item/link}}" target="_blank">{{channel/item/title}}</a>
</div> </div>
<div class="itemDate"> <div class="itemDate">
{{getDate channel/item/pubDate "MM/DD/YYYY"}} {{getDate channel/item/pubDate "MM/dd/yyyy"}}
</div> </div>
<div class="itemContent"> <div class="itemContent">
{{{getShortText channel/item/description 100 true}}} {{{getShortText channel/item/description 100 true}}}
@ -71,7 +60,7 @@ abstract class BaseTemplateService {
<div class="ms-Grid-col ms-sm12"> <div class="ms-Grid-col ms-sm12">
<span class="primaryText"><a href="{{channel/item/link}}">{{channel/item/title}}</a></span> <span class="primaryText"><a href="{{channel/item/link}}">{{channel/item/title}}</a></span>
<span class="secondaryText">{{{getShortText channel/item/description 100 true}}}</span> <span class="secondaryText">{{{getShortText channel/item/description 100 true}}}</span>
<span class="dateText">{{getDate channel/item/pubDate "MM/DD/YYYY"}}</span> <span class="dateText">{{getDate channel/item/pubDate "MM/dd/yyyy"}}</span>
</div> </div>
</div> </div>
</div> </div>
@ -93,240 +82,84 @@ abstract class BaseTemplateService {
* Registers useful helpers for search results templates * Registers useful helpers for search results templates
*/ */
private registerTemplateServices(): void { private registerTemplateServices(): void {
// Return the URL or Title part of a URL automatic managed property // Register a helper for URL field extraction
// <p>{{getUrlField MyLinkOWSURLH "Title"}}</p>
Handlebars.registerHelper("getUrlField", (urlField: string, value: "URL" | "Title") => { Handlebars.registerHelper("getUrlField", (urlField: string, value: "URL" | "Title") => {
const separatorPos = urlField.indexOf(","); const separatorPos = urlField.indexOf(",");
if (value === "URL") { return value === "URL" ? urlField.substring(0, separatorPos) : urlField.substring(separatorPos + 1).trim();
return urlField.substr(0, separatorPos);
}
return urlField.substr(separatorPos + 1).trim();
}); });
// Return the formatted date according to current locale using moment.js // Register a date formatting helper using date-fns
// <p>{{getDate Created "LL"}}</p> Handlebars.registerHelper("getDate", (date: string, formatPattern: string) => {
Handlebars.registerHelper("getDate", (date: string, format: string) => { return format(new Date(date), formatPattern); // Adjusts date format using date-fns
try {
const d = this._helper.moment(date, format, { lang: this.CurrentLocale, datejs: false });
return d;
} catch (error) {
return;
}
}); });
// Get the first maxLength characters from a string // Register a helper for getting a substring
// <p>{{getShortText Description 100}}</p>
Handlebars.registerHelper("getShortText", (inputString: string, maxLength: number, ignoreHtml: boolean) => { Handlebars.registerHelper("getShortText", (inputString: string, maxLength: number, ignoreHtml: boolean) => {
if (!inputString || inputString.length < 1) { if (!inputString) return "";
return "";
}
//remove Html tags if necessary
if (ignoreHtml) { if (ignoreHtml) {
const div = document.createElement("div"); const div = document.createElement("div");
div.innerHTML = inputString; div.innerHTML = inputString;
inputString = (div.textContent || div.innerText || "").replace(/&nbsp;/ig, "").trim(); inputString = (div.textContent || div.innerText || "").replace(/&nbsp;/g, "").trim();
} }
if (inputString.length < maxLength) { return inputString.length <= maxLength ? inputString : `${inputString.slice(0, maxLength)}...`;
return inputString;
}
else {
return inputString.substr(0, maxLength).trim() + "...";
}
}); });
} }
private registerHandlebarsHelpers():void {
// Lodash-based helpers
Handlebars.registerHelper('after', (arr, n) => _.after(n, arr));
Handlebars.registerHelper('filter', (arr, predicate) => _.filter(arr, predicate));
Handlebars.registerHelper('first', arr => _.first(arr));
Handlebars.registerHelper('forEach', (arr, fn) => _.forEach(arr, fn));
Handlebars.registerHelper('isArray', value => _.isArray(value));
Handlebars.registerHelper('join', (arr, separator) => _.join(arr, separator));
Handlebars.registerHelper('last', arr => _.last(arr));
Handlebars.registerHelper('lengthEqual', (arr, length) => _.size(arr) === length);
Handlebars.registerHelper('map', (arr, fn) => _.map(arr, fn));
Handlebars.registerHelper('sort', arr => _.sortBy(arr));
Handlebars.registerHelper('sum', arr => _.sum(arr));
Handlebars.registerHelper('truncate', (str, length) => _.truncate(str, { length }));
Handlebars.registerHelper('capitalize', str => _.capitalize(str));
Handlebars.registerHelper('camelCase', str => _.camelCase(str));
Handlebars.registerHelper('toUpper', str => _.toUpper(str));
Handlebars.registerHelper('toLower', str => _.toLower(str));
// Native JS-based helpers
Handlebars.registerHelper('encodeURI', str => encodeURI(str));
Handlebars.registerHelper('decodeURI', str => decodeURI(str));
Handlebars.registerHelper('toFixed', (num, digits) => Number(num).toFixed(digits));
// Custom helpers
Handlebars.registerHelper('add', (a, b) => a + b);
Handlebars.registerHelper('subtract', (a, b) => a - b);
Handlebars.registerHelper('multiply', (a, b) => a * b);
Handlebars.registerHelper('divide', (a, b) => a / b);
}
/** /**
* Compile the specified Handlebars template with the associated context object¸ * Compile the specified Handlebars template with the associated context object¸
* @returns the compiled HTML template string * @returns the compiled HTML template string
*/ */
public async processTemplate(templateContext: any, templateContent: string): Promise<string> { public async processTemplate(templateContext: any, templateContent: string): Promise<string> {
// Process the Handlebars template // Register helpers only once
const handlebarFunctionNames = [ if (!Handlebars.helpers.after) this.registerHandlebarsHelpers();
"getDate",
"after",
"arrayify",
"before",
"eachIndex",
"filter",
"first",
"forEach",
"inArray",
"isArray",
"itemAt",
"join",
"last",
"lengthEqual",
"map",
"some",
"sort",
"sortBy",
"withAfter",
"withBefore",
"withFirst",
"withGroup",
"withLast",
"withSort",
"embed",
"gist",
"jsfiddle",
"isEmpty",
"iterate",
"length",
"and",
"compare",
"contains",
"gt",
"gte",
"has",
"eq",
"ifEven",
"ifNth",
"ifOdd",
"is",
"isnt",
"lt",
"lte",
"neither",
"or",
"unlessEq",
"unlessGt",
"unlessLt",
"unlessGteq",
"unlessLteq",
"moment",
"fileSize",
"read",
"readdir",
"css",
"ellipsis",
"js",
"sanitize",
"truncate",
"ul",
"ol",
"thumbnailImage",
"i18n",
"inflect",
"ordinalize",
"info",
"bold",
"warn",
"error",
"debug",
"_inspect",
"markdown",
"md",
"mm",
"match",
"isMatch",
"add",
"subtract",
"divide",
"multiply",
"floor",
"ceil",
"round",
"sum",
"avg",
"default",
"option",
"noop",
"withHash",
"addCommas",
"phoneNumber",
"random",
"toAbbr",
"toExponential",
"toFixed",
"toFloat",
"toInt",
"toPrecision",
"extend",
"forIn",
"forOwn",
"toPath",
"get",
"getObject",
"hasOwn",
"isObject",
"merge",
"JSONparse",
"parseJSON",
"pick",
"JSONstringify",
"stringify",
"absolute",
"dirname",
"relative",
"basename",
"stem",
"extname",
"segments",
"camelcase",
"capitalize",
"capitalizeAll",
"center",
"chop",
"dashcase",
"dotcase",
"hyphenate",
"isString",
"lowercase",
"occurrences",
"pascalcase",
"pathcase",
"plusify",
"reverse",
"replace",
"sentence",
"snakecase",
"split",
"startsWith",
"titleize",
"trim",
"uppercase",
"encodeURI",
"decodeURI",
"urlResolve",
"urlParse",
"stripQuerystring",
"stripProtocol"
];
for (let i = 0; i < handlebarFunctionNames.length; i++) {
const element = handlebarFunctionNames[i];
const regExString: string = "{{#?.*?" + element + ".*?}}";
const regEx = new RegExp(regExString, "m");
if (regEx.test(templateContent)) {
await this.LoadHandlebarsHelpers();
break;
}
}
// Compile and execute template
const template = Handlebars.compile(templateContent); const template = Handlebars.compile(templateContent);
const result = template(templateContext); return template(templateContext);
return result;
} }
/**
* Verifies if the template fiel path is correct
* @param filePath the file path string
*/
public static isValidTemplateFile(filePath: string): boolean { public static isValidTemplateFile(filePath: string): boolean {
const path = filePath.toLowerCase().trim(); const path = filePath.toLowerCase().trim();
const pathExtension = path.substring(path.lastIndexOf('.')); const extension = path.substring(path.lastIndexOf('.'));
return (pathExtension === '.htm' || pathExtension === '.html'); return extension === '.htm' || extension === '.html';
} }
public abstract getFileContent(fileUrl: string): Promise<string>; public abstract getFileContent(fileUrl: string): Promise<string>;
public abstract ensureFileResolves(fileUrl: string): Promise<void>; public abstract ensureFileResolves(fileUrl: string): Promise<void>;
} }
export default BaseTemplateService; export default BaseTemplateService;

View File

@ -278,7 +278,6 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
* @param newValue the new value for this property * @param newValue the new value for this property
*/ */
private async _onCustomPropertyPaneChange(propertyPath: string, newValue: any): Promise<void> { private async _onCustomPropertyPaneChange(propertyPath: string, newValue: any): Promise<void> {
// Stores the new value in web part properties // Stores the new value in web part properties
update(this.properties, propertyPath, (): any => { return newValue; }); update(this.properties, propertyPath, (): any => { return newValue; });

View File

@ -39,13 +39,15 @@ export default class RssResultsTemplate extends React.Component<IRssResultsTempl
} }
// public componentWillReceiveProps(nextProps: IRssResultsTemplateProps): void { public componentDidUpdate(prevProps: IRssResultsTemplateProps): void {
public componentDidUpdate(prevProps: any): void { // Only update template if props have changed
if (
prevProps.templateContent !== this.props.templateContent ||
prevProps.templateContext !== this.props.templateContext
) {
this._updateTemplate(this.props); this._updateTemplate(this.props);
} }
}
private async _updateTemplate(props: IRssResultsTemplateProps): Promise<void> { private async _updateTemplate(props: IRssResultsTemplateProps): Promise<void> {
const templateContent = props.templateContent; const templateContent = props.templateContent;

View File

@ -279,7 +279,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
const rssFeed: IRssReaderResponse = await rssReaderService.getFeed(feedRequest); const rssFeed: IRssReaderResponse = await rssReaderService.getFeed(feedRequest);
if (rssFeed && rssFeed.query && rssFeed.query.results) { if (rssFeed && rssFeed.query && rssFeed.query.results) {
this.setState({ this.setState({
rssFeedReady: true, rssFeedReady: true,
rssFeed: rssFeed, rssFeed: rssFeed,
@ -288,7 +287,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
} }
else { else {
this.setState({ this.setState({
rssFeedReady: true, rssFeedReady: true,
rssFeed: null, rssFeed: null,
@ -298,7 +296,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
} }
catch (error) { catch (error) {
this.setState({ this.setState({
rssFeedReady: false, rssFeedReady: false,
rssFeed: null, rssFeed: null,