Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix compatibility issue with ESLint v9 #137

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"js-levenshtein-esm": "^1.2.0"
},
"peerDependencies": {
"eslint": ">=5"
"eslint": ">=8.40.0"
},
"devDependencies": {
"@types/chai": "^4.3.5",
Expand Down
2 changes: 1 addition & 1 deletion src/rules/attach-shadow-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const rule: Rule.RuleModule = {
// variables should be defined here
let insideNonConstructor = false;
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/define-tag-after-class-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const rule: Rule.RuleModule = {

create(context): Rule.RuleListener {
const seenClasses = new Set<ESTree.Node>();
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/expose-class-on-global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const rule: Rule.RuleModule = {

create(context): Rule.RuleListener {
const seenClasses = new Set<ESTree.Node>();
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
4 changes: 2 additions & 2 deletions src/rules/file-name-matches-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ const rule: Rule.RuleModule = {
},

create(context): Rule.RuleListener {
const source = context.getSourceCode();
const source = context.sourceCode;
const options = context.options?.[0] ?? {};
const userSuffixes = coerceArray(options.suffix ?? []);
const userPrefixes = coerceArray(options.prefix ?? []);
const transforms = coerceArray(options.transform ?? ['kebab', 'camel']);
const matchDirectory = options.matchDirectory === true;

const filename = context.getFilename();
const filename = context.filename;

// We don't want to match stdin and what not
if (!filename || filename === '<input>' || filename === '<text>') {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/guard-super-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const rule: Rule.RuleModule = {
create(context): Rule.RuleListener {
let insideNonNativeElement = false;
let errNode = null;
const source = context.getSourceCode();
const source = context.sourceCode;

const nativeHooks = [
'connectedCallback',
Expand Down
2 changes: 1 addition & 1 deletion src/rules/max-elements-per-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const rule: Rule.RuleModule = {

create(context): Rule.RuleListener {
// variables should be defined here
const source = context.getSourceCode();
const source = context.sourceCode;
const maxElements = context.options[0]?.max ?? 1;
let elementCount = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const rule: Rule.RuleModule = {
// variables should be defined here
let insideCallback = false;
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-child-traversal-in-connectedcallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const rule: Rule.RuleModule = {
// variables should be defined here
let insideCallback = false;
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down Expand Up @@ -136,7 +136,7 @@ const rule: Rule.RuleModule = {
return;
}

const scope = context.getScope();
const scope = context.sourceCode.getScope(node);
const name = node.property.name;

if (isAllowedScope(scope)) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-constructor-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const rule: Rule.RuleModule = {
'title',
'translate'
];
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-constructor-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const rule: Rule.RuleModule = {
'ClassBody > MethodDefinition[kind="constructor"]' +
'[value.params.length > 0]';
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const rule: Rule.RuleModule = {
create(context): Rule.RuleListener {
// variables should be defined here
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-customized-built-in-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const rule: Rule.RuleModule = {

create(context): Rule.RuleListener {
// variables should be defined here
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-exports-with-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const rule: Rule.RuleModule = {
const seenClasses = new Set<ESTree.Node>();
const exportedNodes = new Set<ESTree.Node>();
let hasElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

return {
'ClassDeclaration,ClassExpression': (node: ESTree.Class): void => {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-invalid-extends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const rule: Rule.RuleModule = {
},

create(context): Rule.RuleListener {
const source = context.getSourceCode();
const source = context.sourceCode;
const elementClasses = new Set<ESTree.Class>();
const userAllowedSuperNames = context.options[0]?.allowedSuperNames ?? [];
const elementBaseClasses = getElementBaseClasses(context);
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-method-prefixed-with-on.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const rule: Rule.RuleModule = {
create(context): Rule.RuleListener {
// variables should be defined here
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand All @@ -52,7 +52,7 @@ const rule: Rule.RuleModule = {
if (insideElement) {
const name = getMethodName(node);

if (name && name.startsWith('on')) {
if (name?.startsWith('on')) {
context.report({
node,
messageId: 'noPrefix'
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-self-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const rule: Rule.RuleModule = {
// variables should be defined here
let insideElement = false;
const bannedClassListMethods = ['add', 'remove', 'toggle', 'replace'];
const source = context.getSourceCode();
const source = context.sourceCode;

//----------------------------------------------------------------------
// Helpers
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-typos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const rule: Rule.RuleModule = {
create(context): Rule.RuleListener {
// variables should be defined here
let insideElement = false;
const source = context.getSourceCode();
const source = context.sourceCode;
const lifecycleMethods = [
'connectedCallback',
'disconnectedCallback',
Expand Down
6 changes: 3 additions & 3 deletions src/rules/require-listener-teardown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const rule: Rule.RuleModule = {
// Helpers
//----------------------------------------------------------------------
const shouldTrackListener = (node: ESTree.MemberExpression): boolean => {
const source = context.getSourceCode();
const source = context.sourceCode;

const text = source.getText(node.object);

Expand All @@ -82,7 +82,7 @@ const rule: Rule.RuleModule = {
node.callee.type === 'MemberExpression' &&
shouldTrackListener(node.callee)
) {
const source = context.getSourceCode();
const source = context.sourceCode;
const calleeText = source.getText(node.callee.object);
const [arg0, arg1] = node.arguments;

Expand All @@ -104,7 +104,7 @@ const rule: Rule.RuleModule = {
node.callee.type === 'MemberExpression' &&
shouldTrackListener(node.callee)
) {
const source = context.getSourceCode();
const source = context.sourceCode;
const calleeText = source.getText(node.callee.object);
const [arg0, arg1] = node.arguments;

Expand Down
3 changes: 1 addition & 2 deletions src/util/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export function resolveReference(
return node;
}

const ref = context
.getSourceCode()
const ref = context.sourceCode
.getScope(node)
.references.find((r) => r.identifier.name === node.name);

Expand Down
Loading