-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/origin/main' into main-beta
# Conflicts: # CHANGELOG.md # e2e/package.json # e2e/tests/__image_snapshots__/homepage-feature-feature-homepage-looks-fine-test-homepage-footer-on-desktop-1-snap.png # eslint/package.json # package-lock.json # package.json # site/package.json
- Loading branch information
Showing
8 changed files
with
95 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-1.44 KB
(93%)
...e-feature-feature-homepage-looks-fine-test-homepage-footer-on-mobile-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
import {lt} from 'semver'; | ||
import color from 'kleur'; | ||
import {log} from './log'; | ||
|
||
const ESL_PACKAGE = '@exadel/esl'; | ||
const PLUGIN_PACKAGE = '@exadel/eslint-plugin-esl'; | ||
export const ESL_PACKAGE = '@exadel/esl'; | ||
export const PLUGIN_PACKAGE = '@exadel/eslint-plugin-esl'; | ||
|
||
function getInstalledVersion(packageName: string): string | null { | ||
export function getInstalledVersion(packageName: string): string { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires | ||
return require(`${packageName}/package.json`).version; | ||
} catch (error) { | ||
return null; | ||
return ''; | ||
} | ||
} | ||
|
||
export function checkVersion(): void { | ||
const eslintVersion = getInstalledVersion(PLUGIN_PACKAGE); | ||
const eslVersion = getInstalledVersion(ESL_PACKAGE); | ||
if (!(eslintVersion && eslVersion && lt(eslintVersion, eslVersion))) return; | ||
export const ESL_PACKAGE_VERSION = getInstalledVersion(ESL_PACKAGE); | ||
export const PLUGIN_PACKAGE_VERSION = getInstalledVersion(PLUGIN_PACKAGE); | ||
|
||
console.log(`\n${color.yellow('⚠️ Warning:')} | ||
Your installed version of ${color.yellow(PLUGIN_PACKAGE)} (${color.red(eslintVersion)}) \ | ||
is lower than version of main package ${color.yellow(ESL_PACKAGE)} (${color.green(eslVersion)}). | ||
Please update ${color.yellow(PLUGIN_PACKAGE)} to the latest version ${color.green(eslVersion)}\n`); | ||
if (lt(PLUGIN_PACKAGE_VERSION, ESL_PACKAGE_VERSION)) { | ||
log(`Your installed version of ${PLUGIN_PACKAGE} (${PLUGIN_PACKAGE_VERSION})\ | ||
is lower than version of main package ${ESL_PACKAGE} (${ESL_PACKAGE_VERSION}). | ||
Please update ${PLUGIN_PACKAGE} to the latest version ${ESL_PACKAGE_VERSION}`, 'warn'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import color from 'kleur'; | ||
import type {Rule} from 'eslint'; | ||
|
||
const LOGGERS = { | ||
error: console.error, | ||
warn: console.warn, | ||
off: console.info, | ||
}; | ||
const HEADERS = { | ||
error: color.red('[ESL Lint Plugin] ❌ Error:'), | ||
warn: color.yellow('[ESL Lint Plugin] ⚠️ Warning:'), | ||
off: color.blue('[ESL Lint Plugin] ℹ️ Info:'), | ||
}; | ||
|
||
export function log(msg: string, severity: 'error' | 'warn' | 'off' = 'off'): void { | ||
LOGGERS[severity](`\n${HEADERS[severity]}\n${msg}`); | ||
} | ||
|
||
export function buildLoggingRule(msg: string, severity: 'error' | 'warn' | 'off' = 'off'): Rule.RuleModule { | ||
log(msg, severity); | ||
return { | ||
meta: { | ||
docs: { | ||
description: msg, | ||
} | ||
}, | ||
create: (): Rule.RuleListener => ({}) | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import {lte} from 'semver'; | ||
import {ESL_PACKAGE_VERSION} from '../../core/check-version'; | ||
import {buildLoggingRule} from '../../core/log'; | ||
import {buildRule} from '../../core/deprecated-class-method'; | ||
import type {replacementMethodCfg} from '../../core/deprecated-class-method'; | ||
|
||
import type * as ESTree from 'estree'; | ||
import type {ESLintReplacementMethodCfg} from '../../core/deprecated-class-method'; | ||
|
||
const AVAILABLE_SINCE = '5.0.0-beta.24'; | ||
const isActual = lte(ESL_PACKAGE_VERSION, AVAILABLE_SINCE); | ||
|
||
/** | ||
* Rule for deprecated 'parse' method of {@link ESLMediaRuleList} | ||
*/ | ||
export default buildRule({ | ||
className: 'ESLMediaRuleList', | ||
deprecatedMethod: 'parse', | ||
getReplacementMethod: (expression): replacementMethodCfg => { | ||
const args = expression.arguments; | ||
if (expression.type !== 'CallExpression') return {message: 'parseQuery or parseTuple'}; | ||
const methodName = args.length === 1 || (args[1]?.type !== 'Literal' && args[1]?.type !== 'TemplateLiteral') ? 'parseQuery' : 'parseTuple'; | ||
return {message: methodName, replacement: methodName}; | ||
} | ||
}); | ||
export default isActual ? | ||
buildRule({ | ||
className: 'ESLMediaRuleList', | ||
deprecatedMethod: 'parse', | ||
getReplacementMethod: (expression): ESLintReplacementMethodCfg | string => { | ||
const args = expression.arguments; | ||
const isLiteral = (node: ESTree.Expression | ESTree.SpreadElement): boolean => node?.type === 'Literal' || node?.type === 'TemplateLiteral'; | ||
if (expression.type === 'CallExpression' && args.length === 1) return 'parseQuery'; | ||
if (expression.type === 'CallExpression' && args.length === 2 && isLiteral(args[1])) return 'parseTuple'; | ||
if (expression.type === 'CallExpression' && args.length === 3) return 'parseTuple'; | ||
return {message: 'ESLMediaRuleList.parseQuery or ESLMediaRuleList.parseTuple'}; | ||
} | ||
}) : | ||
buildLoggingRule(`'ESLMediaRuleList.parse' was updated in v${AVAILABLE_SINCE}. Rule 'deprecated-4/media-rule-list-parse' is skipped.`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters