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:
parent
e793b7d8e3
commit
0a522ce6d3
|
@ -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
|
||||
{
|
||||
"name": "SPFx 1.18.2",
|
||||
"image": "docker.io/m365pnp/spfx:1.18.2",
|
||||
"name": "SPFx 1.20.0",
|
||||
"image": "docker.io/m365pnp/spfx:1.20.0",
|
||||
// Set *default* container specific settings.json values on container create.
|
||||
"settings": {},
|
||||
// Add the IDs of extensions you want installed when the container is created.
|
||||
|
|
|
@ -1,95 +1,64 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
require("@rushstack/eslint-config/patch/modern-module-resolution");
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
extends: ["@microsoft/eslint-config-spfx/lib/profiles/react"],
|
||||
parserOptions: { tsconfigRootDir: __dirname },
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'project': './tsconfig.json',
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
files: ["*.ts", "*.tsx"],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
ecmaVersion: 2018,
|
||||
sourceType: "module",
|
||||
},
|
||||
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
|
||||
'@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
|
||||
'@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
|
||||
'@rushstack/security/no-unsafe-regexp': 0,
|
||||
"@rushstack/security/no-unsafe-regexp": 0,
|
||||
// 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
|
||||
//
|
||||
// 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.
|
||||
// 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,
|
||||
// but writing code is a much less important activity than reading it.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
"@typescript-eslint/explicit-function-return-type": [
|
||||
1,
|
||||
{
|
||||
'allowExpressions': true,
|
||||
'allowTypedFunctionExpressions': true,
|
||||
'allowHigherOrderFunctions': false
|
||||
}
|
||||
allowExpressions: true,
|
||||
allowTypedFunctionExpressions: true,
|
||||
allowHigherOrderFunctions: false,
|
||||
},
|
||||
],
|
||||
// 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.
|
||||
// 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
|
||||
'@typescript-eslint/no-array-constructor': 1,
|
||||
"@typescript-eslint/no-array-constructor": 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// 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()
|
||||
// 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>".
|
||||
'@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()
|
||||
// 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
|
||||
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||
// 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.
|
||||
'@typescript-eslint/no-for-in-array': 2,
|
||||
"@typescript-eslint/no-for-in-array": 2,
|
||||
// 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
|
||||
// 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
|
||||
|
@ -102,12 +71,12 @@ module.exports = {
|
|||
// dependencies are tracked more conscientiously.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-namespace': [
|
||||
"@typescript-eslint/no-namespace": [
|
||||
1,
|
||||
{
|
||||
'allowDeclarations': false,
|
||||
'allowDefinitionFiles': false
|
||||
}
|
||||
allowDeclarations: false,
|
||||
allowDefinitionFiles: false,
|
||||
},
|
||||
],
|
||||
// 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
|
||||
|
@ -118,236 +87,233 @@ module.exports = {
|
|||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// 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
|
||||
// may impact performance.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
0,
|
||||
{
|
||||
'vars': 'all',
|
||||
vars: "all",
|
||||
// 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
|
||||
// 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
|
||||
'@typescript-eslint/no-use-before-define': [
|
||||
"@typescript-eslint/no-use-before-define": [
|
||||
2,
|
||||
{
|
||||
'functions': false,
|
||||
'classes': true,
|
||||
'variables': true,
|
||||
'enums': true,
|
||||
'typedefs': true
|
||||
}
|
||||
functions: false,
|
||||
classes: true,
|
||||
variables: true,
|
||||
enums: true,
|
||||
typedefs: true,
|
||||
},
|
||||
],
|
||||
// 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.
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||
//
|
||||
// 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
|
||||
// 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
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
"@typescript-eslint/no-inferrable-types": 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// 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.
|
||||
'accessor-pairs': 1,
|
||||
"accessor-pairs": 1,
|
||||
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||
'dot-notation': [
|
||||
"dot-notation": [
|
||||
1,
|
||||
{
|
||||
'allowPattern': '^_'
|
||||
}
|
||||
allowPattern: "^_",
|
||||
},
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'eqeqeq': 1,
|
||||
eqeqeq: 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'for-direction': 1,
|
||||
"for-direction": 1,
|
||||
// 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
|
||||
// to split up your code.
|
||||
'max-lines': ['warn', { max: 2000 }],
|
||||
"max-lines": ["warn", { max: 2000 }],
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-async-promise-executor': 0,
|
||||
"no-async-promise-executor": 0,
|
||||
// RATIONALE: Deprecated language feature.
|
||||
'no-caller': 2,
|
||||
"no-caller": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-compare-neg-zero': 2,
|
||||
"no-compare-neg-zero": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-cond-assign': 2,
|
||||
"no-cond-assign": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-constant-condition': 1,
|
||||
"no-constant-condition": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-control-regex': 2,
|
||||
"no-control-regex": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-debugger': 1,
|
||||
"no-debugger": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-delete-var': 2,
|
||||
"no-delete-var": 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-duplicate-case': 2,
|
||||
"no-duplicate-case": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty': 1,
|
||||
"no-empty": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-character-class': 2,
|
||||
"no-empty-character-class": 2,
|
||||
// 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.
|
||||
'no-eval': 1,
|
||||
"no-eval": 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// 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.
|
||||
// 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 standardized interoperable contract, but polyfills are generally coded in plain
|
||||
// JavaScript.
|
||||
'no-extend-native': 1,
|
||||
"no-extend-native": 1,
|
||||
// Disallow unnecessary labels
|
||||
'no-extra-label': 1,
|
||||
"no-extra-label": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-fallthrough': 2,
|
||||
"no-fallthrough": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-func-assign': 1,
|
||||
"no-func-assign": 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-implied-eval': 2,
|
||||
"no-implied-eval": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-invalid-regexp': 2,
|
||||
"no-invalid-regexp": 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-label-var': 2,
|
||||
"no-label-var": 2,
|
||||
// RATIONALE: Eliminates redundant code.
|
||||
'no-lone-blocks': 1,
|
||||
"no-lone-blocks": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-misleading-character-class': 2,
|
||||
"no-misleading-character-class": 2,
|
||||
// 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
|
||||
// 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
|
||||
// a poor class design.
|
||||
'no-new': 1,
|
||||
"no-new": 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-func': 2,
|
||||
"no-new-func": 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-object': 2,
|
||||
"no-new-object": 2,
|
||||
// RATIONALE: Obsolete notation.
|
||||
'no-new-wrappers': 1,
|
||||
"no-new-wrappers": 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-octal': 2,
|
||||
"no-octal": 2,
|
||||
// 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
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-regex-spaces': 2,
|
||||
"no-regex-spaces": 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-return-assign': 0,
|
||||
"no-return-assign": 0,
|
||||
// RATIONALE: Security risk.
|
||||
'no-script-url': 1,
|
||||
"no-script-url": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-self-assign': 2,
|
||||
"no-self-assign": 2,
|
||||
// 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
|
||||
// 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
|
||||
// in the debugger.
|
||||
'no-sequences': 1,
|
||||
"no-sequences": 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-shadow-restricted-names': 2,
|
||||
"no-shadow-restricted-names": 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// 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,
|
||||
// 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
|
||||
// that their object implements the "Error" contract, then the code is simpler, and
|
||||
// we generally get useful additional information like a call stack.
|
||||
'no-throw-literal': 2,
|
||||
"no-throw-literal": 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unmodified-loop-condition': 1,
|
||||
"no-unmodified-loop-condition": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unsafe-finally': 2,
|
||||
"no-unsafe-finally": 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unused-expressions': 1,
|
||||
"no-unused-expressions": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unused-labels': 1,
|
||||
"no-unused-labels": 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-useless-catch': 0,
|
||||
"no-useless-catch": 0,
|
||||
// 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.
|
||||
// Always use "let" or "const" instead.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'no-var': 2,
|
||||
"no-var": 2,
|
||||
// RATIONALE: Generally not needed in modern code.
|
||||
'no-void': 1,
|
||||
"no-void": 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// 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
|
||||
// @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.
|
||||
'promise/param-names': 2,
|
||||
"promise/param-names": 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-atomic-updates': 2,
|
||||
"require-atomic-updates": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-yield': 1,
|
||||
"require-yield": 1,
|
||||
// "Use strict" is redundant when using the TypeScript compiler.
|
||||
'strict': [
|
||||
2,
|
||||
'never'
|
||||
],
|
||||
strict: [2, "never"],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'use-isnan': 2,
|
||||
"use-isnan": 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
// Rationale to disable: !!{}
|
||||
'no-extra-boolean-cast': 0,
|
||||
"no-extra-boolean-cast": 0,
|
||||
// ====================================================================
|
||||
// @microsoft/eslint-plugin-spfx
|
||||
// ====================================================================
|
||||
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||
'@microsoft/spfx/no-require-ensure': 2,
|
||||
'@microsoft/spfx/pair-react-dom-render-unmount': 1,
|
||||
'react/self-closing-comp': 'off'
|
||||
}
|
||||
"@microsoft/spfx/import-requires-chunk-name": 1,
|
||||
"@microsoft/spfx/no-require-ensure": 2,
|
||||
"@microsoft/spfx/pair-react-dom-render-unmount": 1,
|
||||
"react/self-closing-comp": "off",
|
||||
},
|
||||
},
|
||||
{
|
||||
// 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.
|
||||
files: [
|
||||
// Test files
|
||||
'*.test.ts',
|
||||
'*.test.tsx',
|
||||
'*.spec.ts',
|
||||
'*.spec.tsx',
|
||||
"*.test.ts",
|
||||
"*.test.tsx",
|
||||
"*.spec.ts",
|
||||
"*.spec.tsx",
|
||||
|
||||
// Facebook convention
|
||||
'**/__mocks__/*.ts',
|
||||
'**/__mocks__/*.tsx',
|
||||
'**/__tests__/*.ts',
|
||||
'**/__tests__/*.tsx',
|
||||
"**/__mocks__/*.ts",
|
||||
"**/__mocks__/*.tsx",
|
||||
"**/__tests__/*.ts",
|
||||
"**/__tests__/*.tsx",
|
||||
|
||||
// Microsoft convention
|
||||
'**/test/*.ts',
|
||||
'**/test/*.tsx'
|
||||
"**/test/*.ts",
|
||||
"**/test/*.tsx",
|
||||
],
|
||||
rules: {},
|
||||
},
|
||||
],
|
||||
rules: {}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -1 +1 @@
|
|||
v18.18.0
|
||||
v18.20.4
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"@microsoft/generator-sharepoint": {
|
||||
"isCreatingSolution": true,
|
||||
"environment": "spo",
|
||||
"version": "1.18.2",
|
||||
"version": "1.20.0",
|
||||
"libraryName": "react-rssreader",
|
||||
"libraryId": "fcb53167-e0d5-4ed1-9648-149146649aa1",
|
||||
"packageManager": "npm",
|
||||
|
@ -10,7 +10,7 @@
|
|||
"componentType": "webpart",
|
||||
"nodeVersion": "18.17.1",
|
||||
"sdkVersions": {
|
||||
"@microsoft/teams-js": "2.12.0",
|
||||
"@microsoft/teams-js": "2.24.0",
|
||||
"@microsoft/microsoft-graph-client": "3.0.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
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.
|
||||
|
||||
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.|
|
||||
|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)
|
||||
![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")
|
||||
|
@ -36,7 +36,7 @@ Main features include:
|
|||
![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)
|
||||
|
||||
Tested with: Node.js v18.17.1
|
||||
Tested with: Node.js v18.20.4
|
||||
|
||||
## Applies to
|
||||
|
||||
|
@ -60,6 +60,7 @@ Version|Date|Comments
|
|||
1.0.3 | April 21, 2023 | Added theme awareness
|
||||
1.0.4 | May 25, 2023 | Fixed direct request issues
|
||||
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
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"A RSS Reader original based on work completed by Olivier Carpentier\u0027s"
|
||||
],
|
||||
"creationDateTime": "2020-11-22",
|
||||
"updateDateTime": "2023-08-18",
|
||||
"updateDateTime": "2024-10-30",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
|
@ -20,7 +20,7 @@
|
|||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.18.2"
|
||||
"value": "1.20.0"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
|
|
|
@ -16,21 +16,22 @@ build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not came
|
|||
********************************************************************************************/
|
||||
build.configureWebpack.mergeConfig({
|
||||
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$/,
|
||||
loader: 'unlazy-loader',
|
||||
include: [
|
||||
/node_modules/,
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
generatedConfiguration.node = {
|
||||
fs: 'empty'
|
||||
}
|
||||
include: [/node_modules/]
|
||||
});
|
||||
|
||||
const lastDirName = path.basename(__dirname);
|
||||
const dropPath = path.join(__dirname, 'temp', 'stats');
|
||||
|
@ -47,6 +48,8 @@ build.configureWebpack.mergeConfig({
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
{
|
||||
"name": "react-rssreader",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": "18.17.1"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "16.8.8"
|
||||
"node": ">=18.17.1 <19.0.0"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
|
@ -16,19 +13,18 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@fluentui/react": "8.106.4",
|
||||
"@microsoft/sp-core-library": "1.18.2",
|
||||
"@microsoft/sp-lodash-subset": "1.18.2",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.18.2",
|
||||
"@microsoft/sp-property-pane": "1.18.2",
|
||||
"@microsoft/sp-webpart-base": "1.18.2",
|
||||
"@pnp/logging": "3.22.0",
|
||||
"@pnp/spfx-controls-react": "^3.17.0",
|
||||
"@pnp/spfx-property-controls": "3.16.0",
|
||||
"@types/handlebars": "4.0.39",
|
||||
"@microsoft/sp-adaptive-card-extension-base": "1.20.0",
|
||||
"@microsoft/sp-core-library": "1.20.0",
|
||||
"@microsoft/sp-lodash-subset": "1.20.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.20.0",
|
||||
"@microsoft/sp-property-pane": "1.20.0",
|
||||
"@microsoft/sp-webpart-base": "1.20.0",
|
||||
"@pnp/logging": "4.6.0",
|
||||
"@pnp/spfx-controls-react": "3.19.0",
|
||||
"@pnp/spfx-property-controls": "3.18.0",
|
||||
"ace-builds": "1.32.5",
|
||||
"common-tags": "1.8.0",
|
||||
"handlebars": "4.7.7",
|
||||
"handlebars-helpers": "^0.8.4",
|
||||
"handlebars": "4.7.8",
|
||||
"moment": "2.29.0",
|
||||
"react": "17.0.1",
|
||||
"react-ace": "10.1.0",
|
||||
|
@ -36,24 +32,30 @@
|
|||
"react-moment": "1.1.3",
|
||||
"ts-md5": "1.2.4",
|
||||
"tslib": "2.3.1",
|
||||
"util": "^0.12.5",
|
||||
"xml2js": "0.4.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/eslint-config-spfx": "1.18.2",
|
||||
"@microsoft/eslint-plugin-spfx": "1.18.2",
|
||||
"@microsoft/eslint-config-spfx": "1.20.2",
|
||||
"@microsoft/eslint-plugin-spfx": "1.20.2",
|
||||
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
|
||||
"@microsoft/sp-build-web": "1.18.2",
|
||||
"@microsoft/sp-module-interfaces": "1.18.2",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@microsoft/sp-build-web": "1.20.2",
|
||||
"@microsoft/sp-module-interfaces": "1.20.2",
|
||||
"@rushstack/eslint-config": "4.0.1",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webpack-env": "1.15.2",
|
||||
"@typescript-eslint/eslint-plugin": "^8.12.2",
|
||||
"@typescript-eslint/parser": "^8.12.2",
|
||||
"ajv": "6.12.5",
|
||||
"eslint": "8.7.0",
|
||||
"eslint": "8.57.0",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"timers-browserify": "^2.0.12",
|
||||
"typescript": "4.7.4",
|
||||
"unlazy-loader": "0.1.3",
|
||||
"webpack-bundle-analyzer": "^3.0.3"
|
||||
"url": "^0.11.4",
|
||||
"webpack-bundle-analyzer": "^4.10.2"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,17 @@
|
|||
import { html } from 'common-tags';
|
||||
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 { format } from 'date-fns'; // For date formatting
|
||||
import * as _ from 'lodash';
|
||||
|
||||
abstract class BaseTemplateService {
|
||||
private _helper: any = null;
|
||||
public CurrentLocale: string = "en";
|
||||
|
||||
constructor() {
|
||||
// Registers all helpers
|
||||
// Register custom helpers
|
||||
this.registerTemplateServices();
|
||||
}
|
||||
|
||||
private async LoadHandlebarsHelpers(): Promise<void> {
|
||||
this._helper = HandlebarsHelpers({
|
||||
handlebars: Handlebars
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default Handlebars list item template used in list layout
|
||||
* @returns the template HTML markup
|
||||
|
@ -37,7 +26,7 @@ abstract class BaseTemplateService {
|
|||
<a href="{{channel/item/link}}" target="_blank">{{channel/item/title}}</a>
|
||||
</div>
|
||||
<div class="itemDate">
|
||||
{{getDate channel/item/pubDate "MM/DD/YYYY"}}
|
||||
{{getDate channel/item/pubDate "MM/dd/yyyy"}}
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{{getShortText channel/item/description 100 true}}}
|
||||
|
@ -71,7 +60,7 @@ abstract class BaseTemplateService {
|
|||
<div class="ms-Grid-col ms-sm12">
|
||||
<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="dateText">{{getDate channel/item/pubDate "MM/DD/YYYY"}}</span>
|
||||
<span class="dateText">{{getDate channel/item/pubDate "MM/dd/yyyy"}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -93,240 +82,84 @@ abstract class BaseTemplateService {
|
|||
* Registers useful helpers for search results templates
|
||||
*/
|
||||
private registerTemplateServices(): void {
|
||||
// Return the URL or Title part of a URL automatic managed property
|
||||
// <p>{{getUrlField MyLinkOWSURLH "Title"}}</p>
|
||||
// Register a helper for URL field extraction
|
||||
Handlebars.registerHelper("getUrlField", (urlField: string, value: "URL" | "Title") => {
|
||||
const separatorPos = urlField.indexOf(",");
|
||||
if (value === "URL") {
|
||||
return urlField.substr(0, separatorPos);
|
||||
}
|
||||
return urlField.substr(separatorPos + 1).trim();
|
||||
return value === "URL" ? urlField.substring(0, separatorPos) : urlField.substring(separatorPos + 1).trim();
|
||||
});
|
||||
|
||||
// Return the formatted date according to current locale using moment.js
|
||||
// <p>{{getDate Created "LL"}}</p>
|
||||
Handlebars.registerHelper("getDate", (date: string, format: string) => {
|
||||
try {
|
||||
const d = this._helper.moment(date, format, { lang: this.CurrentLocale, datejs: false });
|
||||
return d;
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
// Register a date formatting helper using date-fns
|
||||
Handlebars.registerHelper("getDate", (date: string, formatPattern: string) => {
|
||||
return format(new Date(date), formatPattern); // Adjusts date format using date-fns
|
||||
});
|
||||
|
||||
// Get the first maxLength characters from a string
|
||||
// <p>{{getShortText Description 100}}</p>
|
||||
// Register a helper for getting a substring
|
||||
Handlebars.registerHelper("getShortText", (inputString: string, maxLength: number, ignoreHtml: boolean) => {
|
||||
if (!inputString || inputString.length < 1) {
|
||||
return "";
|
||||
}
|
||||
if (!inputString) return "";
|
||||
|
||||
//remove Html tags if necessary
|
||||
if (ignoreHtml) {
|
||||
const div = document.createElement("div");
|
||||
div.innerHTML = inputString;
|
||||
inputString = (div.textContent || div.innerText || "").replace(/ /ig, "").trim();
|
||||
inputString = (div.textContent || div.innerText || "").replace(/ /g, "").trim();
|
||||
}
|
||||
|
||||
if (inputString.length < maxLength) {
|
||||
return inputString;
|
||||
}
|
||||
else {
|
||||
return inputString.substr(0, maxLength).trim() + "...";
|
||||
}
|
||||
return inputString.length <= maxLength ? inputString : `${inputString.slice(0, maxLength)}...`;
|
||||
});
|
||||
}
|
||||
|
||||
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¸
|
||||
* @returns the compiled HTML template string
|
||||
*/
|
||||
public async processTemplate(templateContext: any, templateContent: string): Promise<string> {
|
||||
// Process the Handlebars template
|
||||
const handlebarFunctionNames = [
|
||||
"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;
|
||||
}
|
||||
}
|
||||
// Register helpers only once
|
||||
if (!Handlebars.helpers.after) this.registerHandlebarsHelpers();
|
||||
|
||||
// Compile and execute template
|
||||
const template = Handlebars.compile(templateContent);
|
||||
const result = template(templateContext);
|
||||
|
||||
return result;
|
||||
return template(templateContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the template fiel path is correct
|
||||
* @param filePath the file path string
|
||||
*/
|
||||
public static isValidTemplateFile(filePath: string): boolean {
|
||||
|
||||
const path = filePath.toLowerCase().trim();
|
||||
const pathExtension = path.substring(path.lastIndexOf('.'));
|
||||
return (pathExtension === '.htm' || pathExtension === '.html');
|
||||
const extension = path.substring(path.lastIndexOf('.'));
|
||||
return extension === '.htm' || extension === '.html';
|
||||
}
|
||||
|
||||
public abstract getFileContent(fileUrl: string): Promise<string>;
|
||||
|
||||
public abstract ensureFileResolves(fileUrl: string): Promise<void>;
|
||||
}
|
||||
|
||||
export default BaseTemplateService;
|
||||
|
||||
|
|
|
@ -278,7 +278,6 @@ export default class RssReaderWebPart extends BaseClientSideWebPart<IRssReaderWe
|
|||
* @param newValue the new value for this property
|
||||
*/
|
||||
private async _onCustomPropertyPaneChange(propertyPath: string, newValue: any): Promise<void> {
|
||||
|
||||
// Stores the new value in web part properties
|
||||
update(this.properties, propertyPath, (): any => { return newValue; });
|
||||
|
||||
|
|
|
@ -39,13 +39,15 @@ export default class RssResultsTemplate extends React.Component<IRssResultsTempl
|
|||
|
||||
}
|
||||
|
||||
// public componentWillReceiveProps(nextProps: IRssResultsTemplateProps): void {
|
||||
public componentDidUpdate(prevProps: any): void {
|
||||
|
||||
public componentDidUpdate(prevProps: IRssResultsTemplateProps): void {
|
||||
// Only update template if props have changed
|
||||
if (
|
||||
prevProps.templateContent !== this.props.templateContent ||
|
||||
prevProps.templateContext !== this.props.templateContext
|
||||
) {
|
||||
this._updateTemplate(this.props);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private async _updateTemplate(props: IRssResultsTemplateProps): Promise<void> {
|
||||
|
||||
const templateContent = props.templateContent;
|
||||
|
|
|
@ -279,7 +279,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
const rssFeed: IRssReaderResponse = await rssReaderService.getFeed(feedRequest);
|
||||
|
||||
if (rssFeed && rssFeed.query && rssFeed.query.results) {
|
||||
|
||||
this.setState({
|
||||
rssFeedReady: true,
|
||||
rssFeed: rssFeed,
|
||||
|
@ -288,7 +287,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
|
||||
}
|
||||
else {
|
||||
|
||||
this.setState({
|
||||
rssFeedReady: true,
|
||||
rssFeed: null,
|
||||
|
@ -298,7 +296,6 @@ export default class RssReader extends React.Component<IRssReaderProps, IRssRead
|
|||
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
this.setState({
|
||||
rssFeedReady: false,
|
||||
rssFeed: null,
|
||||
|
|
Loading…
Reference in New Issue