Skip to content

Instantly share code, notes, and snippets.

View cartant's full-sized avatar

Nicholas Jamieson cartant

View GitHub Profile
export const windowBy = <K, T>(
keyFn: (t: T) => K
): OperatorFunction<T, GroupedObservable<K, T>> => (source) => source.pipe(
publish((sharedSource) => {
const newWindow = sharedSource.pipe(
distinctUntilChanged((a, b) => keyFn(a) === keyFn(b))
);
return sharedSource.pipe(
groupBy(keyFn, undefined, () =>
newWindow.pipe(
const baseRule = require("./no-foreach");
module.exports = {
meta: {
/* ... */
},
create(context) {
const contextForBaseRule = Object.create(context, {
options: {
value: [{ types: ["Array"] }],
writable: false
TypeError: Error while loading rule 'no-array-foreach': Cannot assign
to read only property 'options' of object '#<Object>'
const baseRule = require("./no-foreach");
module.exports = {
meta: {
/* ... */
},
create(context) {
const contextForBaseRule = Object.create(context);
contextForBaseRule.options = [{ types: ["Array"] }];
return baseRule.create(contextForBaseRule);
}
TypeError: Error while loading rule 'no-array-foreach': 'get' on
proxy: property 'options' is a read-only and non-configurable data
property on the proxy target but the proxy did not return its actual
value (expected '[object Array]' but got '[object Array]')
const baseRule = require("./no-foreach");
module.exports = {
meta: {
/* ... */
},
create(context) {
const contextForBaseRule = new Proxy(context, {
get(target, property, receiver) {
if (property === "options") {
return [{ types: ["Array"] }];
Error while loading rule 'no-array-foreach': You have used a rule
which requires parserServices to be generated. You must therefore
provide a value for the "parserOptions.project" property for
@typescript-eslint/parser.
const baseRule = require("./no-foreach");
module.exports = {
meta: {
/* ... */
},
create(context) {
const contextForBaseRule = {
...context,
options: [{ types: ["Array"] }]
};
TypeError: Error while loading rule 'no-array-foreach': Cannot assign
to read only property 'options' of object '#<Object>'
const baseRule = require("./no-foreach");
module.exports = {
meta: {
/* ... */
deprecated: true,
replacedBy: ["no-foreach"]
},
create(context) {
context.options = [{ types: ["Array"] }];
return baseRule.create(context);